add id for chart for easier testing

This commit is contained in:
Matthias Mair 2024-04-17 21:57:19 +02:00
parent b061d8e43b
commit 3f38cd30bf
No known key found for this signature in database
GPG Key ID: A593429DDA23B66A
2 changed files with 35 additions and 12 deletions

View File

@ -189,7 +189,7 @@ export default function PricingOverviewPanel({
<DataTable records={overviewData} columns={columns} />
</Stack>
<ResponsiveContainer width="100%" height={500}>
<BarChart data={overviewData}>
<BarChart data={overviewData} id="pricing-overview-chart">
<XAxis dataKey="title" />
<YAxis
tickFormatter={(value, index) =>

View File

@ -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();
});