2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 03:26:45 +00:00
InvenTree/src/frontend/tests/pui_general.spec.ts
Oliver 7f5a447769
[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
2025-03-30 14:12:48 +11:00

61 lines
2.0 KiB
TypeScript

import { test } from './baseFixtures.js';
import { globalSearch } from './helpers.js';
import { doCachedLogin } from './login.js';
/**
* Test for integration of django admin button
*/
test('Admin Button', async ({ browser }) => {
const page = await doCachedLogin(browser, {
username: 'admin',
password: 'inventree',
url: 'company/1/details'
});
// Click on the admin button
await page.getByLabel(/action-button-open-in-admin/).click();
await page.waitForURL('**/test-admin/company/company/1/change/**');
await page.getByRole('heading', { name: 'Change Company' }).waitFor();
await page.getByRole('link', { name: 'View on site' }).waitFor();
});
// Tests for the global search functionality
test('Search', async ({ browser }) => {
const page = await doCachedLogin(browser, {
username: 'steven',
password: 'wizardstaff'
});
await globalSearch(page, 'another customer');
// Check for expected results
await page.locator('a').filter({ hasText: 'Customer B' }).first().waitFor();
await page.locator('a').filter({ hasText: 'Customer C' }).first().waitFor();
await page.locator('a').filter({ hasText: 'Customer D' }).first().waitFor();
await page.locator('a').filter({ hasText: 'Customer E' }).first().waitFor();
// Click through to the "Customer" results
await page.getByRole('button', { name: 'view-all-results-customer' }).click();
await page.waitForURL('**/sales/index/customers**');
await page.getByText('Custom table filters are active').waitFor();
await globalSearch(page, '0402 res');
await page
.locator('span')
.filter({ hasText: 'Parts - 16 results' })
.first()
.waitFor();
await page
.locator('span')
.filter({ hasText: 'Supplier Parts - 138 results' })
.first()
.waitFor();
await page.getByLabel('view-all-results-manufacturerpart').click();
await page.waitForURL('**/purchasing/index/manufacturer-parts**');
await page.getByRole('cell', { name: 'RT0402BRD07100KL' }).waitFor();
});