Skip to content

Commit 92310ee

Browse files
fix(playwright): stabilize lint diagnostics waits with one-time rerun fallback. (#101)
1 parent eb5a1cd commit 92310ee

2 files changed

Lines changed: 39 additions & 7 deletions

File tree

playwright/diagnostics.spec.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,11 @@ test('component lint reports missing button type prop', async ({ page }) => {
338338

339339
await runComponentLint(page)
340340

341-
await waitForLintDiagnosticsIssues(page)
341+
await waitForLintDiagnosticsIssues(page, {
342+
rerunLint: async () => {
343+
await runComponentLint(page)
344+
},
345+
})
342346
await expect(page.getByText(/a11y\/useButtonType/)).toBeVisible()
343347
})
344348

@@ -353,7 +357,11 @@ test('styles diagnostics rows navigate editor to reported line', async ({ page }
353357

354358
await runStylesLint(page)
355359

356-
await waitForLintDiagnosticsIssues(page)
360+
await waitForLintDiagnosticsIssues(page, {
361+
rerunLint: async () => {
362+
await runStylesLint(page)
363+
},
364+
})
357365

358366
const targetDiagnostic = page.getByRole('button', { name: /^L3(:\d+)?\s/ }).first()
359367
await expect(targetDiagnostic).toBeVisible()
@@ -371,7 +379,11 @@ test('styles lint reports CSS syntax errors', async ({ page }) => {
371379

372380
await runStylesLint(page)
373381

374-
await waitForLintDiagnosticsIssues(page)
382+
await waitForLintDiagnosticsIssues(page, {
383+
rerunLint: async () => {
384+
await runStylesLint(page)
385+
},
386+
})
375387
await expect(page.locator('#diagnostics-styles')).toContainText(
376388
'Biome reported issues.',
377389
)

playwright/helpers/app-test-helpers.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,32 @@ export const runStylesLint = async (page: Page) => {
263263
await page.getByRole('button', { name: 'Styles lint' }).click()
264264
}
265265

266-
export const waitForLintDiagnosticsIssues = async (page: Page) => {
266+
export const waitForLintDiagnosticsIssues = async (
267+
page: Page,
268+
{
269+
rerunLint,
270+
}: {
271+
rerunLint?: () => Promise<void>
272+
} = {},
273+
) => {
267274
const diagnosticsToggle = page.getByRole('button', { name: /^Diagnostics/ })
268275

269-
await expect(diagnosticsToggle).toHaveAttribute('aria-busy', 'false')
270-
await expect(diagnosticsToggle).toHaveClass(/diagnostics-toggle--error/)
271-
await expect(page.getByText(/Rendered \(Lint issues: [1-9]\d*\)/)).toBeVisible()
276+
const expectLintIssuesVisible = async () => {
277+
await expect(diagnosticsToggle).toHaveAttribute('aria-busy', 'false')
278+
await expect(diagnosticsToggle).toHaveClass(/diagnostics-toggle--error/)
279+
await expect(page.getByText(/Rendered \(Lint issues: [1-9]\d*\)/)).toBeVisible()
280+
}
281+
282+
try {
283+
await expectLintIssuesVisible()
284+
} catch (error) {
285+
if (typeof rerunLint !== 'function') {
286+
throw error
287+
}
288+
289+
await rerunLint()
290+
await expectLintIssuesVisible()
291+
}
272292

273293
await ensureDiagnosticsDrawerOpen(page)
274294
await expect(page.locator('#diagnostics-styles')).toContainText(

0 commit comments

Comments
 (0)