test(coding-agent): reset history storage between test runs

- Reset the HistoryStorage singleton instance in the afterEach hooks of multiple issue reproduction tests.
This commit is contained in:
can1357
2026-07-01 00:52:50 +02:00
parent bdb33a184d
commit c7fa7f5285
4 changed files with 8 additions and 0 deletions
@@ -7,6 +7,7 @@ import { InteractiveMode } from "@oh-my-pi/pi-coding-agent/modes/interactive-mod
import { initTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session";
import { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage";
import { HistoryStorage } from "@oh-my-pi/pi-coding-agent/session/history-storage";
import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager";
import { TempDir } from "@oh-my-pi/pi-utils";
@@ -56,6 +57,7 @@ describe("issue #2510 — /plan toggles plan → plan_paused → none", () => {
afterEach(async () => {
vi.restoreAllMocks();
mode?.stop();
HistoryStorage.resetInstance();
await session?.dispose();
authStorage?.close();
tempDir?.removeSync();
@@ -11,6 +11,7 @@ import { initTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import type { AgentSessionEvent } from "@oh-my-pi/pi-coding-agent/session/agent-session";
import { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session";
import { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage";
import { HistoryStorage } from "@oh-my-pi/pi-coding-agent/session/history-storage";
import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager";
import { TempDir } from "@oh-my-pi/pi-utils";
@@ -89,6 +90,7 @@ describe("issue #3656 /shake mid-stream preserves the in-flight assistant turn",
afterEach(async () => {
mode?.stop();
HistoryStorage.resetInstance();
vi.restoreAllMocks();
await session?.dispose();
authStorage?.close();
@@ -7,6 +7,7 @@ import { InteractiveMode } from "@oh-my-pi/pi-coding-agent/modes/interactive-mod
import { initTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session";
import { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage";
import { HistoryStorage } from "@oh-my-pi/pi-coding-agent/session/history-storage";
import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager";
import { TempDir } from "@oh-my-pi/pi-utils";
@@ -49,6 +50,7 @@ describe("issue #816 — plan mode pendingModelSwitch leak", () => {
afterEach(async () => {
vi.restoreAllMocks();
mode?.stop();
HistoryStorage.resetInstance();
await session?.dispose();
authStorage?.close();
tempDir?.removeSync();
@@ -8,6 +8,7 @@ import { InteractiveMode } from "@oh-my-pi/pi-coding-agent/modes/interactive-mod
import { initTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session";
import { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage";
import { HistoryStorage } from "@oh-my-pi/pi-coding-agent/session/history-storage";
import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager";
import { TempDir } from "@oh-my-pi/pi-utils";
@@ -52,6 +53,7 @@ describe("issue #927 optimistic pending spinner", () => {
afterEach(async () => {
mode?.stop();
HistoryStorage.resetInstance();
vi.restoreAllMocks();
await session?.dispose();
authStorage?.close();