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:
@@ -0,0 +1,31 @@
|
||||
// Export theme template in Settings > Appearance: success, cancel, and an export error.
|
||||
import assert from "node:assert/strict";
|
||||
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("appearance/themeExport", async ({ page }) => {
|
||||
await mockTauri(page, {
|
||||
state: { exportResult: "C:\\exports\\my-theme.json", exportError: "" },
|
||||
commands: test => ({
|
||||
...test.workspace({ root: "C:\\theme-export" }),
|
||||
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
|
||||
theme_export: () => {
|
||||
if (test.state.exportError) throw new Error(test.state.exportError);
|
||||
return test.state.exportResult;
|
||||
},
|
||||
}),
|
||||
});
|
||||
const exportButton = page.getByRole("button", { name: "Export theme template" });
|
||||
await page.goto(smokeUrl + "/?settingsWindow=true");
|
||||
await page.getByRole("button", { name: "Appearance", exact: true }).click();
|
||||
await exportButton.click();
|
||||
await page.getByRole("status").filter({ hasText: "Theme saved to" }).waitFor();
|
||||
// Exported templates use theme schema 2 (src/lib/theme/appearance.ts:90).
|
||||
assert.equal(await page.evaluate(() => JSON.parse(window.__TEST__.calls.find(call => call.command === "theme_export").args.contents).schema), 2);
|
||||
await page.evaluate(() => { window.__TEST__.state.exportResult = null; });
|
||||
await exportButton.click();
|
||||
await page.getByText("Export canceled.", { exact: true }).waitFor();
|
||||
await page.evaluate(() => { window.__TEST__.state.exportError = "Disk is full"; });
|
||||
await exportButton.click();
|
||||
await page.getByRole("alert").filter({ hasText: "Disk is full" }).waitFor();
|
||||
console.log("PASS: theme export success, cancel, and error");
|
||||
}, { viewport: { width: 1200, height: 850 } });
|
||||
Reference in New Issue
Block a user