From 5b7cd7de31e0ce78e6f17d5c8ad9054b774c9759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Schultz=20Madsen?= Date: Fri, 28 Aug 2026 08:46:22 +0200 Subject: [PATCH] fix(playwright): register payroll-settings listener before the settings click The j/ and j1m/ dashboard-edit-a beforeEach hooks registered the page.waitForResponse() listener for the payroll-settings GET only after already awaiting the main settings GET. Since the settings component's ngOnInit fires both requests synchronously back-to-back, the payroll GET usually already completed by the time the listener was armed, leaving it unresolved for the full 120s test timeout (no per-action timeout is configured) and killing the browser mid-hook. Register both listeners before the click so neither response can complete unobserved. Fixes the consistent job/j and pn-playwright-test (j1m) failures in https://github.com/microting/eform-angular-timeplanning-plugin/actions/runs/33082638121 Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01WYHEYf7V1oJyPrLRLAWg6e --- .../time-planning-pn/j/dashboard-edit-a.spec.ts | 12 +++++++++--- .../time-planning-pn/j1m/dashboard-edit-a.spec.ts | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/eform-client/playwright/e2e/plugins/time-planning-pn/j/dashboard-edit-a.spec.ts b/eform-client/playwright/e2e/plugins/time-planning-pn/j/dashboard-edit-a.spec.ts index 5419ad479..e21504546 100644 --- a/eform-client/playwright/e2e/plugins/time-planning-pn/j/dashboard-edit-a.spec.ts +++ b/eform-client/playwright/e2e/plugins/time-planning-pn/j/dashboard-edit-a.spec.ts @@ -23,13 +23,19 @@ test.describe('Dashboard edit values', () => { const settingsGetPromise = page.waitForResponse( r => r.url().includes('/api/time-planning-pn/settings') && r.request().method() === 'GET' ); + // Registered before the click alongside settingsGetPromise: getSettings() and + // getPayrollSettings() both fire synchronously from ngOnInit, so listening for + // this response only after settingsGetPromise resolves is too late — the + // payroll request has often already completed, leaving this promise unresolved + // until the 120s test timeout (no default action timeout is configured). + const payrollSettingsGetPromise = page.waitForResponse( + r => r.url().includes('/api/time-planning-pn/payroll/settings') && r.request().method() === 'GET' + ); await page.locator('#plugin-settings-link0').click(); await settingsGetPromise; // Wait for payroll settings to finish loading (async call that causes re-render) - await page.waitForResponse( - r => r.url().includes('/api/time-planning-pn/payroll/settings') && r.request().method() === 'GET' - ).catch(() => {}); + await payrollSettingsGetPromise; await page.waitForTimeout(500); // Check autoBreakCalculationActiveToggle state and enable if needed diff --git a/eform-client/playwright/e2e/plugins/time-planning-pn/j1m/dashboard-edit-a.spec.ts b/eform-client/playwright/e2e/plugins/time-planning-pn/j1m/dashboard-edit-a.spec.ts index 345229140..0689c1830 100644 --- a/eform-client/playwright/e2e/plugins/time-planning-pn/j1m/dashboard-edit-a.spec.ts +++ b/eform-client/playwright/e2e/plugins/time-planning-pn/j1m/dashboard-edit-a.spec.ts @@ -56,13 +56,19 @@ test.describe('Dashboard edit values (j1m, flag-on, global values round-trip)', const settingsGetPromise = page.waitForResponse( r => r.url().includes('/api/time-planning-pn/settings') && r.request().method() === 'GET' ); + // Registered before the click alongside settingsGetPromise: getSettings() and + // getPayrollSettings() both fire synchronously from ngOnInit, so listening for + // this response only after settingsGetPromise resolves is too late — the + // payroll request has often already completed, leaving this promise unresolved + // until the 120s test timeout (no default action timeout is configured). + const payrollSettingsGetPromise = page.waitForResponse( + r => r.url().includes('/api/time-planning-pn/payroll/settings') && r.request().method() === 'GET' + ); await page.locator('#plugin-settings-link0').click(); await settingsGetPromise; // Wait for payroll settings to finish loading (async call that causes re-render) - await page.waitForResponse( - r => r.url().includes('/api/time-planning-pn/payroll/settings') && r.request().method() === 'GET' - ).catch(() => {}); + await payrollSettingsGetPromise; await page.waitForTimeout(500); // Check autoBreakCalculationActiveToggle state and enable if needed