test(date-comparison): wait for the dialog's initial focus before the retry focus check
CI / policy (pull_request) Successful in 20s
CI / validate (pull_request) Successful in 34s
CI / build (pull_request) Successful in 23s
CI / benchmark (pull_request) Successful in 1m30s
CI / security (pull_request) Successful in 1m0s
CI / test (pull_request) Successful in 2m53s
CI / images (pull_request) Successful in 1m14s
CI / required (pull_request) Successful in 1s
CI / policy (push) Successful in 8s
CI / build (push) Successful in 35s
CI / validate (push) Successful in 42s
CI / benchmark (push) Successful in 1m42s
CI / security (push) Successful in 1m38s
CI / test (push) Successful in 3m25s
CI / images (push) Successful in 1m15s
CI / required (push) Successful in 1s

The retry test recorded document.activeElement right after clicking Retry
and expected the arriving result not to move focus. MatDialog defaults to
delayFocusTrap, so autoFocus 'first-heading' moves focus to the title only
after the 150 ms opening animation timer and the next render. The test
usually finished just before that timer fired, so it compared body with
body. Under load the timer fired while job(2) was being polled, and the
final detectChanges ran the pending afterNextRender. Focus then moved from
body to #counterfactual-title and the assertion failed, even though the
result had not moved focus.

Wait for the title to receive focus, as the first test does, before taking
the snapshot. The assertion now checks that the result leaves the dialog's
settled focus on the title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #361.
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-11-14 16:07:24 +01:00
1 parent 556fa3fe37
commit 57521cc28b
1 file changed
+4
@@ -447,6 +447,10 @@ describe('DateComparison', () => {
fixture.detectChanges(); fixture.detectChanges();
expect(document.querySelector('.comparison-loading')).not.toBeNull(); expect(document.querySelector('.comparison-loading')).not.toBeNull();
expect(comparison.failed()).toBe(false); expect(comparison.failed()).toBe(false);
// The dialog focuses its title only after its opening animation; let that settle first.
await vi.waitFor(() =>
expect(document.activeElement).toBe(document.getElementById('counterfactual-title')),
);
const focusedBeforeResult = document.activeElement; const focusedBeforeResult = document.activeElement;
(await job(2)).emit({ (await job(2)).emit({
type: 'counterfactual-result', type: 'counterfactual-result',