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
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
"build": "vite build",
"preview": "vite preview",
"test": "node --test --import tsx 'scripts/*.test.ts'",
"test:frontmatter": "node --test --import tsx scripts/frontMatter.test.ts scripts/frontMatterDisclosure.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",
"test:settings-scroll": "node --test --import tsx scripts/previewScrollSync.test.ts scripts/toolbarCustomizationWiring.test.ts",
"test:frontmatter": "node --test --import tsx scripts/frontMatter.test.ts scripts/frontMatterProseBlock.test.ts",
"test:workflows": "node --test --import tsx scripts/exportHtml.test.ts scripts/exportOpenPrompt.test.ts scripts/editorToolbar.test.ts scripts/titlebarToolbar.test.ts",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"build:test-bundle": "node scripts/build-test-bundle.mjs",
Expand Down
17 changes: 0 additions & 17 deletions scripts/batchCloseConfirmation.test.ts

This file was deleted.

72 changes: 0 additions & 72 deletions scripts/findCollapsedMatches.test.ts

This file was deleted.

24 changes: 24 additions & 0 deletions scripts/foldLayout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ test('fold wrapper animates an explicit measured height instead of a fractional
assert.match(styles, /foldable-content-wrapper\.is-collapsed[\s\S]*height:\s*0/);
});

// Salvaged from `findCollapsedMatches.test.ts`, which was deleted for asserting
// the spelling of FindBar.svelte (it stayed green with `revealFoldsAround` made
// a no-op). This assertion is a different kind: it couples a TypeScript constant
// to a CSS duration in another file. Nothing else compares the two, and when
// FindBar's re-aim timer fires before the height transition settles the scroll
// lands on a target that is still moving — a defect that only shows up as "find
// sometimes scrolls to the wrong place".
test('the find-bar fold re-aim delay outlasts the CSS fold transition', () => {
const findBar = readFileSync('src/lib/components/FindBar.svelte', 'utf8');
const styles = readFileSync('src/styles.css', 'utf8');

const declared = findBar.match(/const FOLD_TRANSITION_MS = (\d+);/);
assert.ok(declared, 'FindBar.svelte must declare the delay it waits for the fold to settle');

const expandedRule = styles.match(/\.foldable-content-wrapper\s*\{([^}]*)\}/)?.[1] || '';
const transition = expandedRule.match(/transition:[^;]*?height\s+([\d.]+)s/);
assert.ok(transition, 'styles.css must animate the fold wrapper height');

assert.ok(
Number(declared[1]) >= Number(transition[1]) * 1000,
`FOLD_TRANSITION_MS (${declared[1]}ms) must outlast the ${transition[1]}s height transition`,
);
});

test('preview lifecycle starts and cleans up fold observation', () => {
const viewer = readFileSync('src/lib/MarkdownViewer.svelte', 'utf8');

Expand Down
34 changes: 0 additions & 34 deletions scripts/frontMatterDisclosure.test.ts

This file was deleted.

50 changes: 50 additions & 0 deletions scripts/i18nCoverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,56 @@ test('the window-tag editor’s Save button is translated', () => {
}
});

// The two tests below moved here from `toolbarCustomizationWiring.test.ts`,
// which was deleted for asserting the spelling of `Settings.svelte` rather than
// any behaviour. These two were the exception: they import the dictionary and
// look keys up in it, and they are the only thing in the suite that fails when
// a *specific locale* silently falls back to English. The general rules above
// cannot see that — (1) only requires the key in English, and per-locale
// completeness is reported rather than enforced. These keys are the exception
// to that leniency because they label controls whose meaning is carried by the
// word alone: an untranslated "Move Up" on an icon button is unusable, not
// merely unpolished.

/** The value `lang` itself defines for `key`, ignoring the English fallback. */
function directTranslation(lang: LanguageCode, key: string): string | undefined {
return dictionaries.get(lang)!.get(key);
}

test('interactive button labels are directly translated for every supported language', () => {
const interactiveLabelKeys = [
'common.close',
'common.decrease',
'common.increase',
'toc.resizeTableOfContents',
'settings.move',
'settings.moveUp',
'settings.moveDown',
'settings.resetToolbar',
'settings.toolbarOnBar',
'settings.toolbarInMenu',
'settings.resizeWindow',
];

const missing = languages.flatMap((lang) =>
interactiveLabelKeys
.filter((key) => directTranslation(lang, key) === undefined)
.map((key) => `${lang}:${key}`),
);

assert.deepEqual(missing, []);
});

test('Simplified Chinese directly translates the window organization labels', () => {
const keys = [
'menu.moveToWindow', 'menu.window', 'menu.mergeAllWindows', 'menu.setWindowTag',
'menu.windowTagPlaceholder', 'menu.windowTagClear', 'menu.pinWindowTag',
'menu.unpinWindowTag', 'toast.noOtherWindows', 'home.pinnedTags', 'home.pinnedFileCount',
];

assert.deepEqual(keys.filter((key) => directTranslation('zh-CN', key) === undefined), []);
});

test('every t() call resolves to a literal, a declared family, or a known indirection', () => {
assert.deepEqual(
[...indirectCalls].sort(),
Expand Down
36 changes: 0 additions & 36 deletions scripts/interruptedSessionRestore.test.ts

This file was deleted.

36 changes: 36 additions & 0 deletions scripts/macosPdfExport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,39 @@ test('all Markpad webviews may invoke Tauri native printing', () => {
'macOS replaces window.print() with Tauri native printing, which requires this permission',
);
});

// Salvaged from `windowsPdfExport.test.ts`, which was deleted for asserting the
// spelling of the Rust body (it stayed green with the `await` dropped from the
// call below). This part is the opposite kind of claim: a Tauri command name is
// a bare string on the JS side and an identifier inside a macro on the Rust
// side, so nothing — not tsc, not `svelte-check`, not `cargo check` — notices
// when one moves and the other does not. The failure is silent at build time
// and total at runtime: "Export PDF" does nothing at all.
test('both PDF commands the exporter invokes are registered with Tauri', () => {
const exporter = readFileSync('src/lib/utils/export.ts', 'utf8');
const tauriLib = readFileSync('src-tauri/src/lib.rs', 'utf8');

const handlerStart = tauriLib.indexOf('tauri::generate_handler![');
assert.notEqual(handlerStart, -1, 'lib.rs must keep a generate_handler! list');
const handlerEnd = tauriLib.indexOf(']', handlerStart);
const registered = new Set(
tauriLib
.slice(handlerStart, handlerEnd)
.split(',')
.map((entry) => entry.trim().replace(/^.*::/, '')),
);

// Read the names off the exporter rather than restating them, so a renamed
// command is checked at its new name instead of quietly passing.
const invoked = [...exporter.matchAll(/invoke\('([a-z_]*pdf[a-z_]*)'/g)].map((m) => m[1]);
assert.deepEqual(invoked.sort(), ['export_pdf_windows', 'print_pdf']);

for (const command of invoked) {
assert.ok(registered.has(command), `export.ts invokes '${command}', which lib.rs must register`);
assert.match(
tauriLib,
new RegExp(`#\\[tauri::command\\]\\n(?:async )?fn ${command}\\(`),
`${command} must be defined as a Tauri command`,
);
}
});
12 changes: 0 additions & 12 deletions scripts/openMultipleFiles.test.ts

This file was deleted.

17 changes: 0 additions & 17 deletions scripts/previewRenderRevision.test.ts

This file was deleted.

38 changes: 0 additions & 38 deletions scripts/previewScrollSync.test.ts

This file was deleted.

Loading
Loading