import { expect, test as base } from '@playwright/test'; import { readFile } from 'node:fs/promises'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const currentDir = path.dirname(fileURLToPath(import.meta.url)); export const webRoot = path.resolve(currentDir, '..', '..'); export const repoRoot = path.resolve(webRoot, '..'); export const artifactRoot = path.join( repoRoot, 'test-artifacts', 'user-migration-e2e', ); export const playwrightArtifactRoot = path.join(artifactRoot, 'playwright'); export const authDir = path.join(playwrightArtifactRoot, 'auth'); export const metadataPath = path.join(playwrightArtifactRoot, 'metadata.json'); export const readyMarkerPath = path.join( playwrightArtifactRoot, 'server-ready.json', ); export const serverLogPath = path.join(playwrightArtifactRoot, 'ui-server.log'); export const serverBinaryDir = path.join(playwrightArtifactRoot, 'bin'); export const serverBinaryPath = path.join( serverBinaryDir, process.platform === 'win32' ? 'user-migration-ui-server.exe' : 'user-migration-ui-server', ); export const rootStorageStatePath = path.join(authDir, 'root-storage.json'); export const userStorageStatePath = path.join(authDir, 'user-storage.json'); export const adminStorageStatePath = userStorageStatePath; export const clusterRunDir = path.join(artifactRoot, 'runs', 'playwright-ui'); export const cnBaseURL = 'http://127.0.0.1:3100'; export const ovBaseURL = 'http://127.0.0.1:3101'; export const rootUsername = 'root'; export const rootPassword = 'Password123!'; export const adminUsername = 'playwright-admin'; export const adminPassword = 'Password123!'; export type ClusterMetadata = { serverPid: number; serverBinaryPath: string; serverLogPath: string; runDir: string; baseURL: string; ovBaseURL: string; }; export async function readClusterMetadata(): Promise { const raw = await readFile(metadataPath, 'utf8'); return JSON.parse(raw) as ClusterMetadata; } export const test = base.extend<{ cluster: ClusterMetadata }>({ cluster: async ({}, use) => { await use(await readClusterMetadata()); }, }); export { expect };