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.
57 lines
3.1 KiB
JavaScript
57 lines
3.1 KiB
JavaScript
// Move a tab to a new window: Open in new window carries unsaved text, and a tab dragged out stays until the new window accepts it.
|
|
import assert from "node:assert/strict";
|
|
import { mockTauri, openPage, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
|
|
|
await runSmoke("tabs/windowTransfer", async ({ browser }) => {
|
|
// The transfer passes through localStorage, so the source and target windows need one context.
|
|
const context = await browser.newContext({ viewport: { width: 1440, height: 1000 } });
|
|
await mockTauri(context, {
|
|
commands: test => ({
|
|
...test.workspace({ root: "C:\\window-transfer", files: { "a.md": "# Alpha\n", "b.md": "# Beta\n" } }),
|
|
workspace_open_window: ({ transfer }) => { test.transfer = transfer; },
|
|
plugins_snapshot: () => ({ plugins: [], issues: [] }),
|
|
spelling_menu_install: () => null,
|
|
}),
|
|
});
|
|
const page = await openPage(context, { timeout: 15000 });
|
|
const tab = name => page.getByRole("tab", { name, exact: true });
|
|
async function open(name) {
|
|
await page.keyboard.press("Control+p");
|
|
await page.getByRole("textbox", { name: "Find a file" }).fill(name);
|
|
await page.getByRole("dialog").getByRole("button").filter({ hasText: name }).first().click();
|
|
await tab(name).waitFor();
|
|
}
|
|
await page.goto(smokeUrl);
|
|
await page.getByText("window-transfer", { exact: true }).waitFor();
|
|
await open("a.md");
|
|
await open("b.md");
|
|
const editor = page.locator(".cm-content");
|
|
await editor.click();
|
|
await page.keyboard.press("Control+End");
|
|
await page.keyboard.type("Unsaved transfer");
|
|
await tab("b.md").click({ button: "right" });
|
|
await page.getByRole("menuitem", { name: "Open in new window", exact: true }).click();
|
|
await page.waitForFunction(() => window.__TEST__.transfer);
|
|
const token = await page.evaluate(() => window.__TEST__.transfer);
|
|
const target = await openPage(context, { timeout: 15000 });
|
|
await target.goto(smokeUrl + "/?tabTransfer=" + token);
|
|
await target.getByRole("tab", { name: "b.md", exact: true }).waitFor();
|
|
await target.waitForFunction(() => document.querySelector(".cm-content")?.textContent.includes("Unsaved transfer"));
|
|
await tab("b.md").waitFor({ state: "detached" });
|
|
console.log("PASS: Open in new window carries unsaved text and removes the source tab");
|
|
|
|
await page.evaluate(() => { window.__TEST__.transfer = null; });
|
|
const draggedTab = page.getByRole("tab").first();
|
|
const draggedPath = await draggedTab.getAttribute("data-path");
|
|
const tabBox = await draggedTab.boundingBox();
|
|
await page.mouse.move(tabBox.x + tabBox.width / 2, tabBox.y + tabBox.height / 2);
|
|
await page.mouse.down();
|
|
await page.mouse.move(1480, 180, { steps: 12 });
|
|
await page.mouse.up();
|
|
await page.waitForFunction(() => window.__TEST__.transfer);
|
|
assert.notEqual(await page.evaluate(() => window.__TEST__.transfer), token);
|
|
assert.equal(await page.locator(`[role="tab"][data-path="${draggedPath}"]`).count(), 1, "Keep the source tab until the new window accepts it");
|
|
assert.equal([...page.errors, ...target.errors].length, 0, [...page.errors, ...target.errors].join("\n"));
|
|
console.log("PASS: a tab dragged out of the window stays until the new window accepts it");
|
|
});
|