Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dev:installer": "tauri dev -- -- --install",
"build": "vite build",
"preview": "vite preview",
"test:frontmatter": "node --test --import tsx scripts/frontMatter.test.ts scripts/frontMatterDisclosure.test.ts",
"test:frontmatter": "node --test --import tsx scripts/frontMatter.test.ts",
"test:workflows": "node --test --import tsx scripts/exportHtml.test.ts scripts/exportOpenPrompt.test.ts scripts/reloadOpenToolbar.test.ts scripts/editorToolbar.test.ts scripts/titlebarToolbar.test.ts scripts/toolbarCustomizationWiring.test.ts",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
Expand Down
34 changes: 34 additions & 0 deletions scripts/frontMatterDisclosure.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { test } from 'node:test';

const viewerSource = readFileSync(new URL('../src/lib/MarkdownViewer.svelte', import.meta.url), 'utf8');

test('front matter panel uses native details disclosure so collapsed summary remains expandable', () => {
const panelStart = viewerSource.indexOf('frontmatter-panel');
assert.notEqual(panelStart, -1);

const panelSource = viewerSource.slice(panelStart - 160, panelStart + 900);

assert.match(panelSource, /<details\b[^>]*class="frontmatter-panel"/);
assert.match(panelSource, /<summary\b[^>]*class="frontmatter-summary"/);
assert.doesNotMatch(panelSource, /<button\b[^>]*class="frontmatter-summary"/);
});

test('front matter panel is collapsed by default until the user opens it', () => {
assert.match(viewerSource, /frontMatterCollapsedByKey\[frontMatterPanelKey\]\s*\?\?\s*true/);
assert.match(viewerSource, /open=\{!isFrontMatterCollapsed\}/);
});

test('front matter list fields render as editable tags instead of one comma input', () => {
const listBranchStart = viewerSource.indexOf("field.kind === 'list'");
assert.notEqual(listBranchStart, -1);

const listBranch = viewerSource.slice(listBranchStart, listBranchStart + 4000);

assert.match(listBranch, /class="frontmatter-tags"/);
assert.match(listBranch, /class="frontmatter-tag-remove"/);
assert.match(listBranch, /class="frontmatter-tag-add-button"/);
assert.match(listBranch, /startFrontMatterTagEdit/);
assert.match(listBranch, /value=\{getFrontMatterTagDraft\(field\)\}/);
});
Loading
Loading