Each smoke test now uses tests/smoke/_harness/ for Playwright, the Tauri IPC mock, the in-memory workspace, and output folders, instead of its own copy. The tests keep their interactions and assertions. Mock handlers that the app never calls are gone. - Split the four mixed regression scripts into 18 feature tests. - Update tests that broke when the app changed on purpose. Each update cites the app source that shows the new behavior. - Mark two real app defects with @known-issue: the settings window controls are 1px shorter than the main window controls, and plugin tabs cannot be reordered by dragging without a workspace. - Merge three palette unit tests into one table-driven test. - The native tests load Playwright through the harness and read NATIVE_CDP_URL, with their old variable names as fallbacks. - A failed smoke test saves a screenshot and prints the console errors. - The runner runs failed tests once more, alone, and reports a test that then passes as flaky. Result: 89 passed, 1 flaky, 2 known issues, 0 failed. Before, 45 of 78 passed.
59 lines
3.4 KiB
JavaScript
59 lines
3.4 KiB
JavaScript
// Front matter properties: first open, editing, undo, the saved selection, and both themes.
|
|
import assert from "node:assert/strict";
|
|
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
|
|
|
await runSmoke("editor/properties", async ({ page }) => {
|
|
await mockTauri(page, {
|
|
commands: test => test.workspace({
|
|
root: "C:\\smoke-workspace",
|
|
files: {
|
|
"notes/welcome.md": "---\ntitle: Welcome\n---\n\n# Working notes\n\nFirst paragraph.\n\n- [ ] A task\n\n[[second]]\n",
|
|
"notes/second.md": "# Second note\n",
|
|
"src/hello.py": "print('hello')\n",
|
|
},
|
|
}),
|
|
});
|
|
const output = await outputDir("editor/properties");
|
|
await page.goto(smokeUrl);
|
|
await page.getByText("smoke-workspace", { exact: true }).waitFor();
|
|
await page.keyboard.press("Control+p");
|
|
await page.getByRole("textbox", { name: "Find a file" }).fill("welcome.md");
|
|
await page.getByRole("dialog").getByRole("button").filter({ hasText: "welcome.md" }).first().click();
|
|
await page.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
|
|
await page.locator('.md-properties').waitFor();
|
|
await page.evaluate(async () => {
|
|
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
|
|
window.__CM__ = EditorView.findFromDOM(document.querySelector('.cm-content'));
|
|
});
|
|
const original = await page.evaluate(() => window.__CM__.state.sliceDoc());
|
|
assert.equal(await page.evaluate(() => window.__CM__.state.selection.main.head), original.indexOf('\n\n') + 1);
|
|
await page.locator('.md-properties summary').click();
|
|
assert.equal(await page.locator('.md-properties').getAttribute('open'), '');
|
|
assert.match(await page.locator('.md-properties pre').textContent(), /title: Welcome/);
|
|
for (const mode of ['light', 'dark']) {
|
|
await page.evaluate(async mode => {
|
|
const { applyAppearance } = await import('/src/lib/theme/appearance.ts');
|
|
applyAppearance({ theme: 'default', mode });
|
|
}, mode);
|
|
await page.setViewportSize({ width: 760, height: 900 });
|
|
await page.screenshot({ path: `${output}/properties-${mode}-narrow.png` });
|
|
}
|
|
await page.evaluate(() => { window.__CM__.dispatch({ selection: { anchor: 11 } }); window.__CM__.focus(); });
|
|
assert.equal(await page.locator('.md-properties').count(), 0);
|
|
await page.keyboard.type('New ');
|
|
assert.match(await page.evaluate(() => window.__CM__.state.sliceDoc()), /title: New Welcome/);
|
|
await page.keyboard.press('Control+z');
|
|
assert.equal(await page.evaluate(() => window.__CM__.state.sliceDoc()), original);
|
|
await page.evaluate(() => window.__CM__.dispatch({ selection: { anchor: window.__CM__.state.doc.length } }));
|
|
await page.locator('.md-properties').waitFor();
|
|
await page.evaluate(() => { window.__CM__.dispatch({ selection: { anchor: 11 } }); window.__CM__.focus(); });
|
|
await page.getByRole('group', { name: 'Document view' }).hover();
|
|
await page.getByRole('button', { name: 'Read', exact: true }).click();
|
|
await page.locator('.reading .md-properties').waitFor();
|
|
await page.getByRole('group', { name: 'Document view' }).hover();
|
|
await page.getByRole('button', { name: 'Edit', exact: true }).click();
|
|
await page.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
|
|
assert.equal(await page.locator('.writer-preview .md-properties').count(), 0);
|
|
console.log('Properties first-open, editing, undo, saved selection, and both themes passed.');
|
|
});
|