diff --git a/apps/editor/e2e/code-editor.spec.ts b/apps/editor/e2e/code-editor.spec.ts index 09a0b619..9a422870 100644 --- a/apps/editor/e2e/code-editor.spec.ts +++ b/apps/editor/e2e/code-editor.spec.ts @@ -63,6 +63,11 @@ test('asks before closing a tab with unsaved changes from the keyboard', async ( const tab = page.getByRole('tab', { name: /close\.ts/ }); await typeAtEnd(page, '\nexport const unsaved = 1;'); await expect(tab.getByLabel('Unsaved changes')).toBeVisible(); + /** One Tab stop per tablist: Delete closes the tab, so its Close button is out of the order. */ + await expect(tab.getByRole('button', { name: 'Close close.ts' })).toHaveAttribute( + 'tabindex', + '-1', + ); await page.keyboard.press('Alt+w'); const dialog = page.getByRole('dialog', { name: 'Save changes to close.ts?' }); diff --git a/apps/editor/e2e/console.spec.ts b/apps/editor/e2e/console.spec.ts index 59c6af7f..23740629 100644 --- a/apps/editor/e2e/console.spec.ts +++ b/apps/editor/e2e/console.spec.ts @@ -119,20 +119,30 @@ test('problems: a file that is not open, grouped by file, opens at its position' 'true', ); - const file = page - .getByRole('list', { name: 'Problems' }) - .getByRole('listitem', { name: 'scratch/broken.ts' }); - const problem = file.getByRole('button', { name: /is not assignable to type 'number'/ }); + /** A tree: files at level 1 fold, their problems are the level 2 items. */ + const tree = page.getByRole('tree', { name: 'Problems' }); + const file = tree.getByRole('treeitem', { name: /scratch\/broken\.ts/, level: 1 }); + const problem = tree.getByRole('treeitem', { + name: /is not assignable to type 'number'/, + level: 2, + }); await expect(problem).toContainText('typescript 2322'); await expect(problem).toContainText('2:14'); - await expect(file.getByRole('button', { name: /scratch\/broken\.ts/ })).toContainText('1 error'); + await expect(file).toContainText('1 error'); + await expect(file).toHaveAttribute('aria-expanded', 'true'); - await file.getByRole('button', { name: /scratch\/broken\.ts/ }).click(); + await file.click(); + await expect(file).toHaveAttribute('aria-expanded', 'false'); await expect(problem).toHaveCount(0); - await file.getByRole('button', { name: /scratch\/broken\.ts/ }).click(); + await file.click(); + await file.press('Space'); + await expect(file).toHaveAttribute('aria-expanded', 'false'); + await file.press('Space'); + await expect(file).toHaveAttribute('aria-expanded', 'true'); await page.getByLabel('Search problems').fill("assignable to type 'number'"); - await expect(page.getByRole('list', { name: 'Problems' }).getByRole('listitem')).toHaveCount(1); + await expect(tree.getByRole('treeitem', { level: 1 })).toHaveCount(1); + await expect(tree.getByRole('treeitem', { level: 2 })).toHaveCount(1); await page .getByRole('group', { name: 'Severities' }) .getByRole('button', { name: 'Errors' }) @@ -145,13 +155,12 @@ test('problems: a file that is not open, grouped by file, opens at its position' await page.getByLabel('Search problems').fill(''); /** One Tab stop: arrows go through files and problems, Enter opens one. */ - const header = file.getByRole('button', { name: /scratch\/broken\.ts/ }); - await header.focus(); + await file.focus(); await page.keyboard.press('ArrowRight'); await expect(problem).toBeFocused(); - await expect(header).toHaveAttribute('tabindex', '-1'); + await expect(file).toHaveAttribute('tabindex', '-1'); await page.keyboard.press('ArrowLeft'); - await expect(header).toBeFocused(); + await expect(file).toBeFocused(); await page.keyboard.press('ArrowLeft'); await expect(problem).toHaveCount(0); await page.keyboard.press('ArrowRight'); @@ -181,12 +190,13 @@ test.describe('with the engine', () => { await open(page, 'game'); await showPanel(page, 'Problems'); writeFileSync(MAIN, `${original}const = ;\n`); - const file = page - .getByRole('list', { name: 'Problems' }) - .getByRole('listitem', { name: 'apps/client/src/main.ts' }); - const build = file.getByRole('button').filter({ hasText: /\bbuild\b/ }); + const tree = page.getByRole('tree', { name: 'Problems' }); + const build = tree.getByRole('treeitem', { level: 2 }).filter({ hasText: /\bbuild\b/ }); await expect(build.first()).toBeVisible({ timeout: 30_000 }); - await expect(build.first()).toContainText(new RegExp(`${errorLine}:\\d+$`)); + await expect( + tree.getByRole('treeitem', { name: /apps\/client\/src\/main\.ts/, level: 1 }), + ).toBeVisible(); + await expect(build.filter({ hasText: new RegExp(`${errorLine}:\\d+$`) })).not.toHaveCount(0); await showPanel(page, 'Console'); await expect( log(page) diff --git a/apps/editor/e2e/ecs.spec.ts b/apps/editor/e2e/ecs.spec.ts index d200c94d..fc14b053 100644 --- a/apps/editor/e2e/ecs.spec.ts +++ b/apps/editor/e2e/ecs.spec.ts @@ -359,12 +359,16 @@ test('a layout warning of a component shows in Problems, at its declaration', as position.replace('constructor(x: number', 'constructor(/** @preset vector.x */ x: number'), ), ); + const problems = page.getByRole('tree', { name: 'Problems' }); + const warning = problems.getByRole('treeitem', { + name: /Position: The preset "vector" needs/, + level: 2, + }); try { await showPanel(page, 'Problems'); - const file = page - .getByRole('list', { name: 'Problems' }) - .getByRole('listitem', { name: 'apps/client/src/components/components.ts' }); - const warning = file.getByRole('button', { name: /Position: The preset "vector" needs/ }); + await expect(problems.getByRole('treeitem', { name: /components\.ts/, level: 1 })).toBeVisible({ + timeout: 15_000, + }); await expect(warning).toBeVisible({ timeout: 15_000 }); await warning.click(); await expect(page.locator('.monaco-editor .active-line-number')).toHaveText( @@ -373,9 +377,7 @@ test('a layout warning of a component shows in Problems, at its declaration', as } finally { writeFileSync(COMPONENTS, before); } - await expect( - page.getByRole('button', { name: /Position: The preset "vector" needs/ }), - ).toHaveCount(0, { timeout: 15_000 }); + await expect(warning).toHaveCount(0, { timeout: 15_000 }); }); test('runs an action another plugin adds to entities', async ({ page }) => { diff --git a/apps/editor/e2e/history-panel.spec.ts b/apps/editor/e2e/history-panel.spec.ts index b1bfa580..b130c0f7 100644 --- a/apps/editor/e2e/history-panel.spec.ts +++ b/apps/editor/e2e/history-panel.spec.ts @@ -37,6 +37,11 @@ test('follows the focused history, jumps to steps, searches and clears', async ( await expect.poll(() => existsSync(join(PONG, 'history/format copy copy.ts'))).toBe(false); expect(existsSync(join(PONG, 'history/format copy.ts'))).toBe(true); await expect(steps.first()).toHaveAttribute('aria-current', 'step'); + /** The faint time color is below 4.5:1 on the selection: the current time takes the row's. */ + const color = (element: Element) => getComputedStyle(element).color; + expect(await steps.first().locator('time').evaluate(color)).toBe( + await steps.first().evaluate(color), + ); await steps.last().click(); await expect.poll(() => existsSync(join(PONG, 'history/format copy copy copy.ts'))).toBe(true); diff --git a/apps/editor/e2e/marketplace.spec.ts b/apps/editor/e2e/marketplace.spec.ts index 48b89cd5..81a63eab 100644 --- a/apps/editor/e2e/marketplace.spec.ts +++ b/apps/editor/e2e/marketplace.spec.ts @@ -134,7 +134,7 @@ test('installs a plugin from the marketplace, updates it and uninstalls it', asy test('installs a package with its dependency, updates it and uninstalls it', async ({ page }) => { await open(page); let dialog = await openPackages(page); - const details = dialog.getByLabel('Package details'); + const details = dialog.getByRole('region', { name: 'Package details' }); const results = dialog.getByRole('list', { name: 'Registry packages' }); await dialog.getByRole('textbox', { name: 'Search packages' }).fill('shape components'); await expect(results.getByRole('button')).toHaveCount(1); diff --git a/apps/editor/e2e/viewport.spec.ts b/apps/editor/e2e/viewport.spec.ts index 9adc54c4..4424ee13 100644 --- a/apps/editor/e2e/viewport.spec.ts +++ b/apps/editor/e2e/viewport.spec.ts @@ -68,7 +68,8 @@ test.describe('while playing', () => { await screenTab(page, 'Game').click(); await view(page, 'Stats').click(); await play(page); - await page.getByRole('button', { name: 'Resolution' }).click(); + /** Label in name: a voice user says what the button shows. */ + await page.getByRole('button', { name: 'Resolution: Fit' }).click(); await page.getByRole('menuitem', { name: /1280 × 720/ }).click(); const frame = page.getByRole('application', { name: 'Running game' }); await expect.poll(async () => (await frame.boundingBox())?.width).toBe(1280); diff --git a/plugins/console/src/widgets/problems/ProblemsView.svelte b/plugins/console/src/widgets/problems/ProblemsView.svelte index 0992c29d..56442c06 100644 --- a/plugins/console/src/widgets/problems/ProblemsView.svelte +++ b/plugins/console/src/widgets/problems/ProblemsView.svelte @@ -136,25 +136,28 @@ - -
{ - const row = (event.target as HTMLElement).closest('[data-row]')?.dataset.row; - if (row) active = row; - }} - > - {#each groups as group (group.key)} - {@const open_ = !collapsed.includes(group.key)} -
+ {#if groups.length} + +
{ + const row = (event.target as HTMLElement).closest('[data-row]')?.dataset.row; + if (row) active = row; + }} + > + {#each groups as group (group.key)} + {@const open_ = !collapsed.includes(group.key)} +
- {:else} + {/each} +
+ {:else} +
- {/each} -
+ + {/if}