refactor: pre-cleanup.
This commit is contained in:
1 parent
0ceab9d897
commit
e10cbbc92c
53 files changed
+3596
-648
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import "./shim.js";
|
||||
import { renderMarkdown } from "../src/chat/markdown.js";
|
||||
import { updateStreamingReply } from "../src/chat/chat-stream.js";
|
||||
|
||||
test("chat Markdown renders Telegram-style rich blocks as semantic HTML", () => {
|
||||
const rendered = renderMarkdown(
|
||||
"# Summary\n\n**bold**, *italic*, ~~removed~~, and [docs](https://example.com)\n\n- first\n- second\n\n> quoted\n\n```go\nfmt.Println(\"hi\")\n```\n\n| Name | State |\n| --- | --- |\n| Archie | **live** |",
|
||||
);
|
||||
|
||||
assert.equal(rendered.querySelector("h1").textContent, "Summary");
|
||||
assert.equal(rendered.querySelector("strong").textContent, "bold");
|
||||
assert.equal(rendered.querySelector("em").textContent, "italic");
|
||||
assert.equal(rendered.querySelector("del").textContent, "removed");
|
||||
assert.equal(rendered.querySelector("a").getAttribute("href"), "https://example.com");
|
||||
assert.equal(rendered.querySelector("ul").children.length, 2);
|
||||
assert.equal(rendered.querySelector("blockquote").textContent, "quoted");
|
||||
assert.match(rendered.querySelector("pre").textContent, /fmt\.Println/);
|
||||
assert.equal(rendered.querySelector("table").querySelector("th").textContent, "Name");
|
||||
assert.equal(rendered.querySelector("table").querySelector("td").textContent, "Archie");
|
||||
});
|
||||
|
||||
test("streaming assistant replies keep rich Markdown in the live bubble", () => {
|
||||
const bubble = renderMarkdown("draft");
|
||||
const updated = updateStreamingReply(bubble, "# Live\n\n**bold**");
|
||||
|
||||
assert.equal(updated.querySelector("h1").textContent, "Live");
|
||||
assert.equal(updated.querySelector("strong").textContent, "bold");
|
||||
assert.equal(updated.className, "chat-bubble-text");
|
||||
});
|
||||
@@ -16,6 +16,10 @@ class Node {
|
||||
append(...cs) {
|
||||
for (const c of cs.flat(Infinity)) {
|
||||
if (c == null || c === false) continue;
|
||||
if (c instanceof DocumentFragment) {
|
||||
this.append(...c.childNodes);
|
||||
continue;
|
||||
}
|
||||
this.childNodes.push(c instanceof Node ? c : new TextNode(String(c)));
|
||||
}
|
||||
}
|
||||
@@ -87,6 +91,8 @@ class TextNode extends Node {
|
||||
}
|
||||
}
|
||||
|
||||
class DocumentFragment extends Node {}
|
||||
|
||||
class Element extends Node {
|
||||
constructor(tag) {
|
||||
super();
|
||||
@@ -97,8 +103,10 @@ class Element extends Node {
|
||||
globalThis.Node = Node;
|
||||
globalThis.Element = Element;
|
||||
globalThis.TextNode = TextNode;
|
||||
globalThis.DocumentFragment = DocumentFragment;
|
||||
globalThis.document = {
|
||||
createElement: (tag) => new Element(tag),
|
||||
createElementNS: () => new Element("svg"),
|
||||
createDocumentFragment: () => new DocumentFragment(),
|
||||
createTextNode: (text) => new TextNode(String(text)),
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import "./shim.js";
|
||||
import { taskRowA11y } from "../src/tasks/task-row.js";
|
||||
|
||||
test("task rows expose an explicit keyboard-accessible timeline control", () => {
|
||||
assert.deepEqual(taskRowA11y({ id: 42, title: "Keyboard task" }, false), {
|
||||
"aria-expanded": "false",
|
||||
"aria-controls": "task-timeline-42",
|
||||
"aria-label": "Expand timeline for Keyboard task",
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user