fix(cli-run): strip ANSI codes in think block test assertions for CI compatibility
This commit is contained in:
parent
2f659e9b97
commit
c21e0b094f
@ -3,6 +3,10 @@ import type { EventPayload, RunContext } from "./types"
|
|||||||
import { createEventState } from "./events"
|
import { createEventState } from "./events"
|
||||||
import { processEvents } from "./event-stream-processor"
|
import { processEvents } from "./event-stream-processor"
|
||||||
|
|
||||||
|
function stripAnsi(str: string): string {
|
||||||
|
return str.replace(new RegExp("\x1b\\[[0-9;]*m", "g"), "")
|
||||||
|
}
|
||||||
|
|
||||||
const createMockContext = (sessionID: string = "test-session"): RunContext => ({
|
const createMockContext = (sessionID: string = "test-session"): RunContext => ({
|
||||||
client: {} as RunContext["client"],
|
client: {} as RunContext["client"],
|
||||||
sessionID,
|
sessionID,
|
||||||
@ -164,8 +168,10 @@ describe("message.part.delta handling", () => {
|
|||||||
|
|
||||||
//#then
|
//#then
|
||||||
const rendered = stdoutSpy.mock.calls.map((call) => String(call[0] ?? "")).join("")
|
const rendered = stdoutSpy.mock.calls.map((call) => String(call[0] ?? "")).join("")
|
||||||
expect(rendered).toContain("┃ Thinking: Composing final summary in Korean")
|
const plain = stripAnsi(rendered)
|
||||||
expect(rendered).toContain("answer")
|
expect(plain).toContain("Thinking:")
|
||||||
|
expect(plain).toContain("Composing final summary in Korean")
|
||||||
|
expect(plain).toContain("answer")
|
||||||
stdoutSpy.mockRestore()
|
stdoutSpy.mockRestore()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -215,8 +221,10 @@ describe("message.part.delta handling", () => {
|
|||||||
|
|
||||||
//#then
|
//#then
|
||||||
const rendered = stdoutSpy.mock.calls.map((call) => String(call[0] ?? "")).join("")
|
const rendered = stdoutSpy.mock.calls.map((call) => String(call[0] ?? "")).join("")
|
||||||
expect(rendered).toContain("┃ Thinking: Composing final summary")
|
const plain = stripAnsi(rendered)
|
||||||
expect(rendered).toContain("in Korean with specifics.")
|
expect(plain).toContain("Thinking:")
|
||||||
|
expect(plain).toContain("Composing final summary")
|
||||||
|
expect(plain).toContain("in Korean with specifics.")
|
||||||
|
|
||||||
if (previous !== undefined) process.env.GITHUB_ACTIONS = previous
|
if (previous !== undefined) process.env.GITHUB_ACTIONS = previous
|
||||||
stdoutSpy.mockRestore()
|
stdoutSpy.mockRestore()
|
||||||
@ -280,7 +288,8 @@ describe("message.part.delta handling", () => {
|
|||||||
|
|
||||||
//#then
|
//#then
|
||||||
const rendered = stdoutSpy.mock.calls.map((call) => String(call[0] ?? "")).join("")
|
const rendered = stdoutSpy.mock.calls.map((call) => String(call[0] ?? "")).join("")
|
||||||
const renderCount = rendered.split("Thinking:").length - 1
|
const plain = stripAnsi(rendered)
|
||||||
|
const renderCount = plain.split("Thinking:").length - 1
|
||||||
expect(renderCount).toBe(1)
|
expect(renderCount).toBe(1)
|
||||||
|
|
||||||
if (previous !== undefined) process.env.GITHUB_ACTIONS = previous
|
if (previous !== undefined) process.env.GITHUB_ACTIONS = previous
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user