mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-03 15:52: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:
@@ -1,49 +1,45 @@
|
||||
import { expect, test } from './baseFixtures.js';
|
||||
import { apiUrl } from './defaults.js';
|
||||
import { getRowFromCell, loadTab, navigate } from './helpers.js';
|
||||
import { doQuickLogin } from './login.js';
|
||||
import { doCachedLogin } from './login.js';
|
||||
import { setSettingState } from './settings.js';
|
||||
|
||||
/**
|
||||
* Adjust language and color settings
|
||||
*
|
||||
* TODO: Reimplement this - without logging out a cached user
|
||||
*/
|
||||
test('Settings - Language / Color', async ({ page }) => {
|
||||
await doQuickLogin(page);
|
||||
// test('Settings - Language / Color', async ({ browser }) => {
|
||||
// const page = await doCachedLogin(browser);
|
||||
|
||||
await page.getByRole('button', { name: 'Ally Access' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Logout' }).click();
|
||||
await page.getByRole('button', { name: 'Send me an email' }).click();
|
||||
await page.getByLabel('Language toggle').click();
|
||||
await page.getByLabel('Select language').first().click();
|
||||
await page.getByRole('option', { name: 'German' }).click();
|
||||
await page.waitForTimeout(200);
|
||||
// await page.getByRole('button', { name: 'Ally Access' }).click();
|
||||
// await page.getByRole('menuitem', { name: 'Logout' }).click();
|
||||
// await page.getByRole('button', { name: 'Send me an email' }).click();
|
||||
// await page.getByLabel('Language toggle').click();
|
||||
// await page.getByLabel('Select language').first().click();
|
||||
// await page.getByRole('option', { name: 'German' }).click();
|
||||
// await page.waitForTimeout(200);
|
||||
|
||||
await page.getByRole('button', { name: 'Benutzername und Passwort' }).click();
|
||||
await page.getByPlaceholder('Ihr Benutzername').click();
|
||||
await page.getByPlaceholder('Ihr Benutzername').fill('admin');
|
||||
await page.getByPlaceholder('Ihr Benutzername').press('Tab');
|
||||
await page.getByPlaceholder('Dein Passwort').fill('inventree');
|
||||
await page.getByRole('button', { name: 'Anmelden' }).click();
|
||||
await page.waitForTimeout(200);
|
||||
// await page.getByRole('button', { name: 'Benutzername und Passwort' }).click();
|
||||
// await page.getByPlaceholder('Ihr Benutzername').click();
|
||||
// await page.getByPlaceholder('Ihr Benutzername').fill('admin');
|
||||
// await page.getByPlaceholder('Ihr Benutzername').press('Tab');
|
||||
// await page.getByPlaceholder('Dein Passwort').fill('inventree');
|
||||
// await page.getByRole('button', { name: 'Anmelden' }).click();
|
||||
// await page.waitForTimeout(200);
|
||||
|
||||
// Note: changes to the dashboard have invalidated these tests (for now)
|
||||
// await page
|
||||
// .locator('span')
|
||||
// .filter({ hasText: 'AnzeigeneinstellungenFarbmodusSprache' })
|
||||
// .getByRole('button')
|
||||
// .click();
|
||||
// await page
|
||||
// .locator('span')
|
||||
// .filter({ hasText: 'AnzeigeneinstellungenFarbmodusSprache' })
|
||||
// .getByRole('button')
|
||||
// .click();
|
||||
// await page.getByRole('tab', { name: 'Dashboard' }).click();
|
||||
// await page.waitForURL('**/web/home');
|
||||
// });
|
||||
|
||||
await page.getByRole('tab', { name: 'Dashboard' }).click();
|
||||
await page.waitForURL('**/web/home');
|
||||
});
|
||||
test('Settings - User theme', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
username: 'allaccess',
|
||||
password: 'nolimits'
|
||||
});
|
||||
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
test('Settings - User theme', async ({ page }) => {
|
||||
await doQuickLogin(page);
|
||||
await page.getByRole('button', { name: 'Ally Access' }).click();
|
||||
await page.getByRole('menuitem', { name: 'Account settings' }).click();
|
||||
|
||||
@@ -82,14 +78,14 @@ test('Settings - User theme', async ({ page }) => {
|
||||
// primary
|
||||
await page.getByLabel('#fab005').click();
|
||||
await page.getByLabel('#228be6').click();
|
||||
|
||||
// language
|
||||
await page.getByRole('button', { name: 'Use pseudo language' }).click();
|
||||
});
|
||||
|
||||
test('Settings - Admin', async ({ page }) => {
|
||||
test('Settings - Admin', async ({ browser }) => {
|
||||
// Note here we login with admin access
|
||||
await doQuickLogin(page, 'admin', 'inventree');
|
||||
const page = await doCachedLogin(browser, {
|
||||
username: 'admin',
|
||||
password: 'inventree'
|
||||
});
|
||||
|
||||
// User settings
|
||||
await page.getByRole('button', { name: 'admin' }).click();
|
||||
@@ -184,9 +180,12 @@ test('Settings - Admin', async ({ page }) => {
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
});
|
||||
|
||||
test('Settings - Admin - Barcode History', async ({ page, request }) => {
|
||||
test('Settings - Admin - Barcode History', async ({ browser, request }) => {
|
||||
// Login with admin credentials
|
||||
await doQuickLogin(page, 'admin', 'inventree');
|
||||
const page = await doCachedLogin(browser, {
|
||||
username: 'admin',
|
||||
password: 'inventree'
|
||||
});
|
||||
|
||||
// Ensure that the "save scans" setting is enabled
|
||||
await setSettingState({
|
||||
@@ -221,11 +220,14 @@ test('Settings - Admin - Barcode History', async ({ page, request }) => {
|
||||
});
|
||||
});
|
||||
|
||||
test('Settings - Admin - Unauthorized', async ({ page }) => {
|
||||
test('Settings - Admin - Unauthorized', async ({ browser }) => {
|
||||
// Try to access "admin" page with a non-staff user
|
||||
await doQuickLogin(page, 'allaccess', 'nolimits');
|
||||
const page = await doCachedLogin(browser, {
|
||||
username: 'allaccess',
|
||||
password: 'nolimits',
|
||||
url: 'settings/admin/'
|
||||
});
|
||||
|
||||
await navigate(page, 'settings/admin/');
|
||||
await page.waitForURL('**/settings/admin/**');
|
||||
|
||||
// Should get a permission denied message
|
||||
@@ -252,9 +254,12 @@ test('Settings - Admin - Unauthorized', async ({ page }) => {
|
||||
});
|
||||
|
||||
// Test for user auth configuration
|
||||
test('Settings - Auth - Email', async ({ page }) => {
|
||||
await doQuickLogin(page, 'allaccess', 'nolimits');
|
||||
await navigate(page, 'settings/user/');
|
||||
test('Settings - Auth - Email', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
username: 'allaccess',
|
||||
password: 'nolimits',
|
||||
url: 'settings/user/'
|
||||
});
|
||||
|
||||
await loadTab(page, 'Security');
|
||||
|
||||
@@ -269,9 +274,8 @@ test('Settings - Auth - Email', async ({ page }) => {
|
||||
await page.getByRole('button', { name: 'Remove' }).click();
|
||||
|
||||
await page.getByText('Currently no email addresses are registered').waitFor();
|
||||
|
||||
await page.waitForTimeout(2500);
|
||||
});
|
||||
|
||||
async function testColorPicker(page, ref: string) {
|
||||
const element = page.getByLabel(ref);
|
||||
await element.click();
|
||||
|
Reference in New Issue
Block a user