mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 03:26:45 +00:00
Revert some playwright changes (#9419)
* Revert some playwright changes - Use vite dev server all the time * Simplify test
This commit is contained in:
parent
f7a4469590
commit
fcc6709b3f
7
.github/workflows/qc_checks.yaml
vendored
7
.github/workflows/qc_checks.yaml
vendored
@ -584,6 +584,7 @@ jobs:
|
|||||||
INVENTREE_DB_PASSWORD: inventree_password
|
INVENTREE_DB_PASSWORD: inventree_password
|
||||||
INVENTREE_DEBUG: true
|
INVENTREE_DEBUG: true
|
||||||
INVENTREE_PLUGINS_ENABLED: false
|
INVENTREE_PLUGINS_ENABLED: false
|
||||||
|
VITE_COVERAGE_BUILD: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2
|
||||||
@ -605,12 +606,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
invoke int.frontend-compile
|
invoke int.frontend-compile
|
||||||
cd src/frontend && npx playwright install --with-deps
|
cd src/frontend && npx playwright install --with-deps
|
||||||
- name: Set Production Mode
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
run: echo "VITE_PRODUCTION_BUILD=true" >> $GITHUB_ENV
|
|
||||||
- name: Set Coverage Mode
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
run: echo "VITE_COVERAGE_BUILD=true" >> $GITHUB_ENV
|
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
id: tests
|
id: tests
|
||||||
run: cd src/frontend && npx nyc playwright test
|
run: cd src/frontend && npx nyc playwright test
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
import { defineConfig, devices } from '@playwright/test';
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
import type TestConfigWebServer from '@playwright/test';
|
|
||||||
|
|
||||||
// Detect if running in CI
|
// Detect if running in CI
|
||||||
const IS_CI = !!process.env.CI;
|
const IS_CI = !!process.env.CI;
|
||||||
const IS_COVERAGE = !!process.env.VITE_COVERAGE_BUILD;
|
|
||||||
|
|
||||||
// If specified, tests will be run against the production build
|
|
||||||
const IS_PRODUCTION = !!process.env.VITE_PRODUCTION_BUILD;
|
|
||||||
|
|
||||||
console.log('Running Playwright tests:');
|
console.log('Running Playwright tests:');
|
||||||
console.log(` - CI Mode: ${IS_CI}`);
|
console.log(` - CI Mode: ${IS_CI}`);
|
||||||
console.log(` - Coverage Mode: ${IS_COVERAGE}`);
|
|
||||||
console.log(` - Production Mode: ${IS_PRODUCTION}`);
|
|
||||||
|
|
||||||
const MAX_WORKERS: number = 3;
|
const MAX_WORKERS: number = 3;
|
||||||
const MAX_RETRIES: number = 3;
|
const MAX_RETRIES: number = 3;
|
||||||
@ -37,59 +30,19 @@ const MAX_RETRIES: number = 3;
|
|||||||
* - WORKERS = 1 (to avoid conflicts with HMR)
|
* - WORKERS = 1 (to avoid conflicts with HMR)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const devServer: TestConfigWebServer = {
|
|
||||||
command: 'yarn run dev --host --port 5173',
|
|
||||||
url: 'http://localhost:5173',
|
|
||||||
reuseExistingServer: IS_CI,
|
|
||||||
stdout: 'pipe',
|
|
||||||
stderr: 'pipe',
|
|
||||||
timeout: 120 * 1000
|
|
||||||
};
|
|
||||||
|
|
||||||
const WEB_BUILD_CMD: string =
|
|
||||||
'yarn run extract && yarn run compile && yarn run build';
|
|
||||||
|
|
||||||
// Command to spin-up the backend server
|
// Command to spin-up the backend server
|
||||||
// In production mode, we want a stronger webserver to handle multiple requests
|
// In production mode, we want a stronger webserver to handle multiple requests
|
||||||
const WEB_SERVER_CMD: string = IS_PRODUCTION
|
const WEB_SERVER_CMD: string = IS_CI
|
||||||
? `${WEB_BUILD_CMD} && gunicorn --chdir ../backend/InvenTree --workers 8 --thread 8 --bind 127.0.0.1:8000 InvenTree.wsgi`
|
? 'gunicorn --chdir ../backend/InvenTree --workers 8 --thread 8 --bind 127.0.0.1:8000 InvenTree.wsgi'
|
||||||
: 'invoke dev.server -a 127.0.0.1:8000';
|
: 'invoke dev.server -a 127.0.0.1:8000';
|
||||||
|
|
||||||
const webServer: TestConfigWebServer = {
|
|
||||||
// If running in production mode, we need to build the frontend first
|
|
||||||
command: WEB_SERVER_CMD,
|
|
||||||
env: {
|
|
||||||
INVENTREE_DEBUG: 'True',
|
|
||||||
INVENTREE_PLUGINS_ENABLED: 'True',
|
|
||||||
INVENTREE_ADMIN_URL: 'test-admin',
|
|
||||||
INVENTREE_SITE_URL: 'http://localhost:8000',
|
|
||||||
INVENTREE_FRONTEND_API_HOST: 'http://localhost:8000',
|
|
||||||
INVENTREE_CORS_ORIGIN_ALLOW_ALL: 'True',
|
|
||||||
INVENTREE_COOKIE_SAMESITE: 'Lax',
|
|
||||||
INVENTREE_LOGIN_ATTEMPTS: '100'
|
|
||||||
},
|
|
||||||
url: 'http://localhost:8000/api/',
|
|
||||||
reuseExistingServer: IS_CI,
|
|
||||||
stdout: 'pipe',
|
|
||||||
stderr: 'pipe',
|
|
||||||
timeout: 120 * 1000
|
|
||||||
};
|
|
||||||
|
|
||||||
const serverList: TestConfigWebServer[] = [];
|
|
||||||
|
|
||||||
if (!IS_PRODUCTION) {
|
|
||||||
serverList.push(devServer);
|
|
||||||
}
|
|
||||||
|
|
||||||
serverList.push(webServer);
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
testDir: './tests',
|
testDir: './tests',
|
||||||
fullyParallel: false,
|
fullyParallel: false,
|
||||||
timeout: 90000,
|
timeout: 90000,
|
||||||
forbidOnly: !!IS_CI,
|
forbidOnly: !!IS_CI,
|
||||||
retries: IS_CI ? MAX_RETRIES : 0,
|
retries: IS_CI ? MAX_RETRIES : 0,
|
||||||
workers: IS_PRODUCTION ? MAX_WORKERS : 1,
|
workers: IS_CI ? MAX_WORKERS : 1,
|
||||||
reporter: IS_CI ? [['html', { open: 'never' }], ['github']] : 'list',
|
reporter: IS_CI ? [['html', { open: 'never' }], ['github']] : 'list',
|
||||||
|
|
||||||
/* Configure projects for major browsers */
|
/* Configure projects for major browsers */
|
||||||
@ -109,11 +62,38 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
|
|
||||||
/* Run your local dev server before starting the tests */
|
/* Run your local dev server before starting the tests */
|
||||||
webServer: serverList,
|
webServer: [
|
||||||
|
{
|
||||||
|
command: 'yarn run dev --host --port 5173',
|
||||||
|
url: 'http://localhost:5173',
|
||||||
|
reuseExistingServer: IS_CI,
|
||||||
|
stdout: 'pipe',
|
||||||
|
stderr: 'pipe',
|
||||||
|
timeout: 120 * 1000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
command: WEB_SERVER_CMD,
|
||||||
|
env: {
|
||||||
|
INVENTREE_DEBUG: 'True',
|
||||||
|
INVENTREE_PLUGINS_ENABLED: 'True',
|
||||||
|
INVENTREE_ADMIN_URL: 'test-admin',
|
||||||
|
INVENTREE_SITE_URL: 'http://localhost:8000',
|
||||||
|
INVENTREE_FRONTEND_API_HOST: 'http://localhost:8000',
|
||||||
|
INVENTREE_CORS_ORIGIN_ALLOW_ALL: 'True',
|
||||||
|
INVENTREE_COOKIE_SAMESITE: 'Lax',
|
||||||
|
INVENTREE_LOGIN_ATTEMPTS: '100'
|
||||||
|
},
|
||||||
|
url: 'http://localhost:8000/api/',
|
||||||
|
reuseExistingServer: IS_CI,
|
||||||
|
stdout: 'pipe',
|
||||||
|
stderr: 'pipe',
|
||||||
|
timeout: 120 * 1000
|
||||||
|
}
|
||||||
|
],
|
||||||
globalSetup: './playwright/global-setup.ts',
|
globalSetup: './playwright/global-setup.ts',
|
||||||
use: {
|
use: {
|
||||||
baseURL: IS_PRODUCTION ? 'http://localhost:8000' : 'http://localhost:5173',
|
baseURL: 'http://localhost:5173',
|
||||||
headless: IS_PRODUCTION ? true : undefined,
|
headless: IS_CI ? true : undefined,
|
||||||
trace: 'on-first-retry'
|
trace: 'on-first-retry'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user