From 05bfd96e5522164192d52fb554c54e0ca644dc71 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Wed, 21 Jan 2026 17:53:40 +0100 Subject: [PATCH] fix(e2e): add polling for window.ng to prevent intermittent test failures The plugin-feature-check test was failing intermittently because window.ng might not be available immediately after Angular bootstrap. Added polling logic (5s timeout, 100ms intervals) to wait for window.ng to become available. --- .../plugins/plugin-feature-check.spec.ts | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/e2e/tests/plugins/plugin-feature-check.spec.ts b/e2e/tests/plugins/plugin-feature-check.spec.ts index b45b437aa..d472d79a5 100644 --- a/e2e/tests/plugins/plugin-feature-check.spec.ts +++ b/e2e/tests/plugins/plugin-feature-check.spec.ts @@ -5,9 +5,23 @@ test.describe.serial('Plugin Feature Check', () => { // Wait for work view to be ready await workViewPage.waitForTaskList(); - const result = await page.evaluate(() => { - // Check if Angular is loaded - const hasAngular = !!(window as any).ng; + const result = await page.evaluate(async () => { + // Poll for window.ng to become available (handles timing issues) + const pollForNg = async (): Promise => { + const maxAttempts = 50; // 5 seconds with 100ms intervals + const interval = 100; + + for (let i = 0; i < maxAttempts; i++) { + if ((window as any).ng) { + return true; + } + await new Promise((resolve) => setTimeout(resolve, interval)); + } + return false; + }; + + // Check if Angular is loaded (with polling to handle race conditions) + const hasAngular = await pollForNg(); // Check if PluginService is accessible through Angular's injector let hasPluginService = false;