Move the smoke tests onto the shared harness
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.
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
// Use a debug app with TAURI_CONFIG identifier com.runestone.spelling-test,
|
||||
// a hidden window, and a separate WEBVIEW2_USER_DATA_FOLDER outside Vite's watch paths.
|
||||
// Set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9224 before launch.
|
||||
// Native spelling menu in Writer, inputs, textareas, and dialogs: WebView2 Undo, spelling corrections, and editor undo.
|
||||
// Start a debug app with the isolated identifier com.runestone.spelling-test, a hidden window, a separate
|
||||
// WEBVIEW2_USER_DATA_FOLDER outside Vite's watch paths, and remote debugging on port 9224:
|
||||
// set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9224
|
||||
// pnpm tauri dev --config "{\"identifier\":\"com.runestone.spelling-test\"}"
|
||||
// Run `node tests/native/spelling.native.mjs`. NATIVE_CDP_URL (or the older SPELLING_CDP_URL) overrides http://127.0.0.1:9224.
|
||||
// SPELLING_APP_URL overrides http://localhost:1420. SPELLING_WORKSPACE overrides the workspace folder in output/smoke/native/spelling/.
|
||||
// The normal app identifier is rejected before this test writes any workspace files.
|
||||
import { createRequire } from "node:module";
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
import path from "node:path";
|
||||
import assert from "node:assert/strict";
|
||||
import { outputDir, playwright } from "../smoke/_harness/index.mjs";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.connectOverCDP(process.env.SPELLING_CDP_URL || "http://127.0.0.1:9224");
|
||||
const { chromium } = playwright();
|
||||
const browser = await chromium.connectOverCDP(process.env.NATIVE_CDP_URL || process.env.SPELLING_CDP_URL || "http://127.0.0.1:9224");
|
||||
const page = browser.contexts()[0].pages()[0];
|
||||
page.setDefaultTimeout(15000);
|
||||
try {
|
||||
@@ -19,9 +22,10 @@ try {
|
||||
return appDataDir();
|
||||
});
|
||||
assert.match(data, /[\\/]com\.runestone\.spelling-test[\\/]?$/, "Use the isolated spelling-test app identifier");
|
||||
const workspace = resolve(process.env.SPELLING_WORKSPACE || ".audit/spelling-workspace");
|
||||
const output = await outputDir("native/spelling");
|
||||
const workspace = path.resolve(process.env.SPELLING_WORKSPACE || path.join(output, "workspace"));
|
||||
await mkdir(workspace, { recursive: true });
|
||||
await writeFile(resolve(workspace, "Spelling.md"), "# Spelling\n\nI recieved a letter.\n");
|
||||
await writeFile(path.join(workspace, "Spelling.md"), "# Spelling\n\nI recieved a letter.\n");
|
||||
await page.evaluate(async path => {
|
||||
const { invoke } = await import("/node_modules/@tauri-apps/api/core.js");
|
||||
await invoke("workspace_open", { path });
|
||||
@@ -41,8 +45,7 @@ try {
|
||||
await page.mouse.click(rect.x + 42, rect.y + rect.height / 2, { button: "right" });
|
||||
const menu = page.getByRole("menu", { name: "Spelling actions", exact: true });
|
||||
await menu.waitFor();
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.screenshot({ path: ".audit/spelling-native.png" });
|
||||
await page.screenshot({ path: path.join(output, "spelling-menu.png") });
|
||||
const undo = menu.getByRole("menuitem", { name: "Undo Ctrl+Z", exact: true });
|
||||
assert.equal(await undo.isEnabled(), true, "The native Undo command is enabled after typing");
|
||||
await undo.click();
|
||||
|
||||
Reference in New Issue
Block a user