test: replace false-green checks with behavioral coverage (#6282)
* test: replace false-green checks with behavioral coverage * test: complete behavior-focused audit coverage
This commit is contained in:
1 parent
c7ab7aa6da
commit
74942bd190
91 files changed
+1891
-1391
No files matched your search
@@ -809,8 +809,6 @@ describe("NanobotTui layout and themes", () => {
|
||||
const ui = app as unknown as {
|
||||
composer: TextareaRenderable
|
||||
status: TextRenderable
|
||||
shimmerFrame: number
|
||||
renderActiveStatus(): void
|
||||
}
|
||||
expect(ui.composer.textColor.intent).toBe("default")
|
||||
expect(ui.composer.backgroundColor.intent).toBe("default")
|
||||
@@ -832,8 +830,7 @@ describe("NanobotTui layout and themes", () => {
|
||||
.slice(0, "Thinking".length)
|
||||
.map((chunk) => chunk.attributes ?? 0)
|
||||
const firstFrame = terminalFrame()
|
||||
ui.shimmerFrame += 1
|
||||
ui.renderActiveStatus()
|
||||
await waitUntil(() => JSON.stringify(terminalFrame()) !== JSON.stringify(firstFrame), 2_000)
|
||||
const secondFrame = terminalFrame()
|
||||
expect(firstFrame).toContain(TextAttributes.BOLD)
|
||||
expect(secondFrame).not.toEqual(firstFrame)
|
||||
|
||||
@@ -189,11 +189,10 @@ describe("NanobotTui transcript", () => {
|
||||
setup.renderer.emit(CliRenderEvents.THEME_MODE, "dark")
|
||||
app.accept({ event: "attached", chat_id: "chat" })
|
||||
app.accept({ event: "reasoning_delta", chat_id: "chat", text: "hidden reasoning" })
|
||||
await Bun.sleep(130)
|
||||
await setup.renderOnce()
|
||||
await setup.flush()
|
||||
let frame = setup.captureCharFrame()
|
||||
|
||||
expect(frame).toMatch(/Thinking\s+0s/u)
|
||||
expect(frame).toMatch(/Thinking\s+\d+s/u)
|
||||
expect(frame).not.toMatch(/[◐◓◑◒⠋⠙⠹⠸]/u)
|
||||
expect(frame).not.toContain("hidden reasoning")
|
||||
const ui = app as unknown as {
|
||||
@@ -205,7 +204,12 @@ describe("NanobotTui transcript", () => {
|
||||
composerFrame: BoxRenderable
|
||||
}
|
||||
const status = ui.status
|
||||
expect(status.plainText).toMatch(/^Thinking\s+0s/u)
|
||||
const statusColors = () => status.content.chunks
|
||||
.slice(0, "Thinking".length)
|
||||
.map((chunk) => chunk.fg?.toInts().join(","))
|
||||
const firstFrame = JSON.stringify(statusColors())
|
||||
await waitUntil(() => JSON.stringify(statusColors()) !== firstFrame, 2_000)
|
||||
expect(status.plainText).toMatch(/^Thinking\s+\d+s/u)
|
||||
expect(ui.composer.placeholder).toBe("Enter send now Tab send next")
|
||||
expect(ui.composerFrame.height).toBe(3)
|
||||
const shimmerColors = new Set(
|
||||
@@ -223,11 +227,11 @@ describe("NanobotTui transcript", () => {
|
||||
kind: "tool_hint",
|
||||
tool_events: [{ phase: "start", name: "exec", arguments: { cmd: "pwd" } }],
|
||||
})
|
||||
await Bun.sleep(130)
|
||||
await setup.renderOnce()
|
||||
await waitUntil(() => /^Working\s+\d+s/u.test(status.plainText), 2_000)
|
||||
await setup.flush()
|
||||
frame = setup.captureCharFrame()
|
||||
|
||||
expect(frame).toMatch(/Working\s+0s/u)
|
||||
expect(frame).toMatch(/Working\s+\d+s/u)
|
||||
expect(frame).not.toMatch(/[◐◓◑◒⠋⠙⠹⠸]/u)
|
||||
expect(frame).toContain("› Running pwd")
|
||||
expect(occurrences(frame, "pwd")).toBe(1)
|
||||
@@ -235,6 +239,10 @@ describe("NanobotTui transcript", () => {
|
||||
app.accept({ event: "turn_end", chat_id: "chat" })
|
||||
await setup.flush()
|
||||
expect(ui.composer.placeholder).toBe("Ask nanobot anything")
|
||||
expect(status.plainText).toMatch(/^Ready/u)
|
||||
const stopped = status.content
|
||||
await Bun.sleep(200)
|
||||
expect(status.content).toBe(stopped)
|
||||
})
|
||||
|
||||
test("updates retry state in place and ends failed turns explicitly", async () => {
|
||||
|
||||
@@ -478,8 +478,21 @@ describe("gateway protocol", () => {
|
||||
client.close()
|
||||
})
|
||||
|
||||
test("represents lifecycle frames without browser state", () => {
|
||||
const events: InboundEvent[] = [
|
||||
test("delivers lifecycle frames with media metadata through the gateway socket", () => {
|
||||
const original = globalThis.WebSocket
|
||||
let socket: FakeSocket | undefined
|
||||
Object.defineProperty(globalThis, "WebSocket", {
|
||||
configurable: true,
|
||||
value: class extends FakeSocket {
|
||||
constructor() {
|
||||
super()
|
||||
socket = this
|
||||
}
|
||||
},
|
||||
})
|
||||
const frames: InboundEvent[] = [
|
||||
{ event: "ready", chat_id: "", client_id: "client" },
|
||||
{ event: "attached", chat_id: "one" },
|
||||
{
|
||||
event: "user_message",
|
||||
chat_id: "one",
|
||||
@@ -493,12 +506,26 @@ describe("gateway protocol", () => {
|
||||
{ event: "stream_end", chat_id: "one", resuming: false },
|
||||
{ event: "turn_end", chat_id: "one", latency_ms: 12 },
|
||||
]
|
||||
expect(events.map((event) => event.event)).toEqual([
|
||||
"user_message",
|
||||
"delta",
|
||||
"stream_end",
|
||||
"turn_end",
|
||||
])
|
||||
const delivered: InboundEvent[] = []
|
||||
const client = new NanobotClient({
|
||||
url: "ws://nanobot.test/ws",
|
||||
chatId: "one",
|
||||
onEvent: (event) => delivered.push(event),
|
||||
onStatus: () => undefined,
|
||||
})
|
||||
|
||||
try {
|
||||
client.connect()
|
||||
if (!socket) throw new Error("socket was not created")
|
||||
socket.emit("open")
|
||||
for (const frame of frames) {
|
||||
socket.emit("message", { data: JSON.stringify(frame) })
|
||||
}
|
||||
expect(delivered).toEqual(frames)
|
||||
} finally {
|
||||
client.close()
|
||||
Object.defineProperty(globalThis, "WebSocket", { configurable: true, value: original })
|
||||
}
|
||||
})
|
||||
|
||||
test("attaches and sends turns through the gateway envelope", () => {
|
||||
|
||||
Reference in new issue
Block a user