Files
edgeever/tests/memo-list-wechat-copy.test.ts
T
tianma-if 65ef837f45 feat(web): copy a note to WeChat from the card menu
Text-note card menus can copy the note as rich text. The open note uses the editor, including unsaved changes; other notes copy saved content without switching the editor.
2026-09-30 20:12:49 +08:00

25 lines
1.4 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
const readSource = (path: string) => readFileSync(new URL(path, import.meta.url), "utf8");
const memoListSource = readSource("../apps/web/src/components/MemoListPane.tsx");
const workspaceSource = readSource("../apps/web/src/components/WorkspaceApp.tsx");
const editorActionsSource = readSource("../apps/web/src/components/editor/useEditorDocumentActions.ts");
describe("memo list WeChat copy", () => {
test("adds the publish copy action to text-note card menus", () => {
expect(memoListSource).toContain('t("editor.copyToWeChat")');
expect(memoListSource).toContain("!memoContextMenu.memo.diagramKind && !memoContextMenu.memo.structuredTable && !memoContextMenu.memo.infographic");
expect(memoListSource).toContain("void handleCopyContextMemoToWeChat()");
expect(memoListSource).toContain('wechatCopyNotice === "copied" ? "editor.copiedToWeChat" : "editor.copyToWeChatFailed"');
});
test("copies the open text note through the editor and other notes from saved markdown", () => {
expect(workspaceSource).toContain('action: "copy-wechat"');
expect(workspaceSource).toContain("copyMarkdownToWeChat(memo.contentMarkdown)");
expect(workspaceSource).toContain("return \"editor\"");
expect(editorActionsSource).toContain("copyWeChat: () => void handleCopyToWeChat()");
});
});