2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-02-14 02:07:13 +00:00

[bug] Playwright fixes (#9933)

* Fixes for playwright testing

- Ensure cookies are completely cleaned  between sessions
- Fix base URL based on vite command
- Fix samesite cookie mode
- Prevent /static/ files being served by web server on :8000

* Remove gunicorn option

* Readjust base URL

* Simplify doCachedLogin

* Fix logic func

* Revert webserver cmd

* Set base URL in playwrightconfig file

* Fix URL checks

* Fix URL definitions

* adjust playwright base URL

* Tweak for URL helper

* Further login tweaks

* Tweak test

* wait for API before starting tests

* Handle error

* Adjust login functions

* Don't use gunicorn

- But still use the webserver to serve static files in CI

* Enhanced login functions

* Tweak login tests

* Fix broken test

* Flipped the flippies
This commit is contained in:
Oliver
2025-07-02 22:12:17 +10:00
committed by GitHub
parent 2ce7e225ad
commit 3f14ae3f7d
11 changed files with 169 additions and 87 deletions

View File

@@ -1,5 +1,3 @@
import { baseUrl } from './defaults';
/**
* Open the filter drawer for the currently visible table
* @param page - The page object
@@ -73,21 +71,30 @@ export const clickOnRowMenu = async (cell) => {
await row.getByLabel(/row-action-menu-/i).click();
};
interface NavigateOptions {
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
baseUrl?: string;
}
/**
* Navigate to the provided page, and wait for loading to complete
* @param page
* @param url
*/
export const navigate = async (page, url: string) => {
if (!url.startsWith(baseUrl)) {
if (url.startsWith('/')) {
url = url.slice(1);
}
url = `${baseUrl}/${url}`;
export const navigate = async (
page,
url: string,
options?: NavigateOptions
) => {
if (!url.startsWith('http') && !url.includes('web')) {
url = `/web/${url}`.replaceAll('//', '/');
}
await page.goto(url);
const path: string = options?.baseUrl
? new URL(url, options.baseUrl).toString()
: url;
await page.goto(path, { waitUntil: options?.waitUntil ?? 'load' });
};
/**