feat(05-03): fix ReviewStep act() warnings with vi.useFakeTimers

- Add afterEach to vitest imports
- Add vi.useFakeTimers() at the start of beforeEach block
- Add afterEach(() => vi.useRealTimers()) to restore timers after each test
- Freezes OutputBlock's setTimeout(setCopied(false), 2000) during tests
This commit is contained in:
2026-03-30 09:43:14 +02:00
parent 9b6d8a8137
commit 913cbe836e
+6 -1
View File
@@ -5,7 +5,7 @@
// Covers SECU-02: privacy/no-server message in rendered output
// Covers TECH-01: scriptTargets filtering in ReviewStep
// Covers TECH-02: Back button navigation in ReviewStep
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render, screen, fireEvent, act } from '@testing-library/react';
import React, { useEffect } from 'react';
import ReviewStep from './ReviewStep';
@@ -17,6 +17,7 @@ vi.mock('../../utils/downloadFile', () => ({ downloadFile: vi.fn() }));
vi.mock('../../utils/downloadZip', () => ({ downloadZip: vi.fn().mockResolvedValue(undefined) }));
beforeEach(() => {
vi.useFakeTimers();
vi.clearAllMocks();
// Re-establish the resolved mock after clearAllMocks
vi.mocked(downloadZip).mockResolvedValue(undefined);
@@ -30,6 +31,10 @@ beforeEach(() => {
});
});
afterEach(() => {
vi.useRealTimers();
});
// Helper: render ReviewStep inside WizardProvider.
// The fully populated state must be injected by the implementation via
// a custom context initializer — for now the wrapper just provides the provider.