From 3e3a57cccafc957fc3304c4fbbb9a091b02333aa Mon Sep 17 00:00:00 2001 From: Ingwannu Date: Sat, 26 Sep 2026 22:59:56 +0000 Subject: [PATCH] test(gui): avoid duplicate provider hash events --- gui/tests/providers-deep-link.test.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gui/tests/providers-deep-link.test.tsx b/gui/tests/providers-deep-link.test.tsx index 9ee1a6d924b..feac8f80133 100644 --- a/gui/tests/providers-deep-link.test.tsx +++ b/gui/tests/providers-deep-link.test.tsx @@ -59,8 +59,15 @@ async function mount(names: string[] | null, onAccounts?: (name: string, choose: async function hash(next: string) { await act(async () => { + const previous = testWindow.location.hash; testWindow.location.hash = next; - testWindow.dispatchEvent(new testWindow.HashChangeEvent("hashchange")); + // A changed location emits its own hashchange in browsers and Happy DOM. Dispatching + // another one raced that native task and occasionally applied one navigation twice. + // Only an unchanged hash needs the explicit re-application event used by production. + if (testWindow.location.hash === previous) { + testWindow.dispatchEvent(new testWindow.HashChangeEvent("hashchange")); + } + await new Promise(resolve => setTimeout(resolve, 0)); }); }