From b64e1264dcdab6c413c63c6a5b2a56766b8b49f6 Mon Sep 17 00:00:00 2001 From: sudacode Date: Tue, 11 Aug 2026 00:16:46 -0700 Subject: [PATCH] test(stats): click backdrop, not disabled button, in cleanup close test - Assert the Close button is disabled while apply is in flight - Click the always-enabled backdrop instead, since that's the path that actually reaches the close guard --- .../vocabulary/DuplicateLineCleanup.test.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/stats/src/components/vocabulary/DuplicateLineCleanup.test.tsx b/stats/src/components/vocabulary/DuplicateLineCleanup.test.tsx index fc0f28ff..4d49166e 100644 --- a/stats/src/components/vocabulary/DuplicateLineCleanup.test.tsx +++ b/stats/src/components/vocabulary/DuplicateLineCleanup.test.tsx @@ -51,6 +51,13 @@ function findButton(container: Element, label: string): HTMLButtonElement { return match as unknown as HTMLButtonElement; } +/** The backdrop stays clickable during an apply, so it reaches the guard in `close`. */ +function findBackdrop(container: Element): HTMLButtonElement { + const match = container.querySelector('button[aria-label="Close duplicate line cleanup"]'); + assert.ok(match, 'expected the backdrop close button'); + return match as unknown as HTMLButtonElement; +} + function deferred(): { promise: Promise; resolve: (value: T) => void } { let resolve!: (value: T) => void; const promise = new Promise((done) => { @@ -181,8 +188,10 @@ test('closing is refused while an apply is in flight', async () => { findButton(harness.container, 'Clean Up').click(); }); + assert.equal(findButton(harness.container, 'Close').disabled, true); + // The backdrop is never disabled, so this is the path that has to be refused. await act(async () => { - findButton(harness.container, 'Close').click(); + findBackdrop(harness.container).click(); }); assert.equal(harness.closedCalls(), 0, 'the modal must stay open mid-apply'); assert.equal(harness.cleanedCalls(), 0);