mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 23:20:46 +00:00
431 lines
20 KiB
TypeScript
431 lines
20 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
import {
|
|
getHostPickerTriggerRange,
|
|
isNoteSmallImageWidth,
|
|
isSupportedNoteExternalHref,
|
|
isPointerInsideLinkActionHoverZone,
|
|
linkActionStatesEqual,
|
|
NOTE_SMALL_IMAGE_MAX_WIDTH,
|
|
resolveHostPickerPopupPosition,
|
|
shouldInsertClipboardTextAsMarkdown,
|
|
shouldHandleHostPickerNavigationKey,
|
|
} from "./InlineMarkdownEditor.tsx";
|
|
|
|
test("host picker navigation keys are handled even before a query is typed", () => {
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "ArrowDown", 3), true);
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "ArrowUp", 3), true);
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "Enter", 3), true);
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "Tab", 3), true);
|
|
});
|
|
|
|
test("host picker uses a constrained virtual list and keeps pointer selection", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /FixedSizeVirtualList/);
|
|
assert.match(source, /ref=\{hostPickerListRef\}/);
|
|
assert.match(source, /HOST_PICKER_LIST_MAX_HEIGHT/);
|
|
assert.match(
|
|
source,
|
|
/filteredHosts\.length === 0\s*\?\s*HOST_PICKER_EMPTY_HEIGHT\s*:\s*HOST_PICKER_LIST_VERTICAL_PADDING \+ filteredHosts\.length \* HOST_PICKER_ROW_HEIGHT/,
|
|
);
|
|
assert.match(source, /onMouseDown=\{\(event\) => event\.preventDefault\(\)\}/);
|
|
assert.match(source, /onClick=\{\(\) => insertHostLink\(host\)\}/);
|
|
});
|
|
|
|
test("host picker still lets ordinary trigger text continue through the editor", () => {
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "@", 3), false);
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "/", 3), false);
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "a", 3), false);
|
|
});
|
|
|
|
test("host picker does not consume submit keys when there are no hosts to choose", () => {
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "ArrowDown", 0), false);
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "Enter", 0), false);
|
|
assert.equal(shouldHandleHostPickerNavigationKey(true, "Escape", 0), true);
|
|
});
|
|
|
|
test("link action hover zone keeps the open button reachable but not sticky", () => {
|
|
const action = { href: "https://example.com", label: "example", left: 100, top: 50 };
|
|
|
|
assert.equal(isPointerInsideLinkActionHoverZone(action, 105, 55), true);
|
|
assert.equal(isPointerInsideLinkActionHoverZone(action, 95, 45), true);
|
|
assert.equal(isPointerInsideLinkActionHoverZone(action, 160, 55), false);
|
|
assert.equal(isPointerInsideLinkActionHoverZone(null, 105, 55), false);
|
|
});
|
|
|
|
test("link action state equality skips identical hover chips", () => {
|
|
const a = { href: "https://example.com", label: "example", left: 100, top: 50 };
|
|
assert.equal(linkActionStatesEqual(a, { ...a }), true);
|
|
assert.equal(linkActionStatesEqual(a, { ...a, left: 101 }), false);
|
|
assert.equal(linkActionStatesEqual(a, null), false);
|
|
assert.equal(linkActionStatesEqual(null, null), true);
|
|
});
|
|
|
|
test("small note image width threshold matches README badge sizes", () => {
|
|
assert.equal(isNoteSmallImageWidth(32), true);
|
|
assert.equal(isNoteSmallImageWidth("96"), true);
|
|
assert.equal(isNoteSmallImageWidth(NOTE_SMALL_IMAGE_MAX_WIDTH), true);
|
|
assert.equal(isNoteSmallImageWidth(128), false);
|
|
assert.equal(isNoteSmallImageWidth(2000), false);
|
|
assert.equal(isNoteSmallImageWidth(""), false);
|
|
assert.equal(isNoteSmallImageWidth(null), false);
|
|
});
|
|
|
|
test("host picker trigger range only covers the typed trigger and query", () => {
|
|
const text = "before\n\n@10.2.0.32";
|
|
const range = getHostPickerTriggerRange(text);
|
|
|
|
assert.deepEqual(range, {
|
|
query: "10.2.0.32",
|
|
startOffset: "before\n\n".length,
|
|
trigger: "@",
|
|
});
|
|
assert.equal(text.slice(0, range?.startOffset), "before\n\n");
|
|
});
|
|
|
|
test("host picker trigger range supports slash without stealing ordinary text", () => {
|
|
assert.deepEqual(getHostPickerTriggerRange("run /prod"), {
|
|
query: "prod",
|
|
startOffset: "run ".length,
|
|
trigger: "/",
|
|
});
|
|
assert.equal(getHostPickerTriggerRange("email foo@bar"), null);
|
|
});
|
|
|
|
test("host picker opens above the caret when the bottom edge has no room", () => {
|
|
const position = resolveHostPickerPopupPosition({
|
|
anchorRect: { left: 520, top: 910, bottom: 930, width: 1, height: 20 },
|
|
containerRect: { left: 400, top: 40, bottom: 960, width: 1200, height: 920 },
|
|
availableHostCount: 8,
|
|
viewportHeight: 960,
|
|
});
|
|
|
|
assert.equal(position.left, 120);
|
|
assert.ok(position.top < 870);
|
|
});
|
|
|
|
test("host picker stays below the caret when there is enough room", () => {
|
|
const position = resolveHostPickerPopupPosition({
|
|
anchorRect: { left: 520, top: 160, bottom: 180, width: 1, height: 20 },
|
|
containerRect: { left: 400, top: 40, bottom: 960, width: 1200, height: 920 },
|
|
availableHostCount: 4,
|
|
viewportHeight: 960,
|
|
});
|
|
|
|
assert.equal(position.left, 120);
|
|
assert.equal(position.top, 150);
|
|
});
|
|
|
|
test("pasted markdown is detected only when it has renderable structure", () => {
|
|
assert.equal(shouldInsertClipboardTextAsMarkdown("# Runbook\n\n- restart sshd"), true);
|
|
assert.equal(shouldInsertClipboardTextAsMarkdown("Open [docs](https://example.com)"), true);
|
|
assert.equal(shouldInsertClipboardTextAsMarkdown("```sh\nuptime\n```"), true);
|
|
assert.equal(shouldInsertClipboardTextAsMarkdown("plain text from clipboard"), false);
|
|
assert.equal(shouldInsertClipboardTextAsMarkdown("https://example.com/path_(x)"), false);
|
|
// Image markdown / raw HTML img must intercept so notes can render remote images.
|
|
assert.equal(shouldInsertClipboardTextAsMarkdown(""), true);
|
|
assert.equal(shouldInsertClipboardTextAsMarkdown('<img alt="logo" src="https://example.com/logo.png" />'), true);
|
|
});
|
|
|
|
test("note editor registers a code block editor for pasted fenced code", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(
|
|
source,
|
|
/codeBlockPlugin\([^)]*\),\s*codeMirrorPlugin\(\{\s*codeBlockLanguages:/s,
|
|
);
|
|
assert.match(source, /codeMirrorExtensions:\s*NOTE_CODE_MIRROR_EXTENSIONS/);
|
|
assert.match(source, /syntaxHighlighting\(noteCodeHighlightStyle\)/);
|
|
});
|
|
|
|
test("note editor enables image plugin for remote markdown images", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
assert.match(source, /imagePlugin\(\{\s*allowSetImageDimensions:\s*true/);
|
|
});
|
|
|
|
test("note editor exposes preview and edit modes with a markdown toolbar in edit mode", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
const managerSource = readFileSync(new URL("./NotesManager.tsx", import.meta.url), "utf8");
|
|
const toolbarSource = readFileSync(new URL("./NoteToolbar.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /type NoteEditorMode = "edit" \| "preview"/);
|
|
// The app-owned NoteToolbar (not MDXEditor's toolbarPlugin) hosts the
|
|
// formatting controls; MDXEditor must not render its own toolbar.
|
|
assert.doesNotMatch(source, /toolbarPlugin\(/);
|
|
assert.match(toolbarSource, /onAction\?\.\("undo"\)/);
|
|
assert.match(toolbarSource, /onAction\?\.\("redo"\)/);
|
|
assert.match(toolbarSource, /<Undo2 size=\{14\} \/>/);
|
|
assert.match(toolbarSource, /<Redo2 size=\{14\} \/>/);
|
|
// Preview and edit both use MDXEditor (readOnly in preview).
|
|
assert.match(source, /readOnly=\{editorMode === "preview"\}/);
|
|
assert.match(source, /key=\{editorMode\}/);
|
|
assert.match(source, /netcatty-mdx-editor--preview/);
|
|
assert.doesNotMatch(source, /NoteMarkdownPreview|react-markdown|github-markdown/);
|
|
assert.match(source, /editorMode = controlledEditorMode \?\? "edit"/);
|
|
assert.doesNotMatch(source, /data-note-mode-switch/);
|
|
assert.doesNotMatch(source, /absolute -top-9/);
|
|
assert.match(managerSource, /data-note-title-row/);
|
|
assert.match(managerSource, /data-note-mode-switch/);
|
|
assert.match(managerSource, /Glasses/);
|
|
assert.match(managerSource, /PencilLine/);
|
|
assert.match(managerSource, /setNoteEditorMode\(\(currentMode\) => \(/);
|
|
assert.match(managerSource, /currentMode === "edit" \|\| currentMode === "live" \? "preview" : "edit"/);
|
|
assert.match(managerSource, /editorMode=\{noteEditorMode\}/);
|
|
assert.match(managerSource, /className="app-no-drag h-8 w-8 shrink-0 rounded-md p-0 text-muted-foreground transition-colors hover:bg-secondary\/70 hover:text-foreground"/);
|
|
assert.doesNotMatch(managerSource, /data-note-mode-switch[\s\S]{0,500}border/);
|
|
assert.doesNotMatch(`${source}\n${managerSource}`, /role="tablist"|role="tab"|renderModeButton/);
|
|
assert.doesNotMatch(`${source}\n${managerSource}`, /className="mb-2 flex shrink-0 items-center justify-end"/);
|
|
});
|
|
|
|
test("note markdown toolbar remains usable in narrow panes", () => {
|
|
const styles = readFileSync(new URL("../../index.css", import.meta.url), "utf8");
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
const toolbarSource = readFileSync(new URL("./NoteToolbar.tsx", import.meta.url), "utf8");
|
|
|
|
assert.doesNotMatch(source, /MoreHorizontal|data-note-toolbar-more|netcatty-note-toolbar-more/);
|
|
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s*\{[^}]*container-type:\s*inline-size;/s,
|
|
);
|
|
// Keep fixed-containing-block in sync with MDX linkDialog coordinate math
|
|
// (container-type alone is not a fixed CB in browsers).
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s*\{[^}]*transform:\s*translateZ\(0\);/s,
|
|
);
|
|
// The app-owned NoteToolbar scrolls horizontally when the pane is narrow so
|
|
// formatting buttons are never clipped; the scrollbar stays visible.
|
|
assert.match(
|
|
toolbarSource,
|
|
/overflow-x-auto [^"]*\[scrollbar-width:thin\]/,
|
|
);
|
|
assert.match(
|
|
toolbarSource,
|
|
/\[&::-webkit-scrollbar\]:h-1\.5/,
|
|
);
|
|
assert.match(
|
|
toolbarSource,
|
|
/\[&::-webkit-scrollbar-thumb\]:bg-border\/70/,
|
|
);
|
|
assert.match(
|
|
toolbarSource,
|
|
/flex flex-1 items-center gap-0\.5 min-w-0 overflow-x-auto/,
|
|
);
|
|
});
|
|
|
|
test("preview mode opens links directly without showing the edit hover action", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /const handleClickCapture = useCallback/);
|
|
assert.match(
|
|
source,
|
|
/if \(editorMode === "preview"\) \{[\s\S]*toggleTaskListItemAtIndex[\s\S]*const handled = openLink\(href, label\);/,
|
|
"preview click path handles task toggles then openable links",
|
|
);
|
|
assert.match(source, /const handled = openLink\(href, label\);[\s\S]*if \(!handled\) return;[\s\S]*event\.preventDefault\(\);/);
|
|
assert.match(source, /scheduleHostPickerUpdate\(\);\s*\n\s*\}, \[commitMarkdown, editorMode, openLink, scheduleHostPickerUpdate\]/);
|
|
assert.match(source, /onClickCapture=\{\(event\) => \{[\s\S]*blockWhileContentSwapping[\s\S]*handleClickCapture/);
|
|
assert.match(source, /if \(editorMode !== "edit"\) \{[\s\S]*setLinkActionIfChanged\(null\);[\s\S]*return;/);
|
|
assert.match(source, /\{editorMode === "edit" && linkAction && \(/);
|
|
});
|
|
|
|
test("preview mode only intercepts links netcatty can open", () => {
|
|
assert.equal(isSupportedNoteExternalHref("https://example.com/docs"), true);
|
|
assert.equal(isSupportedNoteExternalHref("http://example.com/docs"), true);
|
|
assert.equal(isSupportedNoteExternalHref("mailto:support@example.com"), true);
|
|
assert.equal(isSupportedNoteExternalHref("#section"), false);
|
|
assert.equal(isSupportedNoteExternalHref("/docs"), false);
|
|
assert.equal(isSupportedNoteExternalHref("file:///tmp/readme.md"), false);
|
|
});
|
|
|
|
test("pasting inside code blocks keeps CodeMirror in control", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /export const isNotePasteInsideCodeBlock/);
|
|
assert.match(source, /element\?\.closest/);
|
|
assert.match(source, /\.cm-editor/);
|
|
assert.match(source, /_codeMirrorWrapper_/);
|
|
assert.match(
|
|
source,
|
|
/pasteInsideCodeBlock:\s*isNotePasteInsideCodeBlock\(event\.target\)/,
|
|
);
|
|
});
|
|
|
|
test("note code block editor colors follow the app theme", () => {
|
|
const styles = readFileSync(new URL("../../index.css", import.meta.url), "utf8");
|
|
|
|
assert.match(styles, /\.netcatty-mdx-editor\s+\.cm-editor/);
|
|
assert.match(styles, /\.netcatty-mdx-editor\s+\.cm-gutters/);
|
|
assert.match(styles, /background:\s*hsl\(var\(--secondary\)/);
|
|
assert.match(styles, /color:\s*hsl\(var\(--foreground\)/);
|
|
assert.match(styles, /--note-code-token-keyword:\s*color-mix\(in oklab,\s*hsl\(var\(--primary\)\)/);
|
|
assert.match(styles, /\.netcatty-mdx-editor\s+\.cm-content\s+\.netcatty-code-token-keyword/);
|
|
assert.match(styles, /\.netcatty-mdx-editor\s+\.cm-content\s+\.netcatty-code-token-string/);
|
|
assert.doesNotMatch(styles, /span\[class\*="ͼ"\]/);
|
|
assert.doesNotMatch(styles, /\.netcatty-mdx-editor\s+\.cm-line\s+span/);
|
|
});
|
|
|
|
test("note code block active line is highlighted only while focused", () => {
|
|
const styles = readFileSync(new URL("../../index.css", import.meta.url), "utf8");
|
|
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\.cm-activeLine,\s*\.netcatty-mdx-editor\s+\.cm-activeLineGutter\s*\{[^}]*background:\s*transparent/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\.cm-editor:focus-within\s+\.cm-activeLine,\s*\.netcatty-mdx-editor\s+\.cm-editor:focus-within\s+\.cm-activeLineGutter\s*\{[^}]*background:\s*hsl\(var\(--primary\)\s*\/\s*0\.08\)/s,
|
|
);
|
|
});
|
|
|
|
test("note code block frame is borderless and language picker is compact", () => {
|
|
const styles = readFileSync(new URL("../../index.css", import.meta.url), "utf8");
|
|
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\[class\*="_codeMirrorWrapper_"\]\s*\{[^}]*border:\s*0\s*!important;[^}]*padding:\s*0\.2rem\s+0\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\.cm-editor\s*\{[^}]*border:\s*0\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor:not\(\.netcatty-mdx-editor--preview\)\s+\[class\*="_codeMirrorToolbar_"\]\s*\{[^}]*position:\s*absolute\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor \[class\*="_codeMirrorToolbar_"\] \[class\*="_selectTrigger_"\]\s*\{[^}]*height:\s*1\.45rem\s*!important;[^}]*font-size:\s*11px\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor \[class\*="_codeMirrorToolbar_"\] \[class\*="_tooltipTrigger_"\]\s*\{[^}]*display:\s*inline-flex\s*!important;[^}]*align-items:\s*center\s*!important;[^}]*align-self:\s*center\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor \[class\*="_codeMirrorToolbar_"\]\s+\[class\*="_selectTrigger_"\]\s*\{[^}]*width:\s*auto\s*!important;[^}]*min-width:\s*0\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor \[class\*="_toolbarCodeBlockLanguageSelectContent_"\][\s\S]*width:\s*auto\s*!important;[\s\S]*min-width:\s*max-content\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor \[class\*="_toolbarCodeBlockLanguageSelectContent_"\] \[class\*="_selectItem_"\][\s\S]*font-size:\s*11px\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\.cm-editor\s*\{[^}]*font-size:\s*13px\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\.cm-line\s*\{[^}]*line-height:\s*1\.45\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\.cm-gutterElement\s*\{[^}]*font-size:\s*13px\s*!important;[^}]*line-height:\s*1\.45\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor:not\(\.netcatty-mdx-editor--preview\)\s+\[class\*="_codeMirrorWrapper_"\]\s*\{[^}]*gap:\s*0;[^}]*margin:\s*0\.3rem\s+0\s+0\.65rem;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor:not\(\.netcatty-mdx-editor--preview\)\s+\[class\*="_codeMirrorWrapper_"\]\s+\.cm-content\s*\{[^}]*padding:\s*0\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\.cm-gutters\s*\{[^}]*padding:\s*0\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor--preview\s+\[class\*="_codeMirrorToolbar_"\]\s*\{[^}]*display:\s*none\s*!important;/s,
|
|
);
|
|
});
|
|
|
|
test("getCodeMirrorBlockText reads rendered code block lines", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /export const getCodeMirrorBlockText/);
|
|
assert.match(source, /\.cm-content \.cm-line/);
|
|
assert.match(source, /\.join\("\\n"\)/);
|
|
});
|
|
|
|
test("annotateNoteCodeBlockCopyButtons adds a copy action to code blocks", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /export const annotateNoteCodeBlockCopyButtons/);
|
|
assert.match(source, /data-note-code-copy/);
|
|
assert.match(source, /getCodeMirrorBlockText\(wrapper\)/);
|
|
assert.match(source, /onCopy\(text\)/);
|
|
});
|
|
|
|
test("annotateNoteCodeBlockCopyButtons treats a CSS-hidden toolbar as absent so preview shows the copy button", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /getComputedStyle\(toolbar\)\.display !== "none"/);
|
|
assert.match(source, /toolbarVisible/);
|
|
assert.match(source, /firstButton\.parentElement !== wrapper/);
|
|
assert.match(source, /wrapper\.appendChild\(firstButton\)/);
|
|
});
|
|
|
|
test("annotateNoteCodeBlockDeleteButtons swaps the delete icon to a stroke SVG", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /export const annotateNoteCodeBlockDeleteButtons/);
|
|
assert.match(source, /data-note-code-delete/);
|
|
assert.match(source, /DELETE_ICON_SVG/);
|
|
assert.match(source, /stroke="currentColor"/);
|
|
assert.match(source, /stroke-width="2"/);
|
|
});
|
|
|
|
test("note preview uses MDX readOnly with code-copy chrome", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
const styles = readFileSync(new URL("../../index.css", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /removeNoteCodeBlockCopyButtons/);
|
|
assert.match(source, /readOnly=\{editorMode === "preview"\}/);
|
|
assert.match(source, /annotateCodeBlockCopyButtons/);
|
|
assert.match(source, /annotateNoteCodeBlockCopyButtons/);
|
|
assert.match(source, /MutationObserver/);
|
|
assert.match(source, /setAttribute\("aria-label", copiedLabel\)/);
|
|
assert.match(styles, /\.netcatty-note-code-copy/);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\[class\*="_codeMirrorWrapper_"\]:hover\s+\.netcatty-note-code-copy/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor:not\(\.netcatty-mdx-editor--preview\)\s+\[class\*="_codeMirrorWrapper_"\]\s*\{[^}]*display:\s*flex;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor:not\(\.netcatty-mdx-editor--preview\)\s+\[class\*="_codeMirrorToolbar_"\]\s*\{[^}]*justify-content:\s*flex-end;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\[class\*="_codeMirrorToolbar_"\]\s+\[class\*="_selectTrigger_"\]\s*\{[^}]*font-size:\s*11px\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\[class\*="_codeMirrorToolbar_"\]\s+button[^{]*\{[^}]*height:\s*1\.4rem\s*!important;/s,
|
|
);
|
|
assert.match(
|
|
styles,
|
|
/\.netcatty-mdx-editor\s+\[class\*="_codeMirrorToolbar_"\][^{]*svg\s*\{[^}]*width:\s*10px\s*!important;/s,
|
|
);
|
|
});
|
|
|
|
test("annotateMathFormulaBlocks handles empty math blocks and avoids reading toolbar text", () => {
|
|
const source = readFileSync(new URL("./InlineMarkdownEditor.tsx", import.meta.url), "utf8");
|
|
|
|
assert.match(source, /export const annotateMathFormulaBlocks/);
|
|
assert.match(source, /const text = getCodeMirrorBlockText\(wrapper\)\.trim\(\);/);
|
|
assert.match(source, /if \(!formulaSource\) \{/);
|
|
assert.match(source, /existingPreview\.remove\(\)/);
|
|
});
|