Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/editor/e2e/code-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?' });
Expand Down
44 changes: 27 additions & 17 deletions apps/editor/e2e/console.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
Expand All @@ -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');
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 9 additions & 7 deletions apps/editor/e2e/ecs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 }) => {
Expand Down
5 changes: 5 additions & 0 deletions apps/editor/e2e/history-panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion apps/editor/e2e/marketplace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion apps/editor/e2e/viewport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
48 changes: 28 additions & 20 deletions plugins/console/src/widgets/problems/ProblemsView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,28 @@
</div>
<Input bind:value={query} placeholder="Search problems" aria-label="Search problems" />
</div>
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<div
class="list"
role="list"
aria-label="Problems"
aria-keyshortcuts="ArrowUp ArrowDown ArrowLeft ArrowRight Home End"
bind:this={list}
{onkeydown}
onfocusin={(event) => {
const row = (event.target as HTMLElement).closest<HTMLElement>('[data-row]')?.dataset.row;
if (row) active = row;
}}
>
{#each groups as group (group.key)}
{@const open_ = !collapsed.includes(group.key)}
<section role="listitem" aria-label={group.label}>
{#if groups.length}
<!-- svelte-ignore a11y_interactive_supports_focus (focus is on the rows: one roving tab stop) -->
<div
class="list"
role="tree"
aria-label="Problems"
aria-keyshortcuts="ArrowUp ArrowDown ArrowLeft ArrowRight Home End"
bind:this={list}
{onkeydown}
onfocusin={(event) => {
const row = (event.target as HTMLElement).closest<HTMLElement>('[data-row]')?.dataset.row;
if (row) active = row;
}}
>
{#each groups as group (group.key)}
{@const open_ = !collapsed.includes(group.key)}
<!-- svelte-ignore a11y_role_has_required_aria_props (ARIA 1.2 needs no aria-selected: nothing is selected here) -->
<button
type="button"
class="file"
role="treeitem"
aria-level={1}
aria-expanded={open_}
data-row={groupRow(group.key)}
tabindex={current === groupRow(group.key) ? 0 : -1}
Expand All @@ -166,9 +169,12 @@
</button>
{#if open_}
{#each group.problems as problem, index (index)}
<!-- svelte-ignore a11y_role_has_required_aria_props (as above) -->
<button
type="button"
class="problem {problem.severity}"
role="treeitem"
aria-level={2}
aria-disabled={!problem.path}
data-row={problemRow(group.key, index)}
tabindex={current === problemRow(group.key, index) ? 0 : -1}
Expand All @@ -182,17 +188,19 @@
</button>
{/each}
{/if}
</section>
{:else}
{/each}
</div>
{:else}
<div class="list">
<EmptyState
icon="circle-check"
title={total ? 'No problems match the filters' : 'No problems'}
description={total
? 'Show more severities or change the search.'
: 'Errors and warnings of the project appear here.'}
/>
{/each}
</div>
</div>
{/if}
</div>

<style>
Expand Down
Loading