From 40c86d66d20b763e80b2623414a25d288eb01b6a Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Tue, 5 May 2026 06:50:21 +0000 Subject: [PATCH] fix(e2e): add waitForSidebar helper and networkidle waits for reliability Add waitForSidebar helper function with explicit sidebar visibility wait and networkidle state to ensure page is fully loaded before assertions. This addresses flaky E2E tests where elements were not consistently found due to timing issues during page transitions. --- e2e/argocd.spec.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/e2e/argocd.spec.ts b/e2e/argocd.spec.ts index 7e547f2..0182b37 100644 --- a/e2e/argocd.spec.ts +++ b/e2e/argocd.spec.ts @@ -1,30 +1,37 @@ import { test, expect } from '@playwright/test'; +async function waitForSidebar(page: import('@playwright/test').Page) { + const sidebar = page.getByRole('navigation', { name: 'Navigation' }); + await expect(sidebar).toBeVisible({ timeout: 15_000 }); + await page.waitForLoadState('networkidle'); + return sidebar; +} + test.describe('ArgoCD plugin smoke tests', () => { test('sidebar contains ArgoCD entry', async ({ page }) => { await page.goto('/'); - const sidebar = page.getByRole('navigation', { name: 'Navigation' }); - await expect(sidebar).toBeVisible({ timeout: 15_000 }); + const sidebar = await waitForSidebar(page); await expect(sidebar.getByRole('button', { name: /argocd/i })).toBeVisible(); }); test('ArgoCD sidebar entry navigates to applications list', async ({ page }) => { await page.goto('/'); - const sidebar = page.getByRole('navigation', { name: 'Navigation' }); - await expect(sidebar).toBeVisible({ timeout: 15_000 }); + const sidebar = await waitForSidebar(page); const argocdEntry = sidebar.getByRole('button', { name: /argocd/i }); await expect(argocdEntry).toBeVisible(); await argocdEntry.click(); - await expect(page).toHaveURL(/\/argocd/); - await expect(page.getByRole('heading', { name: /argo.*cd|applications/i })).toBeVisible(); + await page.waitForLoadState('networkidle'); + await expect(page).toHaveURL(/argocd/); + await expect(page.getByRole('heading', { name: /argo.*cd.*applications/i })).toBeVisible(); }); test('applications list page renders', async ({ page }) => { await page.goto('/c/main/argocd'); + await waitForSidebar(page); - await expect(page.getByRole('heading', { name: /argo.*cd|applications/i })).toBeVisible({ + await expect(page.getByRole('heading', { name: /argo.*cd.*applications/i })).toBeVisible({ timeout: 15_000, }); @@ -35,6 +42,7 @@ test.describe('ArgoCD plugin smoke tests', () => { test('plugin settings page shows argocd plugin entry', async ({ page }) => { await page.goto('/settings/plugins'); + await page.waitForLoadState('networkidle'); const pluginEntry = page.locator('text=/argocd|argo.*cd/i').first(); await expect(pluginEntry).toBeVisible({ timeout: 30_000 }); -- 2.52.0