test: stabilize parallel-sensitive CI specs

Relax verbose event assertions to target custom-event logs only and run compact lock-management specs serially to avoid global timer races in CI.
This commit is contained in:
YeonGyu-Kim 2026-02-21 03:40:23 +09:00
parent e21bbed3ab
commit 4aec627b33

View File

@ -113,7 +113,7 @@ describe("executeCompact lock management", () => {
fakeTimeouts.restore() fakeTimeouts.restore()
}) })
test("clears lock on successful summarize completion", async () => { test.serial("clears lock on successful summarize completion", async () => {
// given: Valid session with providerID/modelID // given: Valid session with providerID/modelID
autoCompactState.errorDataBySession.set(sessionID, { autoCompactState.errorDataBySession.set(sessionID, {
errorType: "token_limit", errorType: "token_limit",
@ -128,7 +128,7 @@ describe("executeCompact lock management", () => {
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false) expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false)
}) })
test("clears lock when summarize throws exception", async () => { test.serial("clears lock when summarize throws exception", async () => {
// given: Summarize will fail // given: Summarize will fail
mockClient.session.summarize = mock(() => mockClient.session.summarize = mock(() =>
Promise.reject(new Error("Network timeout")), Promise.reject(new Error("Network timeout")),
@ -146,7 +146,7 @@ describe("executeCompact lock management", () => {
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false) expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false)
}) })
test("shows toast when lock already held", async () => { test.serial("shows toast when lock already held", async () => {
// given: Lock already held // given: Lock already held
autoCompactState.compactionInProgress.add(sessionID) autoCompactState.compactionInProgress.add(sessionID)
@ -168,7 +168,7 @@ describe("executeCompact lock management", () => {
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(true) expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(true)
}) })
test("clears lock when fixEmptyMessages path executes", async () => { test.serial("clears lock when fixEmptyMessages path executes", async () => {
//#given - Empty content error scenario with no messages in storage //#given - Empty content error scenario with no messages in storage
const readMessagesSpy = spyOn(messagesReader, "readMessages").mockReturnValue([]) const readMessagesSpy = spyOn(messagesReader, "readMessages").mockReturnValue([])
autoCompactState.errorDataBySession.set(sessionID, { autoCompactState.errorDataBySession.set(sessionID, {
@ -186,7 +186,7 @@ describe("executeCompact lock management", () => {
readMessagesSpy.mockRestore() readMessagesSpy.mockRestore()
}) })
test("clears lock when truncation is sufficient", async () => { test.serial("clears lock when truncation is sufficient", async () => {
//#given - Aggressive truncation scenario with no messages in storage //#given - Aggressive truncation scenario with no messages in storage
const readMessagesSpy = spyOn(messagesReader, "readMessages").mockReturnValue([]) const readMessagesSpy = spyOn(messagesReader, "readMessages").mockReturnValue([])
autoCompactState.errorDataBySession.set(sessionID, { autoCompactState.errorDataBySession.set(sessionID, {
@ -215,7 +215,7 @@ describe("executeCompact lock management", () => {
readMessagesSpy.mockRestore() readMessagesSpy.mockRestore()
}) })
test("prevents concurrent compaction attempts", async () => { test.serial("prevents concurrent compaction attempts", async () => {
// given: Lock already held (simpler test) // given: Lock already held (simpler test)
autoCompactState.compactionInProgress.add(sessionID) autoCompactState.compactionInProgress.add(sessionID)
@ -233,7 +233,7 @@ describe("executeCompact lock management", () => {
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(true) expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(true)
}) })
test("clears lock after max recovery attempts exhausted", async () => { test.serial("clears lock after max recovery attempts exhausted", async () => {
// given: All retry/revert attempts exhausted // given: All retry/revert attempts exhausted
mockClient.session.messages = mock(() => Promise.resolve({ data: [] })) mockClient.session.messages = mock(() => Promise.resolve({ data: [] }))
@ -265,7 +265,7 @@ describe("executeCompact lock management", () => {
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false) expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false)
}) })
test("clears lock when client.tui.showToast throws", async () => { test.serial("clears lock when client.tui.showToast throws", async () => {
// given: Toast will fail (this should never happen but testing robustness) // given: Toast will fail (this should never happen but testing robustness)
mockClient.tui.showToast = mock(() => mockClient.tui.showToast = mock(() =>
Promise.reject(new Error("Toast failed")), Promise.reject(new Error("Toast failed")),
@ -283,7 +283,7 @@ describe("executeCompact lock management", () => {
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false) expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false)
}) })
test("clears lock when promptAsync in continuation throws", async () => { test.serial("clears lock when promptAsync in continuation throws", async () => {
// given: promptAsync will fail during continuation // given: promptAsync will fail during continuation
mockClient.session.promptAsync = mock(() => mockClient.session.promptAsync = mock(() =>
Promise.reject(new Error("Prompt failed")), Promise.reject(new Error("Prompt failed")),
@ -305,7 +305,7 @@ describe("executeCompact lock management", () => {
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false) expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false)
}) })
test("falls through to summarize when truncation is insufficient", async () => { test.serial("falls through to summarize when truncation is insufficient", async () => {
// given: Over token limit with truncation returning insufficient // given: Over token limit with truncation returning insufficient
autoCompactState.errorDataBySession.set(sessionID, { autoCompactState.errorDataBySession.set(sessionID, {
errorType: "token_limit", errorType: "token_limit",
@ -346,7 +346,7 @@ describe("executeCompact lock management", () => {
truncateSpy.mockRestore() truncateSpy.mockRestore()
}) })
test("does NOT call summarize when truncation is sufficient", async () => { test.serial("does NOT call summarize when truncation is sufficient", async () => {
// given: Over token limit with truncation returning sufficient // given: Over token limit with truncation returning sufficient
autoCompactState.errorDataBySession.set(sessionID, { autoCompactState.errorDataBySession.set(sessionID, {
errorType: "token_limit", errorType: "token_limit",