Skip to content

Commit 7620854

Browse files
test: wait for lint diagnostics helper.
1 parent 6fbbdef commit 7620854

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

playwright/diagnostics.spec.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
runTypecheck,
1212
setComponentEditorSource,
1313
setStylesEditorSource,
14+
waitForLintDiagnosticsIssues,
1415
waitForInitialRender,
1516
} from './helpers/app-test-helpers.js'
1617

@@ -337,9 +338,7 @@ test('component lint reports missing button type prop', async ({ page }) => {
337338

338339
await runComponentLint(page)
339340

340-
await expect(page.getByText(/Rendered \(Lint issues: [1-9]\d*\)/)).toBeVisible()
341-
await ensureDiagnosticsDrawerOpen(page)
342-
await expect(page.getByText('Biome reported issues.')).toBeVisible()
341+
await waitForLintDiagnosticsIssues(page)
343342
await expect(page.getByText(/a11y\/useButtonType/)).toBeVisible()
344343
})
345344

@@ -354,10 +353,7 @@ test('styles diagnostics rows navigate editor to reported line', async ({ page }
354353

355354
await runStylesLint(page)
356355

357-
await expect(page.getByRole('button', { name: /^Diagnostics/ })).toHaveClass(
358-
/diagnostics-toggle--error/,
359-
)
360-
await ensureDiagnosticsDrawerOpen(page)
356+
await waitForLintDiagnosticsIssues(page)
361357

362358
const targetDiagnostic = page.getByRole('button', { name: /^L3(:\d+)?\s/ }).first()
363359
await expect(targetDiagnostic).toBeVisible()
@@ -375,9 +371,10 @@ test('styles lint reports CSS syntax errors', async ({ page }) => {
375371

376372
await runStylesLint(page)
377373

378-
await expect(page.getByText(/Rendered \(Lint issues: [1-9]\d*\)/)).toBeVisible()
379-
await ensureDiagnosticsDrawerOpen(page)
380-
await expect(page.getByText('Biome reported issues.')).toBeVisible()
374+
await waitForLintDiagnosticsIssues(page)
375+
await expect(page.locator('#diagnostics-styles')).toContainText(
376+
'Biome reported issues.',
377+
)
381378
})
382379

383380
test('sass compiler warnings surface in styles diagnostics', async ({ page }) => {

playwright/helpers/app-test-helpers.ts

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

266+
export const waitForLintDiagnosticsIssues = async (page: Page) => {
267+
const diagnosticsToggle = page.getByRole('button', { name: /^Diagnostics/ })
268+
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()
272+
273+
await ensureDiagnosticsDrawerOpen(page)
274+
await expect(page.locator('#diagnostics-styles')).toContainText(
275+
'Biome reported issues.',
276+
)
277+
}
278+
266279
export const getActiveStylesEditorLineNumber = async (page: Page) => {
267280
return page
268281
.locator('#editor-panel-styles .cm-activeLineGutter')

0 commit comments

Comments
 (0)