From 30565145cd8f6d424ef943b4ea347696b50d347b Mon Sep 17 00:00:00 2001 From: Timothy Date: Wed, 15 Jul 2026 22:36:16 +0200 Subject: [PATCH] test(web): harden primary-action ownership regressions Refs #247 Co-Authored-By: OpenAI Codex --- web/src/primaryAction.test.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/src/primaryAction.test.tsx b/web/src/primaryAction.test.tsx index b6de3aa0a..a40be4a41 100644 --- a/web/src/primaryAction.test.tsx +++ b/web/src/primaryAction.test.tsx @@ -72,7 +72,7 @@ describe('primary actions', () => { expect(latestHandler).toHaveBeenCalledOnce(); }); - it('cleans up the old route and clears the registration on unmount', () => { + it("moves the same owner's registration to a new route and clears it on unmount", () => { const handler = vi.fn(); const view = render( @@ -105,7 +105,7 @@ describe('primary actions', () => { expect(screen.getByRole('button', { name: 'Run channels' })).toBeDisabled(); }); - it('does not let an older owner clear a newer registration', () => { + it('does not let an older owner rerender or cleanup reclaim a newer registration', () => { const olderHandler = vi.fn(); const updatedOlderHandler = vi.fn(); const newerHandler = vi.fn(); @@ -130,6 +130,9 @@ describe('primary actions', () => { ); + fireEvent.click(screen.getByRole('button', { name: 'Run schedules' })); + expect(newerHandler).toHaveBeenCalledOnce(); + view.rerender( @@ -140,7 +143,7 @@ describe('primary actions', () => { expect(olderHandler).not.toHaveBeenCalled(); expect(updatedOlderHandler).not.toHaveBeenCalled(); - expect(newerHandler).toHaveBeenCalledOnce(); + expect(newerHandler).toHaveBeenCalledTimes(2); }); it('lets screens render harmlessly without a provider', () => {