From 98debe15f1c66ec68f01733405e209ca4c58a9db Mon Sep 17 00:00:00 2001 From: lucaronin Date: Wed, 25 Mar 2026 23:34:52 +0100 Subject: [PATCH] =?UTF-8?q?test:=20fix=20act()=20warnings=20in=20useVaultS?= =?UTF-8?q?witcher=20=E2=80=94=20settle=20async=20effect=20(option=20D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'starts with default vaults' test was synchronous but the hook fires an async useEffect on mount, causing React act() warnings when the state update resolved after unmount. Now awaits the loaded state to let the effect settle before the test completes. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/hooks/useVaultSwitcher.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hooks/useVaultSwitcher.test.ts b/src/hooks/useVaultSwitcher.test.ts index 95c5f58c..ea5174dc 100644 --- a/src/hooks/useVaultSwitcher.test.ts +++ b/src/hooks/useVaultSwitcher.test.ts @@ -47,10 +47,11 @@ describe('useVaultSwitcher', () => { }) }) - it('starts with default vaults', () => { + it('starts with default vaults', async () => { const { result } = renderHook(() => useVaultSwitcher({ onSwitch, onToast })) expect(result.current.allVaults).toEqual(DEFAULT_VAULTS) expect(result.current.vaultPath).toBe(DEFAULT_VAULTS[0].path) + await waitFor(() => { expect(result.current.loaded).toBe(true) }) }) it('loads persisted vaults on mount', async () => {