2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-27 09:10:51 +00:00

[CI] Playwright improvements (#9395)

* Allow port 4173 (vite preview)

* Change 'base' attr based on vite command

* Allow api_host to be specified separately

* Harden API host functionality

* Adjust server selections

* Cleanup vite.config.ts

* Adjust playwright configuration

- Allow to run in "production" mode
- Builds the code first
- Runs only the backend web server
- Not suitable for coverage

* Tweak github actions

* Tweak QC file

* Reduce number of steps

* Tweak CI file

* Fix typo

* Ensure translation before build

* Fix hard-coded test

* Test tweaks

* uncomment

* Revert some changes

* Run with gunicorn, single worker

* Reduce log output in DEBUG mode

* Update deps

* Add global-setup func

* Fix for .gitignore file

* Cached auth state

* Tweak login func

* Updated tests

* Enable parallel workers again

* Simplify config

* Try with a single worker again

* Single retry mode

* Run auth setup first

- Prevent issues with parallel test doing login

* Improve test setup process

* Tweaks

* Bump to 3 workers

* Tweak playwright settings

* Revert change

* Revert change
This commit is contained in:
Oliver
2025-03-30 14:12:48 +11:00
committed by GitHub
parent 858eb8f807
commit 7f5a447769
40 changed files with 794 additions and 575 deletions

View File

@ -5,15 +5,17 @@ import {
loadTab,
navigate
} from '../helpers';
import { doQuickLogin } from '../login';
import { doCachedLogin } from '../login';
/**
* CHeck each panel tab for the "Parts" page
*/
test('Parts - Tabs', async ({ page }) => {
await doQuickLogin(page);
test('Parts - Tabs', async ({ browser }) => {
const page = await doCachedLogin(browser);
await page.getByRole('tab', { name: 'Parts' }).click();
await page.waitForURL('**/part/category/index/**');
await page
.getByLabel('panel-tabs-partcategory')
.getByRole('tab', { name: 'Parts' })
@ -56,10 +58,8 @@ test('Parts - Tabs', async ({ page }) => {
await loadTab(page, 'Build Orders');
});
test('Parts - Manufacturer Parts', async ({ page }) => {
await doQuickLogin(page);
await navigate(page, 'part/84/suppliers');
test('Parts - Manufacturer Parts', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/84/suppliers' });
await loadTab(page, 'Suppliers');
await page.getByText('Hammond Manufacturing').click();
@ -69,10 +69,8 @@ test('Parts - Manufacturer Parts', async ({ page }) => {
await page.getByText('1551ACLR - 1551ACLR').waitFor();
});
test('Parts - Supplier Parts', async ({ page }) => {
await doQuickLogin(page);
await navigate(page, 'part/15/suppliers');
test('Parts - Supplier Parts', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/15/suppliers' });
await loadTab(page, 'Suppliers');
await page.getByRole('cell', { name: 'DIG-84670-SJI' }).click();
@ -82,11 +80,8 @@ test('Parts - Supplier Parts', async ({ page }) => {
await page.getByText('DIG-84670-SJI - R_550R_0805_1%').waitFor();
});
test('Parts - Locking', async ({ page }) => {
await doQuickLogin(page);
// Navigate to a known assembly which is *not* locked
await navigate(page, 'part/104/bom');
test('Parts - Locking', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/104/bom' });
await loadTab(page, 'Bill of Materials');
await page.getByLabel('action-button-add-bom-item').waitFor();
await loadTab(page, 'Parameters');
@ -108,11 +103,9 @@ test('Parts - Locking', async ({ page }) => {
await page.getByText('Part parameters cannot be').waitFor();
});
test('Parts - Allocations', async ({ page }) => {
await doQuickLogin(page);
test('Parts - Allocations', async ({ browser }) => {
// Let's look at the allocations for a single stock item
await navigate(page, 'stock/item/324/');
const page = await doCachedLogin(browser, { url: 'stock/item/324/' });
await loadTab(page, 'Allocations');
await page.getByRole('button', { name: 'Build Order Allocations' }).waitFor();
@ -173,11 +166,9 @@ test('Parts - Allocations', async ({ page }) => {
await page.keyboard.press('Escape');
});
test('Parts - Pricing (Nothing, BOM)', async ({ page }) => {
await doQuickLogin(page);
test('Parts - Pricing (Nothing, BOM)', async ({ browser }) => {
// Part with no history
await navigate(page, 'part/82/pricing');
const page = await doCachedLogin(browser, { url: 'part/82/pricing' });
await page.getByText('Small plastic enclosure, black').waitFor();
await loadTab(page, 'Part Pricing');
@ -223,11 +214,9 @@ test('Parts - Pricing (Nothing, BOM)', async ({ page }) => {
await page.waitForURL('**/part/98/**');
});
test('Parts - Pricing (Supplier)', async ({ page }) => {
await doQuickLogin(page);
test('Parts - Pricing (Supplier)', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/55/pricing' });
// Part
await navigate(page, 'part/55/pricing');
await page.getByText('Ceramic capacitor, 100nF in').waitFor();
await loadTab(page, 'Part Pricing');
await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor();
@ -249,11 +238,8 @@ test('Parts - Pricing (Supplier)', async ({ page }) => {
// await page.waitForURL('**/purchasing/supplier-part/697/');
});
test('Parts - Pricing (Variant)', async ({ page }) => {
await doQuickLogin(page);
// Part
await navigate(page, 'part/106/pricing');
test('Parts - Pricing (Variant)', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/106/pricing' });
await page.getByText('A chair - available in multiple colors').waitFor();
await loadTab(page, 'Part Pricing');
await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor();
@ -275,11 +261,8 @@ test('Parts - Pricing (Variant)', async ({ page }) => {
await page.waitForURL('**/part/109/**');
});
test('Parts - Pricing (Internal)', async ({ page }) => {
await doQuickLogin(page);
// Part
await navigate(page, 'part/65/pricing');
test('Parts - Pricing (Internal)', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/65/pricing' });
await page.getByText('Socket head cap screw, M2').waitFor();
await loadTab(page, 'Part Pricing');
await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor();
@ -300,11 +283,9 @@ test('Parts - Pricing (Internal)', async ({ page }) => {
await page.getByText('Part *M2x4 SHCSSocket head').click();
});
test('Parts - Pricing (Purchase)', async ({ page }) => {
await doQuickLogin(page);
test('Parts - Pricing (Purchase)', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/69/pricing' });
// Part
await navigate(page, 'part/69/pricing');
await page.getByText('1.25mm Pitch, PicoBlade PCB').waitFor();
await loadTab(page, 'Part Pricing');
await page.getByLabel('Part Pricing').getByText('Part Pricing').waitFor();
@ -322,10 +303,8 @@ test('Parts - Pricing (Purchase)', async ({ page }) => {
await page.getByText('2022-04-29').waitFor();
});
test('Parts - Attachments', async ({ page }) => {
await doQuickLogin(page);
await navigate(page, 'part/69/attachments');
test('Parts - Attachments', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/69/attachments' });
// Submit a new external link
await page.getByLabel('action-button-add-external-').click();
@ -344,10 +323,8 @@ test('Parts - Attachments', async ({ page }) => {
await page.getByRole('button', { name: 'Cancel' }).click();
});
test('Parts - Parameters', async ({ page }) => {
await doQuickLogin(page);
await navigate(page, 'part/69/parameters');
test('Parts - Parameters', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/69/parameters' });
// Create a new template
await page.getByLabel('action-button-add-parameter').click();
@ -371,10 +348,8 @@ test('Parts - Parameters', async ({ page }) => {
await page.getByRole('button', { name: 'Cancel' }).click();
});
test('Parts - Notes', async ({ page }) => {
await doQuickLogin(page);
await navigate(page, 'part/69/notes');
test('Parts - Notes', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/69/notes' });
// Enable editing
await page.getByLabel('Enable Editing').waitFor();
@ -393,20 +368,16 @@ test('Parts - Notes', async ({ page }) => {
await page.getByLabel('Close Editor').waitFor();
});
test('Parts - 404', async ({ page }) => {
await doQuickLogin(page);
await navigate(page, 'part/99999/');
test('Parts - 404', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/99999/' });
await page.getByText('Page Not Found', { exact: true }).waitFor();
// Clear out any console error messages
await page.evaluate(() => console.clear());
});
test('Parts - Revision', async ({ page }) => {
await doQuickLogin(page);
await navigate(page, 'part/906/details');
test('Parts - Revision', async ({ browser }) => {
const page = await doCachedLogin(browser, { url: 'part/906/details' });
await page.getByText('Revision of').waitFor();
await page.getByText('Select Part Revision').waitFor();
@ -421,10 +392,10 @@ test('Parts - Revision', async ({ page }) => {
await page.getByText('Select Part Revision').waitFor();
});
test('Parts - Bulk Edit', async ({ page }) => {
await doQuickLogin(page);
await navigate(page, 'part/category/index/parts');
test('Parts - Bulk Edit', async ({ browser }) => {
const page = await doCachedLogin(browser, {
url: 'part/category/index/parts'
});
// Edit the category for multiple parts
await page.getByLabel('Select record 1', { exact: true }).click();