From 3f38cd30bf0f58cd863a843a342be88dd4b1b272 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 17 Apr 2024 21:57:19 +0200 Subject: [PATCH] add id for chart for easier testing --- .../part/pricing/PricingOverviewPanel.tsx | 2 +- src/frontend/tests/pages/pui_part.spec.ts | 45 ++++++++++++++----- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/frontend/src/pages/part/pricing/PricingOverviewPanel.tsx b/src/frontend/src/pages/part/pricing/PricingOverviewPanel.tsx index c034793e29..9d840d007e 100644 --- a/src/frontend/src/pages/part/pricing/PricingOverviewPanel.tsx +++ b/src/frontend/src/pages/part/pricing/PricingOverviewPanel.tsx @@ -189,7 +189,7 @@ export default function PricingOverviewPanel({ - + diff --git a/src/frontend/tests/pages/pui_part.spec.ts b/src/frontend/tests/pages/pui_part.spec.ts index c1d2e7e143..9b8b756c60 100644 --- a/src/frontend/tests/pages/pui_part.spec.ts +++ b/src/frontend/tests/pages/pui_part.spec.ts @@ -1,22 +1,45 @@ import { expect, test } from '@playwright/test'; -import { user } from '../defaults'; +import { baseUrl, user } from '../defaults'; +import { doQuickLogin } from '../login'; test('PUI - Pages - Part - Pricing', async ({ page }) => { - await page.goto('./platform/'); - await expect(page).toHaveTitle('InvenTree'); - await page.waitForURL('**/platform/'); - await page.getByLabel('username').fill(user.username); - await page.getByLabel('password').fill(user.password); - await page.getByRole('button', { name: 'Log in' }).click(); - await page.waitForURL('**/platform'); - await page.goto('./platform/home'); + await doQuickLogin(page); - await page.goto('./platform/part/82/pricing'); - await page.locator('a').filter({ hasText: '1551ABKSmall plastic' }).click(); + // Part with no history + await page.goto(`${baseUrl}/part/82/pricing`); + await page.getByText('1551ABK').waitFor(); await page.getByRole('tab', { name: 'Part Pricing' }).click(); await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor(); await page.getByRole('button', { name: 'Pricing Overview' }).waitFor(); await page.getByRole('button', { name: 'Pricing Overview' }).waitFor(); await page.getByText('Last Updated').waitFor(); + await page.getByRole('button', { name: 'Purchase History' }).isDisabled(); + await page.getByRole('button', { name: 'Internal Pricing' }).isDisabled(); + await page.getByRole('button', { name: 'Supplier Pricing' }).isDisabled(); + + // Part with history + await page.goto('./platform/part/108/pricing'); + await page.getByText('Part: Blue Chair').waitFor(); + await page.getByRole('tab', { name: 'Part Pricing' }).click(); + await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor(); + await page.getByRole('button', { name: 'Pricing Overview' }).waitFor(); + await page.getByRole('button', { name: 'Pricing Overview' }).waitFor(); + await page.getByText('Last Updated').waitFor(); + await page.getByRole('button', { name: 'Internal Pricing' }).isDisabled(); + await page.getByRole('button', { name: 'Sale History' }).isDisabled(); + await page.getByRole('button', { name: 'Sale Pricing' }).isDisabled(); + await page.getByRole('button', { name: 'BOM Pricing' }).isEnabled(); + + // Overview Graph + await page.getByText('BOM PricingOverall Pricing').waitFor(); + let graph = page.locator('#pricing-overview-chart'); + await graph.waitFor(); + //await graph.screenshot({ path: 'pui_part_pricing_overview.png' }); + await graph.getByText('$45').waitFor(); + await graph.getByText('BOM Pricing').waitFor(); + await graph.getByText('Overall Pricing').waitFor(); + await graph.locator('path').nth(1).hover(); + //await graph.screenshot({ path: 'pui_part_pricing_overview_hover.png' }); + //await page.getByText('min_value: $43*').waitFor(); });