edbfe2848c
- ensure not loading twice the same variables, namespace to ensure it in the future - end to end tests where successfull, need to check it is not reusing a previous release (in cache from build CI) - fix: #377 #378
71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
/** Parse a KEY=VALUE env file, skipping blank lines and comments. */
|
|
function loadEnv(filePath: string): Record<string, string> {
|
|
const env: Record<string, string> = {};
|
|
for (const line of fs.readFileSync(filePath, 'utf-8').split('\n')) {
|
|
const trimmed = line.trim();
|
|
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
const idx = trimmed.indexOf('=');
|
|
if (idx === -1) continue;
|
|
env[trimmed.slice(0, idx)] = trimmed.slice(idx + 1);
|
|
}
|
|
return env;
|
|
}
|
|
|
|
const commonEnv = loadEnv(path.join(__dirname, '../common/server.env'));
|
|
|
|
console.log(`starting playwright with env BUILD_TARGET=${process.env.BUILD_TARGET ?? "debug"}`);
|
|
|
|
const workspace=process.env.GITHUB_WORKSPACE ?? path.join(__dirname, '../..');
|
|
|
|
export default defineConfig({
|
|
testDir: './scenarios',
|
|
fullyParallel: true,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 2 : 0,
|
|
workers: process.env.CI ? 1 : undefined,
|
|
reporter: process.env.CI ? [['github'], ['html']] : 'html',
|
|
|
|
globalSetup: require.resolve('./global-setup'),
|
|
|
|
use: {
|
|
baseURL: 'http://localhost:8087',
|
|
trace: 'on-first-retry',
|
|
},
|
|
|
|
expect: {
|
|
toHaveScreenshot: { maxDiffPixelRatio: 0.02 },
|
|
},
|
|
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
{
|
|
name: 'firefox',
|
|
use: { ...devices['Desktop Firefox'] },
|
|
},
|
|
],
|
|
|
|
webServer: {
|
|
command: process.env.BUILD_TARGET
|
|
? `${workspace}/target/${process.env.BUILD_TARGET}/oxicloud`
|
|
: 'cargo run',
|
|
url: 'http://localhost:8087',
|
|
timeout: 600_000,
|
|
reuseExistingServer: false,
|
|
cwd: '../..',
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
env: {
|
|
...commonEnv,
|
|
OXICLOUD_SERVER_PORT: '8087',
|
|
OXICLOUD_STORAGE_PATH: './tests/e2e/storage',
|
|
},
|
|
},
|
|
});
|