fix(test): add _resetForTesting for proper test isolation
This commit is contained in:
parent
ec2cf22449
commit
b4fa31a47a
@ -6,17 +6,16 @@ import {
|
|||||||
updateSessionAgent,
|
updateSessionAgent,
|
||||||
setMainSession,
|
setMainSession,
|
||||||
getMainSessionID,
|
getMainSessionID,
|
||||||
subagentSessions,
|
_resetForTesting,
|
||||||
} from "./state"
|
} from "./state"
|
||||||
|
|
||||||
describe("claude-code-session-state", () => {
|
describe("claude-code-session-state", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// #given - clean state before each test
|
// #given - clean state before each test
|
||||||
|
_resetForTesting()
|
||||||
clearSessionAgent("test-session-1")
|
clearSessionAgent("test-session-1")
|
||||||
clearSessionAgent("test-session-2")
|
clearSessionAgent("test-session-2")
|
||||||
clearSessionAgent("test-prometheus-session")
|
clearSessionAgent("test-prometheus-session")
|
||||||
setMainSession(undefined)
|
|
||||||
subagentSessions.clear()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("setSessionAgent", () => {
|
describe("setSessionAgent", () => {
|
||||||
@ -82,11 +81,6 @@ describe("claude-code-session-state", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("mainSessionID", () => {
|
describe("mainSessionID", () => {
|
||||||
beforeEach(() => {
|
|
||||||
// #given - ensure clean state for mainSessionID tests
|
|
||||||
setMainSession(undefined)
|
|
||||||
})
|
|
||||||
|
|
||||||
test("should store and retrieve main session ID", () => {
|
test("should store and retrieve main session ID", () => {
|
||||||
// #given
|
// #given
|
||||||
const mainID = "main-session-123"
|
const mainID = "main-session-123"
|
||||||
|
|||||||
@ -1,13 +1,19 @@
|
|||||||
export const subagentSessions = new Set<string>()
|
export const subagentSessions = new Set<string>()
|
||||||
|
|
||||||
export let mainSessionID: string | undefined
|
let _mainSessionID: string | undefined
|
||||||
|
|
||||||
export function setMainSession(id: string | undefined) {
|
export function setMainSession(id: string | undefined) {
|
||||||
mainSessionID = id
|
_mainSessionID = id
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMainSessionID(): string | undefined {
|
export function getMainSessionID(): string | undefined {
|
||||||
return mainSessionID
|
return _mainSessionID
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @internal For testing only */
|
||||||
|
export function _resetForTesting(): void {
|
||||||
|
_mainSessionID = undefined
|
||||||
|
subagentSessions.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionAgentMap = new Map<string, string>()
|
const sessionAgentMap = new Map<string, string>()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user