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
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { parseRichTextMentionHref } from "@tutti-os/ui-rich-text/core";
|
|
import {
|
|
browserElementMentionLabel,
|
|
createBrowserElementMentionMarkdown,
|
|
presentBrowserElementMention
|
|
} from "./browserElementMention.ts";
|
|
|
|
describe("browser element mentions", () => {
|
|
it("preserve prompt text and show only the DOM tag", () => {
|
|
const context = [
|
|
"DOM Path: #app > div",
|
|
"Position: top=0px",
|
|
"HTML Element: <div>Hello</div>"
|
|
].join("\n");
|
|
const markdown = createBrowserElementMentionMarkdown({
|
|
context,
|
|
id: "browser-element:1",
|
|
tagName: "A",
|
|
workspaceId: "workspace-1"
|
|
});
|
|
const href = markdown.slice(markdown.indexOf("(") + 1, -1);
|
|
const mention = parseRichTextMentionHref(href);
|
|
|
|
expect(markdown).toMatch(/^\[@a\]\(/u);
|
|
expect(browserElementMentionLabel(mention?.scope?.tag ?? "")).toBe("<a>");
|
|
expect(mention?.providerId).toBe("browser-element");
|
|
expect(mention?.scope?.context).toBe(context);
|
|
expect(mention?.scope?.workspaceId).toBe("workspace-1");
|
|
});
|
|
|
|
it("reject incomplete references", () => {
|
|
expect(
|
|
createBrowserElementMentionMarkdown({
|
|
context: "",
|
|
id: "browser-element:1",
|
|
tagName: "div",
|
|
workspaceId: "workspace-1"
|
|
})
|
|
).toBe("");
|
|
});
|
|
|
|
it("keep historical references presentable without inline context", () => {
|
|
expect(
|
|
presentBrowserElementMention({
|
|
label: "a",
|
|
scope: { tag: "a", workspaceId: "workspace-1" }
|
|
})
|
|
).toEqual({ name: "<a>", workspaceId: "workspace-1" });
|
|
});
|
|
});
|