Skip to content

Commit 595c604

Browse files
test(web): the wizard import tests dispose their Date.now spy
CodeRabbit review on #22562. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent b55b277 commit 595c604

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎apps/web/src/components/onboarding/WelcomeWizard.import.browser.test.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ async function mountImport(remote = false) {
230230
}
231231

232232
// The mocked modules read `state`, so every test starts by replacing all of it.
233+
// Returns the clock spy so each test can `using` it; the spy would otherwise outlive the test.
233234
function setup() {
234-
vi.spyOn(Date, "now").mockReturnValue(NOW);
235+
const now = vi.spyOn(Date, "now").mockReturnValue(NOW);
235236
state.sessions.clear();
236237
for (const id of [primaryId, remoteId]) {
237238
state.sessions.set(
@@ -257,10 +258,11 @@ function setup() {
257258
state.onDone.mockReset();
258259
state.scan.mockReset();
259260
state.refreshScan.mockReset();
261+
return now;
260262
}
261263

262264
it("rechecks after project creation and can retry its history without recreating the project", async () => {
263-
setup();
265+
using _now = setup();
264266
const creation = deferred<void>();
265267
state.createProject.mockImplementationOnce(async (input: CreateProjectInput) => {
266268
await creation.promise;
@@ -287,7 +289,7 @@ it("rechecks after project creation and can retry its history without recreating
287289
});
288290

289291
it("completes accepted imports when permission is revoked after the final server write", async () => {
290-
setup();
292+
using _now = setup();
291293
state.candidates = state.candidates.slice(0, 1);
292294
const imported = deferred<{ importedCount: number; skippedCount: number }>();
293295
state.importThreads.mockImplementationOnce(async () =>

0 commit comments

Comments
 (0)