test(client): finish moving the tests to msw 3

Two more window.location stand-ins sat on http://localhost while the
page runs on http://localhost:3000; they now use locationAt like the
rest, which brings back the plugin settings answer FE-COMP-
PLUGINSETTINGS-020 waits for. FE-PAGE-JOURNEYDETAIL-153 ended while the
journal reload it set off was still out, which timed out after the
test; it now waits for that read. The reload mocks in
versionHandover.test.ts carry the signatures of location.replace and
location.reload, as locationAt's overrides require.
This commit is contained in:
Maurice
2026-11-26 14:03:46 +01:00
parent 3c1cf8b347
commit ed1bba9371
4 changed files with 17 additions and 7 deletions
+5 -5
View File
@@ -1,4 +1,4 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { afterEach, beforeEach, describe, expect, it, vi, type Mock } from 'vitest'
import { locationAt } from '../../tests/helpers/location'
/*
@@ -76,14 +76,14 @@ function breakStorage(method: 'getItem' | 'setItem', broken: () => Storage) {
const marker = () => localStorage.getItem('trek_app_version')
// The version the bundle under test is built as (vite define, from package.json).
const BUILT = __TREK_UI_VERSION__
let reload: ReturnType<typeof vi.fn>
let plainReload: ReturnType<typeof vi.fn>
let reload: Mock<Location['replace']>
let plainReload: Mock<Location['reload']>
beforeEach(() => {
// Every reload here asks for the page under a fresh URL (reloadFresh), which is
// a location.replace. `plainReload` is the location.reload() it must not use.
reload = vi.fn()
plainReload = vi.fn()
reload = vi.fn<Location['replace']>()
plainReload = vi.fn<Location['reload']>()
Object.defineProperty(window, 'location', {
writable: true,
value: locationAt('/dashboard', { replace: reload, reload: plainReload }),