From 494125a9b31c0db73ca4ae8ecaab5a7cdeacb681 Mon Sep 17 00:00:00 2001 From: KCM Date: Sun, 26 Apr 2026 12:46:47 -0500 Subject: [PATCH] fix(playwright): stabilize lint diagnostics waits with one-time rerun fallback. --- playwright/diagnostics.spec.ts | 18 ++++++++++++++--- playwright/helpers/app-test-helpers.ts | 28 ++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/playwright/diagnostics.spec.ts b/playwright/diagnostics.spec.ts index 5d23cb5..f8ec32c 100644 --- a/playwright/diagnostics.spec.ts +++ b/playwright/diagnostics.spec.ts @@ -338,7 +338,11 @@ test('component lint reports missing button type prop', async ({ page }) => { await runComponentLint(page) - await waitForLintDiagnosticsIssues(page) + await waitForLintDiagnosticsIssues(page, { + rerunLint: async () => { + await runComponentLint(page) + }, + }) await expect(page.getByText(/a11y\/useButtonType/)).toBeVisible() }) @@ -353,7 +357,11 @@ test('styles diagnostics rows navigate editor to reported line', async ({ page } await runStylesLint(page) - await waitForLintDiagnosticsIssues(page) + await waitForLintDiagnosticsIssues(page, { + rerunLint: async () => { + await runStylesLint(page) + }, + }) const targetDiagnostic = page.getByRole('button', { name: /^L3(:\d+)?\s/ }).first() await expect(targetDiagnostic).toBeVisible() @@ -371,7 +379,11 @@ test('styles lint reports CSS syntax errors', async ({ page }) => { await runStylesLint(page) - await waitForLintDiagnosticsIssues(page) + await waitForLintDiagnosticsIssues(page, { + rerunLint: async () => { + await runStylesLint(page) + }, + }) await expect(page.locator('#diagnostics-styles')).toContainText( 'Biome reported issues.', ) diff --git a/playwright/helpers/app-test-helpers.ts b/playwright/helpers/app-test-helpers.ts index d01ddd0..f4e8c3e 100644 --- a/playwright/helpers/app-test-helpers.ts +++ b/playwright/helpers/app-test-helpers.ts @@ -263,12 +263,32 @@ export const runStylesLint = async (page: Page) => { await page.getByRole('button', { name: 'Styles lint' }).click() } -export const waitForLintDiagnosticsIssues = async (page: Page) => { +export const waitForLintDiagnosticsIssues = async ( + page: Page, + { + rerunLint, + }: { + rerunLint?: () => Promise + } = {}, +) => { const diagnosticsToggle = page.getByRole('button', { name: /^Diagnostics/ }) - await expect(diagnosticsToggle).toHaveAttribute('aria-busy', 'false') - await expect(diagnosticsToggle).toHaveClass(/diagnostics-toggle--error/) - await expect(page.getByText(/Rendered \(Lint issues: [1-9]\d*\)/)).toBeVisible() + const expectLintIssuesVisible = async () => { + await expect(diagnosticsToggle).toHaveAttribute('aria-busy', 'false') + await expect(diagnosticsToggle).toHaveClass(/diagnostics-toggle--error/) + await expect(page.getByText(/Rendered \(Lint issues: [1-9]\d*\)/)).toBeVisible() + } + + try { + await expectLintIssuesVisible() + } catch (error) { + if (typeof rerunLint !== 'function') { + throw error + } + + await rerunLint() + await expectLintIssuesVisible() + } await ensureDiagnosticsDrawerOpen(page) await expect(page.locator('#diagnostics-styles')).toContainText(