|
| 1 | +/** |
| 2 | + * Custom Playwright test with RHDH fixtures. |
| 3 | + * Uses standard @playwright/test so timeout is not overridden by rhdh-e2e-test-utils (500s). |
| 4 | + */ |
| 5 | +import { test as base } from "@playwright/test"; |
| 6 | +import { RHDHDeployment } from "rhdh-e2e-test-utils/rhdh"; |
| 7 | +import { LoginHelper, UIhelper } from "rhdh-e2e-test-utils/helpers"; |
| 8 | +import { $ } from "rhdh-e2e-test-utils/utils"; |
| 9 | + |
| 10 | +const BEFORE_ALL_TIMEOUT_MS = 30 * 60 * 1000; // 30 min for orchestrator + RHDH deploy |
| 11 | + |
| 12 | +export const test = base.extend<{ |
| 13 | + rhdhDeploymentWorker: RHDHDeployment; |
| 14 | + rhdh: RHDHDeployment; |
| 15 | + uiHelper: UIhelper; |
| 16 | + loginHelper: LoginHelper; |
| 17 | + baseURL: string; |
| 18 | +}>({ |
| 19 | + rhdhDeploymentWorker: [ |
| 20 | + async ({}, use, workerInfo) => { |
| 21 | + const projectName = workerInfo.project.name; |
| 22 | + console.log( |
| 23 | + `Deploying rhdh for plugin ${projectName} in namespace ${projectName}`, |
| 24 | + ); |
| 25 | + const rhdhDeployment = new RHDHDeployment(projectName); |
| 26 | + |
| 27 | + try { |
| 28 | + base.setTimeout(BEFORE_ALL_TIMEOUT_MS); |
| 29 | + |
| 30 | + await rhdhDeployment.configure({ auth: "keycloak" }); |
| 31 | + |
| 32 | + const orchestratorNamespace = "orchestrator"; |
| 33 | + await $`bash tests/scripts/install-orchestrator.sh ${orchestratorNamespace}`; |
| 34 | + |
| 35 | + await rhdhDeployment.deploy({ timeoutMs: BEFORE_ALL_TIMEOUT_MS }); |
| 36 | + |
| 37 | + await use(rhdhDeployment); |
| 38 | + } finally { |
| 39 | + if (process.env.CI) { |
| 40 | + console.log(`Deleting namespace ${projectName}`); |
| 41 | + await rhdhDeployment.teardown(); |
| 42 | + } |
| 43 | + } |
| 44 | + }, |
| 45 | + { scope: "worker", auto: true }, |
| 46 | + ], |
| 47 | + |
| 48 | + rhdh: [ |
| 49 | + async ({ rhdhDeploymentWorker }, use) => { |
| 50 | + await use(rhdhDeploymentWorker); |
| 51 | + }, |
| 52 | + { scope: "test", auto: true }, |
| 53 | + ], |
| 54 | + |
| 55 | + uiHelper: [ |
| 56 | + async ({ page }, use) => { |
| 57 | + await use(new UIhelper(page)); |
| 58 | + }, |
| 59 | + { scope: "test" }, |
| 60 | + ], |
| 61 | + |
| 62 | + loginHelper: [ |
| 63 | + async ({ page }, use) => { |
| 64 | + await use(new LoginHelper(page)); |
| 65 | + }, |
| 66 | + { scope: "test" }, |
| 67 | + ], |
| 68 | + |
| 69 | + baseURL: [ |
| 70 | + async ({ rhdhDeploymentWorker }, use) => { |
| 71 | + await use(rhdhDeploymentWorker.rhdhUrl); |
| 72 | + }, |
| 73 | + { scope: "test" }, |
| 74 | + ], |
| 75 | +}); |
| 76 | + |
| 77 | +export { expect } from "@playwright/test"; |
| 78 | +export type { Page } from "@playwright/test"; |
0 commit comments