mirror of
https://github.com/inventree/InvenTree.git
synced 2026-04-01 00:51:06 +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:
3
src/frontend/playwright/.gitignore
vendored
Normal file
3
src/frontend/playwright/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Ignore auth cache
|
||||
auth/
|
||||
*.json
|
||||
45
src/frontend/playwright/global-setup.ts
Normal file
45
src/frontend/playwright/global-setup.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { type FullConfig, chromium } from '@playwright/test';
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { doCachedLogin } from '../tests/login';
|
||||
|
||||
async function globalSetup(config: FullConfig) {
|
||||
const authDir = path.resolve('./playwright/auth');
|
||||
|
||||
if (fs.existsSync(authDir)) {
|
||||
// Clear out the cached authentication states
|
||||
fs.rm(path.resolve('./playwright/auth'), { recursive: true }, (err) => {
|
||||
if (err) {
|
||||
console.error('Failed to clear out cached authentication states:', err);
|
||||
} else {
|
||||
console.log('Removed cached authentication states');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Perform login for each user
|
||||
const browser = await chromium.launch();
|
||||
|
||||
await doCachedLogin(browser, {
|
||||
username: 'admin',
|
||||
password: 'inventree'
|
||||
});
|
||||
|
||||
await doCachedLogin(browser, {
|
||||
username: 'allaccess',
|
||||
password: 'nolimits'
|
||||
});
|
||||
|
||||
await doCachedLogin(browser, {
|
||||
username: 'reader',
|
||||
password: 'readonly'
|
||||
});
|
||||
|
||||
await doCachedLogin(browser, {
|
||||
username: 'steven',
|
||||
password: 'wizardstaff'
|
||||
});
|
||||
}
|
||||
|
||||
export default globalSetup;
|
||||
Reference in New Issue
Block a user