Repository navigation
fix(ui): stop live counts from flooding screen readers #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b2da87c
fix(ui): stop live counts from flooding screen readers
erkamyaman 0f45431
fix(ui): report a missing connection on Clear and re-announce equal f…
erkamyaman 444dc41
Merge remote-tracking branch 'upstream/main' into components/cd-statu…
erkamyaman 30893f2
build(extension): rebuild the panel bundle
erkamyaman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import { TestBed, type ComponentFixture } from '@angular/core/testing'; | ||
| import type { DevframeRpcClient } from 'devframe/client'; | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
| import { CdRecording, type CdCycle, type CdPage } from '../pages/cd-recording'; | ||
|
|
||
| let fixture: ComponentFixture<CdRecording>; | ||
| let rpcCall: ReturnType<typeof vi.fn>; | ||
|
|
||
| function cycle(id: number): CdCycle { | ||
| return { id, at: 1000 + id, ms: 1, passes: 1, checks: 2, components: [] }; | ||
| } | ||
|
|
||
| function page(recording: boolean, count: number): CdPage { | ||
| return { | ||
| pageId: 'p1', | ||
| supported: true, | ||
| recording, | ||
| startedAt: recording ? 1000 : null, | ||
| dropped: 0, | ||
| cycles: Array.from({ length: count }, (_, i) => cycle(i + 1)), | ||
| components: [], | ||
| hosts: {}, | ||
| }; | ||
| } | ||
|
|
||
| const host = () => fixture.nativeElement as HTMLElement; | ||
| const live = () => host().querySelector('[role="status"]')!.textContent!; | ||
| const visible = () => host().querySelector('.status')!.textContent!.trim(); | ||
| const button = (text: string) => | ||
| [...host().querySelectorAll('button')].find((b) => b.textContent?.trim() === text)!; | ||
|
|
||
| async function show(recording: boolean, count: number) { | ||
| fixture.componentRef.setInput('page', page(recording, count)); | ||
| await fixture.whenStable(); | ||
| } | ||
|
|
||
| async function click(text: string) { | ||
| button(text).click(); | ||
| await fixture.whenStable(); | ||
| await new Promise((resolve) => setTimeout(resolve)); | ||
| await fixture.whenStable(); | ||
| } | ||
|
|
||
| describe('CdRecording status', () => { | ||
| beforeEach(async () => { | ||
| rpcCall = vi.fn(() => Promise.resolve({ ok: true })); | ||
| const client = { scope: () => ({ rpc: { call: rpcCall } }) }; | ||
| fixture = TestBed.createComponent(CdRecording); | ||
| fixture.componentRef.setInput('pageId', 'p1'); | ||
| fixture.componentRef.setInput('rpc', client as unknown as DevframeRpcClient); | ||
| await show(false, 0); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| fixture?.destroy(); | ||
| TestBed.resetTestingModule(); | ||
| }); | ||
|
|
||
| it('keeps the cycle count visible but out of the live region', async () => { | ||
| await show(true, 1); | ||
| const before = live(); | ||
| expect(visible()).toBe('Recording. 1 cycle so far.'); | ||
| expect(host().querySelector('.status')!.closest('[role="status"], [aria-live]')).toBeNull(); | ||
|
|
||
| await show(true, 2); | ||
| await show(true, 30); | ||
| expect(visible()).toBe('Recording. 30 cycles so far.'); | ||
| expect(live()).toBe(before); | ||
| }); | ||
|
|
||
| it('announces Record, Stop with the total, and Clear', async () => { | ||
| await click('Record'); | ||
| expect(rpcCall).toHaveBeenLastCalledWith('request-change-detection-record', { | ||
| pageId: 'p1', | ||
| on: true, | ||
| }); | ||
| expect(live()).toBe('Recording started.'); | ||
|
|
||
| await show(true, 3); | ||
| expect(live()).toBe('Recording started.'); | ||
|
|
||
| await click('Stop recording'); | ||
| expect(live()).toBe('Recording stopped. 3 cycles recorded.'); | ||
|
|
||
| await show(false, 3); | ||
| await click('Clear'); | ||
| expect(live()).toBe('Cleared the recorded cycles.'); | ||
| }); | ||
|
|
||
| it('announces a repeated message again', async () => { | ||
| await show(false, 2); | ||
| await click('Clear'); | ||
| const first = live(); | ||
| await click('Clear'); | ||
| expect(live()).not.toBe(first); | ||
| expect(live().trim()).toBe('Cleared the recorded cycles.'); | ||
| }); | ||
|
|
||
| it('announces when the page cannot be reached', async () => { | ||
| rpcCall.mockImplementation(() => Promise.reject(new Error('offline'))); | ||
| await click('Record'); | ||
| expect(live()).toBe('Could not reach the page.'); | ||
| expect(visible()).toBe('Could not reach the page.'); | ||
| }); | ||
|
|
||
| it('reports a failure, not success, when there is no connection to clear through', async () => { | ||
| fixture.componentRef.setInput('rpc', null); | ||
| await show(false, 3); | ||
| await click('Clear'); | ||
| expect(live()).toBe('Could not reach the page.'); | ||
| expect(live()).not.toContain('Cleared'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ts/browser-agent-rpc-BXhoSh1z-CQUbrXfP.js → ...ts/browser-agent-rpc-BXhoSh1z-rqSBv5Pm.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not announce success when no RPC request ran.
If cycles exist while
rpcis null, the user can click Clear.rpcCallthen resolves withnull, so this line announces “Cleared the recorded cycles.” although no request was sent. Treat the absent client as a failure before announcing completion.🤖 Prompt for AI Agents