Skip to content

Commit 0334447

Browse files
committed
refactor(e2e): move about:blank cleanup from try/finally to test.afterEach
Move the WebSocket teardown workaround (page.goto('about:blank')) from per-test try/finally blocks into test.afterEach hooks. This is cleaner: the cleanup is declared once per describe block and applies to all tests that use the page fixture, without wrapping test bodies. Assisted-by: OpenCode
1 parent 5c9e678 commit 0334447

4 files changed

Lines changed: 30 additions & 31 deletions

File tree

e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ test.describe("Change app-config at e2e test runtime", () => {
2626
await ensureRuntimeDeployed();
2727
});
2828

29+
// Navigate away from RHDH to close WebSocket connections before
30+
// Playwright tears down the page — prevents a long hang during
31+
// context/trace cleanup.
32+
test.afterEach(async ({ page }) => {
33+
await page.goto("about:blank").catch(() => {});
34+
});
35+
2936
test("Verify title change after ConfigMap modification", async ({ page }) => {
3037
test.setTimeout(300000);
3138

@@ -60,11 +67,6 @@ test.describe("Change app-config at e2e test runtime", () => {
6067
} catch (error) {
6168
console.log(`Test failed during ConfigMap update or deployment restart:`, error);
6269
throw error;
63-
} finally {
64-
// Navigate away from RHDH to close WebSocket connections before
65-
// Playwright tears down the page — prevents a long hang during
66-
// context/trace cleanup.
67-
await page.goto("about:blank").catch(() => {});
6870
}
6971
});
7072
});

e2e-tests/playwright/e2e/external-database/verify-tls-config-with-external-azure-db.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ test.describe("Verify TLS configuration with Azure Database for PostgreSQL healt
8989
});
9090
});
9191

92+
test.afterEach(async ({ page }) => {
93+
await page.goto("about:blank").catch(() => {});
94+
});
95+
9296
test("Configure and restart deployment", async ({}, testInfo) => {
9397
if (!config.host) {
9498
testInfo.skip(true, `AZURE_DB_*_HOST not set for ${config.name}`);
@@ -105,14 +109,10 @@ test.describe("Verify TLS configuration with Azure Database for PostgreSQL healt
105109
});
106110

107111
test("Verify successful DB connection", async ({ page }) => {
108-
try {
109-
const uiHelper = new UIhelper(page);
110-
const common = new Common(page);
111-
await common.loginAsGuest();
112-
await uiHelper.verifyHeading("Welcome back!");
113-
} finally {
114-
await page.goto("about:blank").catch(() => {});
115-
}
112+
const uiHelper = new UIhelper(page);
113+
const common = new Common(page);
114+
await common.loginAsGuest();
115+
await uiHelper.verifyHeading("Welcome back!");
116116
});
117117
});
118118
}

e2e-tests/playwright/e2e/external-database/verify-tls-config-with-external-rds.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ test.describe("Verify TLS configuration with RDS PostgreSQL health check", () =>
8989
});
9090
});
9191

92+
test.afterEach(async ({ page }) => {
93+
await page.goto("about:blank").catch(() => {});
94+
});
95+
9296
test("Configure and restart deployment", async ({}, testInfo) => {
9397
if (!config.host) {
9498
testInfo.skip(true, `RDS_*_HOST not set for ${config.name}`);
@@ -105,14 +109,10 @@ test.describe("Verify TLS configuration with RDS PostgreSQL health check", () =>
105109
});
106110

107111
test("Verify successful DB connection", async ({ page }) => {
108-
try {
109-
const uiHelper = new UIhelper(page);
110-
const common = new Common(page);
111-
await common.loginAsGuest();
112-
await uiHelper.verifyHeading("Welcome back!");
113-
} finally {
114-
await page.goto("about:blank").catch(() => {});
115-
}
112+
const uiHelper = new UIhelper(page);
113+
const common = new Common(page);
114+
await common.loginAsGuest();
115+
await uiHelper.verifyHeading("Welcome back!");
116116
});
117117
});
118118
}

e2e-tests/playwright/e2e/plugin-division-mode-schema/verify-schema-mode.spec.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ test.describe("Verify pluginDivisionMode: schema", () => {
156156
await killPortForward(portForwardProcess);
157157
});
158158

159+
test.afterEach(async ({ page }) => {
160+
await page.goto("about:blank").catch(() => {});
161+
});
162+
159163
test("Verify database user has restricted permissions", async () => {
160164
const hasRestrictedPerms = await testSetup.verifyRestrictedDatabasePermissions();
161165
expect(hasRestrictedPerms).toBe(true);
@@ -181,17 +185,10 @@ test.describe("Verify pluginDivisionMode: schema", () => {
181185
}
182186

183187
const common = new Common(page);
184-
try {
185-
await common.loginAsGuest();
188+
await common.loginAsGuest();
186189

187-
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
190+
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
188191

189-
console.log("RHDH is accessible - plugins successfully created schemas in schema mode");
190-
} finally {
191-
// Navigate away from RHDH to close WebSocket connections before
192-
// Playwright tears down the page — prevents a long hang during
193-
// context/trace cleanup.
194-
await page.goto("about:blank").catch(() => {});
195-
}
192+
console.log("RHDH is accessible - plugins successfully created schemas in schema mode");
196193
});
197194
});

0 commit comments

Comments
 (0)