Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { stabilizeStreamingMarkdownTail } from "./streamingMarkdownTailStabilizer";
|
|
|
|
describe("stabilizeStreamingMarkdownTail", () => {
|
|
it("leaves completed or non-streaming markdown unchanged", () => {
|
|
const content = "Done\n\n```ts\nconst value = 1;\n```";
|
|
|
|
expect(
|
|
stabilizeStreamingMarkdownTail(content, { streaming: false })
|
|
).toEqual({
|
|
content,
|
|
changed: false
|
|
});
|
|
});
|
|
|
|
it("temporarily closes an open fenced code block", () => {
|
|
const result = stabilizeStreamingMarkdownTail(
|
|
"Before\n```ts\nconst value = 1;",
|
|
{
|
|
streaming: true
|
|
}
|
|
);
|
|
|
|
expect(result.changed).toBe(true);
|
|
expect(result.reason).toBe("open-fence");
|
|
expect(result.content).toBe("Before\n```ts\nconst value = 1;\n```");
|
|
});
|
|
|
|
it("temporarily closes an open inline code span", () => {
|
|
const result = stabilizeStreamingMarkdownTail("Run `pnpm test", {
|
|
streaming: true
|
|
});
|
|
|
|
expect(result).toEqual({
|
|
content: "Run `pnpm test`",
|
|
changed: true,
|
|
reason: "open-inline-code"
|
|
});
|
|
});
|
|
|
|
it("renders an incomplete tail link as its label text", () => {
|
|
const result = stabilizeStreamingMarkdownTail("Read [README](./READ", {
|
|
streaming: true
|
|
});
|
|
|
|
expect(result).toEqual({
|
|
content: "Read README",
|
|
changed: true,
|
|
reason: "incomplete-link-target"
|
|
});
|
|
});
|
|
|
|
it("suppresses a dangling list marker at the active tail", () => {
|
|
const result = stabilizeStreamingMarkdownTail("Items\n-", {
|
|
streaming: true
|
|
});
|
|
|
|
expect(result).toEqual({
|
|
content: "Items\n",
|
|
changed: true,
|
|
reason: "dangling-list-marker"
|
|
});
|
|
});
|
|
|
|
it("soft-closes a partial table row when a table is already underway", () => {
|
|
const result = stabilizeStreamingMarkdownTail(
|
|
"| File | Status |\n| --- | --- |\n| app.ts | pass",
|
|
{ streaming: true }
|
|
);
|
|
|
|
expect(result).toEqual({
|
|
content: "| File | Status |\n| --- | --- |\n| app.ts | pass |",
|
|
changed: true,
|
|
reason: "partial-table-row"
|
|
});
|
|
});
|
|
});
|