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 @@
|
||||
// Ctrl+Tab selects the next working tab and Ctrl+Shift+Tab returns to the previous one.
|
||||
import assert from "node:assert/strict";
|
||||
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("tabs/cycleShortcuts", async ({ page }) => {
|
||||
await mockTauri(page, {
|
||||
commands: test => ({
|
||||
...test.workspace({ root: "C:\\tab-cycle", files: { "a.md": "# Alpha\n", "b.md": "# Beta\n" } }),
|
||||
plugins_snapshot: () => ({ plugins: [], issues: [] }),
|
||||
spelling_menu_install: () => null,
|
||||
}),
|
||||
});
|
||||
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 page.getByRole("tab", { name, exact: true }).waitFor();
|
||||
}
|
||||
const selected = () => page.getByRole("tab", { selected: true }).getAttribute("data-path");
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText("tab-cycle", { exact: true }).waitFor();
|
||||
await open("a.md");
|
||||
await open("b.md");
|
||||
await page.locator(".cm-content").click();
|
||||
const before = await selected();
|
||||
await page.keyboard.press("Control+Tab");
|
||||
assert.notEqual(await selected(), before);
|
||||
await page.keyboard.press("Control+Shift+Tab");
|
||||
assert.equal(await selected(), before);
|
||||
console.log("PASS: Ctrl+Tab and Ctrl+Shift+Tab cycle working tabs");
|
||||
});
|
||||
@@ -1,17 +1,9 @@
|
||||
import { createRequire } from "node:module";
|
||||
// The last tab becomes a new tab, compact tab widths, site icons, mixed file and plugin tabs, close actions, plugin disable, and secondary windows.
|
||||
// @known-issue Without a workspace, plugin tabs cannot be dragged to reorder: they are native-draggable but get no drag data (Workbench.svelte workingTabDragData).
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { mockTauri, openPage, outputDir, runSmoke, settle as settleFrames, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const context = await browser.newContext({ viewport: { width: 1440, height: 1000 } });
|
||||
const page = await context.newPage();
|
||||
await context.exposeBinding("settingsHostInvoke", (_source, command, args) =>
|
||||
page.evaluate(({ command, args }) => window.__TAURI_INTERNALS__.invoke(command, args), { command, args }));
|
||||
page.setDefaultTimeout(10000);
|
||||
const errors = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
const pluginCode = `export function activate(api) {
|
||||
window.tabTest.api = api;
|
||||
const mount = (id, container) => {
|
||||
@@ -33,90 +25,84 @@ const pluginCode = `export function activate(api) {
|
||||
mount: (container, document) => mount(document.id, container),
|
||||
});
|
||||
}`;
|
||||
await context.addInitScript(({ pluginCode }) => {
|
||||
window.isTauri = true;
|
||||
localStorage.setItem("runestone.settings", JSON.stringify({ autosaveEnabled: false, autosaveSeconds: 5 }));
|
||||
const root = "C:\\plugin-tab-workspace";
|
||||
const files = new Map(["a.md", "b.md", "c.md", ...Array.from({ length: 14 }, (_, index) => `note-${index}.md`)].map(name => [name, `# ${name}\n\nOriginal text.\n`]));
|
||||
files.set("project.board", "project-board");
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
let sequence = 0, enabled = true;
|
||||
const manifest = { schemaVersion: 1, id: "test.tabs", name: "Tab fixtures", author: "Tests", description: "Test editor tabs.", version: "1.0.0", apiVersion: 1, entry: "main.js", access: "full-app" };
|
||||
const emit = async (event, payload) => {
|
||||
await Promise.all((listeners.get(event) || []).map(id => callbacks.get(id)?.({ event, id, payload })));
|
||||
};
|
||||
window.tabTest = { mounts: {}, disposals: {}, answer: "Cancel", prompts: 0, closeRequests: 0, destroys: 0, files };
|
||||
const label = location.search.includes("secondary") ? "workspace-2" : "main";
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label }, currentWebview: { label } },
|
||||
transformCallback: callback => { const id = ++sequence; callbacks.set(id, callback); return id; },
|
||||
unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (location.search.includes("settingsWindow") && !command.startsWith("plugin:event|") && !command.startsWith("plugin:window|"))
|
||||
return window.settingsHostInvoke(command, args);
|
||||
if (command === "settings_open_window") return;
|
||||
if (command === "plugin:event|listen") {
|
||||
const ids = listeners.get(args.event) || []; ids.push(args.handler); listeners.set(args.event, ids); return args.handler;
|
||||
}
|
||||
if (command === "plugin:event|unlisten") { callbacks.delete(args.eventId); return; }
|
||||
if (command === "plugin:window|is_maximized") return false;
|
||||
if (command === "plugin:window|close") {
|
||||
window.tabTest.closeRequests++;
|
||||
await emit("tauri://close-requested");
|
||||
return;
|
||||
}
|
||||
if (command === "plugin:window|destroy") { window.tabTest.destroys++; return; }
|
||||
if (command.startsWith("plugin:window|")) return;
|
||||
if (command === "plugins_snapshot") return { root, plugins: [{ manifest, hash: "test", enabled, path: root, error: null, removal: false }] };
|
||||
if (command === "plugins_load") return pluginCode;
|
||||
if (command === "plugins_data") return "null";
|
||||
if (command === "plugins_release") return;
|
||||
if (command === "plugins_set_enabled") { enabled = args.enabled; emit("plugins-changed"); return; }
|
||||
if (command === "workspace_last_path") return location.search.includes("no-workspace") ? null : root;
|
||||
if (command === "workspace_open") return { root, name: "plugin-tab-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_write") { files.set(args.rel, args.contents); return; }
|
||||
if (command === "workspace_list") return args.rel ? [] : [...files.keys()].map(name => ({ name, rel_path: name, kind: "file" }));
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "plugin:dialog|message") { window.tabTest.prompts++; return window.tabTest.answer; }
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
|
||||
// `?secondary` loads a secondary window. `?settingsWindow` loads the settings window, which sends its commands to the main page.
|
||||
function windowRoles(context) {
|
||||
return context.addInitScript(() => {
|
||||
const internals = window.__TAURI_INTERNALS__;
|
||||
if (location.search.includes("secondary")) internals.metadata = { currentWindow: { label: "workspace-2" }, currentWebview: { label: "workspace-2" } };
|
||||
if (!location.search.includes("settingsWindow")) return;
|
||||
const { invoke } = internals;
|
||||
internals.invoke = (command, args = {}) => command.startsWith("plugin:event|") || command.startsWith("plugin:window|")
|
||||
? invoke(command, args)
|
||||
: window.settingsHostInvoke(command, args);
|
||||
});
|
||||
}
|
||||
|
||||
await runSmoke("tabs/lastTabAndSiteIcons", async ({ browser }) => {
|
||||
const output = await outputDir("tabs/lastTabAndSiteIcons");
|
||||
const context = await browser.newContext({ viewport: { width: 1440, height: 1000 } });
|
||||
await mockTauri(context, {
|
||||
state: { pluginCode },
|
||||
commands: test => {
|
||||
localStorage.setItem("runestone.settings", JSON.stringify({ autosaveEnabled: false, autosaveSeconds: 5 }));
|
||||
const root = "C:\\plugin-tab-workspace";
|
||||
const files = Object.fromEntries(["a.md", "b.md", "c.md", ...Array.from({ length: 14 }, (_, index) => `note-${index}.md`)].map(name => [name, `# ${name}\n\nOriginal text.\n`]));
|
||||
files["project.board"] = "project-board";
|
||||
const manifest = { schemaVersion: 1, id: "test.tabs", name: "Tab fixtures", author: "Tests", description: "Test editor tabs.", version: "1.0.0", apiVersion: 1, entry: "main.js", access: "full-app" };
|
||||
let enabled = true;
|
||||
window.tabTest = { mounts: {}, disposals: {}, answer: "Cancel", prompts: 0, closeRequests: 0, destroys: 0 };
|
||||
const workspace = test.workspace({ root, files });
|
||||
return {
|
||||
...workspace,
|
||||
workspace_last_path: () => location.search.includes("no-workspace") ? null : root,
|
||||
settings_open_window: () => null,
|
||||
"plugin:window|is_maximized": () => false,
|
||||
"plugin:window|close": () => { window.tabTest.closeRequests++; test.emit("tauri://close-requested"); },
|
||||
"plugin:window|destroy": () => { window.tabTest.destroys++; },
|
||||
"plugin:dialog|message": () => { window.tabTest.prompts++; return window.tabTest.answer; },
|
||||
plugins_snapshot: () => ({ root, plugins: [{ manifest, hash: "test", enabled, path: root, error: null, removal: false }] }),
|
||||
plugins_load: () => test.state.pluginCode,
|
||||
plugins_release: () => null,
|
||||
plugins_set_enabled: args => { enabled = args.enabled; test.emit("plugins-changed"); },
|
||||
};
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: (_event, id) => callbacks.delete(id) };
|
||||
}, { pluginCode });
|
||||
});
|
||||
await windowRoles(context);
|
||||
const page = await openPage(context);
|
||||
const pages = [page];
|
||||
await context.exposeBinding("settingsHostInvoke", (_source, command, args) =>
|
||||
page.evaluate(({ command, args }) => window.__TAURI_INTERNALS__.invoke(command, args), { command, args }));
|
||||
const tab = name => page.getByRole("tab", { name, exact: true });
|
||||
const bar = page.getByRole("tablist", { name: "Working tabs" });
|
||||
const order = () => bar.getByRole("tab").evaluateAll(nodes => nodes.map(node => node.textContent.trim()));
|
||||
const settle = () => settleFrames(page);
|
||||
async function openFile(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 settle();
|
||||
}
|
||||
async function openView(name) {
|
||||
await page.getByRole("navigation", { name: "Plugin shortcuts" }).getByRole("button", { name, exact: true }).click();
|
||||
await tab(name).waitFor();
|
||||
}
|
||||
async function drag(from, to, side = "before", cancel) {
|
||||
const source = await tab(from).boundingBox(), target = await tab(to).boundingBox();
|
||||
await page.mouse.move(source.x + source.width / 2, source.y + source.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(side === "before" ? target.x + 2 : target.x + target.width - 2, target.y + target.height / 2, { steps: 10 });
|
||||
if (cancel === "escape") await page.keyboard.press("Escape");
|
||||
if (cancel === "outside") await page.mouse.move(target.x, target.y + 100);
|
||||
await page.mouse.up();
|
||||
await settle();
|
||||
}
|
||||
async function menu(name) {
|
||||
await tab(name).click({ button: "right" });
|
||||
await page.getByRole("menu", { name: "Tab actions" }).waitFor();
|
||||
}
|
||||
|
||||
const tab = name => page.getByRole("tab", { name, exact: true });
|
||||
const bar = page.getByRole("tablist", { name: "Working tabs" });
|
||||
const order = () => bar.getByRole("tab").evaluateAll(nodes => nodes.map(node => node.textContent.trim()));
|
||||
const settle = () => page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||
async function openFile(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 settle();
|
||||
}
|
||||
async function openView(name) {
|
||||
await page.getByRole("navigation", { name: "Plugin shortcuts" }).getByRole("button", { name, exact: true }).click();
|
||||
await tab(name).waitFor();
|
||||
}
|
||||
async function drag(from, to, side = "before", cancel) {
|
||||
const source = await tab(from).boundingBox(), target = await tab(to).boundingBox();
|
||||
await page.mouse.move(source.x + source.width / 2, source.y + source.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(side === "before" ? target.x + 2 : target.x + target.width - 2, target.y + target.height / 2, { steps: 10 });
|
||||
if (cancel === "escape") await page.keyboard.press("Escape");
|
||||
if (cancel === "outside") await page.mouse.move(target.x, target.y + 100);
|
||||
await page.mouse.up();
|
||||
await settle();
|
||||
}
|
||||
async function menu(name) {
|
||||
await tab(name).click({ button: "right" });
|
||||
await page.getByRole("menu", { name: "Tab actions" }).waitFor();
|
||||
}
|
||||
|
||||
try {
|
||||
const url = process.env.SMOKE_URL || "http://127.0.0.1:1420";
|
||||
await page.goto(url);
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText("plugin-tab-workspace", { exact: true }).waitFor();
|
||||
await tab("New tab").waitFor();
|
||||
for (const close of ["button", "middle", "shortcut", "all"]) {
|
||||
@@ -165,8 +151,7 @@ try {
|
||||
await plus.focus();
|
||||
await page.locator('[role="tooltip"]:popover-open').filter({ hasText: "New tab (Ctrl T)" }).waitFor();
|
||||
await page.keyboard.press("Escape");
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.locator(".header").screenshot({ path: `.audit/compact-tabs-${width}-${theme}.png` });
|
||||
await page.locator(".header").screenshot({ path: path.join(output, `compact-tabs-${width}-${theme}.png`) });
|
||||
}
|
||||
}
|
||||
await menu("note-0.md");
|
||||
@@ -187,8 +172,7 @@ try {
|
||||
assert.equal(await tab("Browser").locator("img").getAttribute("draggable"), "false");
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await page.evaluate(theme => document.documentElement.dataset.theme = theme, theme);
|
||||
await mkdir("output", { recursive: true });
|
||||
await page.locator(".header").screenshot({ path: `output/tab-site-icon-${theme}.png` });
|
||||
await page.locator(".header").screenshot({ path: path.join(output, `site-icon-${theme}.png`) });
|
||||
}
|
||||
await page.evaluate(() => window.tabTest.api.updateViewIcon("browser", "data:image/png;base64,aW1hZ2U="));
|
||||
await tab("Browser").locator("img").waitFor({ state: "detached" });
|
||||
@@ -274,6 +258,9 @@ try {
|
||||
const bar = document.querySelector('[aria-label="Working tabs"]');
|
||||
return bar.scrollLeft >= bar.scrollWidth - bar.clientWidth - 2;
|
||||
});
|
||||
// Native drag needs a fresh pointer event after the strip scrolls beneath it, as in tabs/order.
|
||||
await page.mouse.move(bounds.x + bounds.width - 4, source.y + source.height / 2);
|
||||
await page.mouse.move(bounds.x + bounds.width - 3, source.y + source.height / 2);
|
||||
await page.mouse.up();
|
||||
await settle();
|
||||
assert.equal((await order()).at(-1), "Overview");
|
||||
@@ -283,9 +270,9 @@ try {
|
||||
assert.equal((await order())[0], "c.md");
|
||||
const fileOrder = (await order()).filter(name => name !== "Overview");
|
||||
await page.keyboard.press("Control+,");
|
||||
const settingsPage = await context.newPage();
|
||||
settingsPage.on("pageerror", error => errors.push(error.message));
|
||||
await settingsPage.goto(url + '/?settingsWindow=true');
|
||||
const settingsPage = await openPage(context);
|
||||
pages.push(settingsPage);
|
||||
await settingsPage.goto(smokeUrl + '/?settingsWindow=true');
|
||||
await settingsPage.getByRole("button", { name: "Plug-ins", exact: true }).click();
|
||||
await settingsPage.getByRole("switch", { name: "Tab fixtures", exact: true }).click();
|
||||
await settingsPage.waitForFunction(() => document.getElementById("external-test.tabs")?.checked === false);
|
||||
@@ -294,7 +281,7 @@ try {
|
||||
console.log("PASS: plugin drag auto-scroll, empty-tab replacement, and plugin disable preserve the mixed order");
|
||||
await settingsPage.close();
|
||||
|
||||
await page.goto(`${url}?no-workspace`);
|
||||
await page.goto(`${smokeUrl}?no-workspace`);
|
||||
await tab("New tab").waitFor();
|
||||
await openView("Overview");
|
||||
await page.getByRole("button", { name: "Close New tab", exact: true }).click();
|
||||
@@ -302,17 +289,16 @@ try {
|
||||
await drag("Browser", "Overview");
|
||||
assert.deepEqual(await order(), ["Browser", "Overview"]);
|
||||
await page.setViewportSize({ width: 880, height: 700 });
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.screenshot({ path: ".audit/plugin-tab-order.png" });
|
||||
await page.screenshot({ path: path.join(output, "plugin-tab-order.png") });
|
||||
await tab("Browser").click({ button: "middle" });
|
||||
assert.deepEqual(await order(), ["Overview"]);
|
||||
await page.getByRole("button", { name: "Close Overview", exact: true }).click();
|
||||
await tab("New tab").waitFor();
|
||||
assert.deepEqual(await order(), ["New tab"]);
|
||||
assert.deepEqual(errors, []);
|
||||
assert.deepEqual(pages.flatMap(page => page.errors), []);
|
||||
console.log("PASS: plugin tabs reorder and close without an open workspace");
|
||||
for (const close of ["button", "middle", "shortcut", "all", "plugin", "dirty"]) {
|
||||
await page.goto(`${url}?secondary`);
|
||||
await page.goto(`${smokeUrl}?secondary`);
|
||||
await tab("New tab").waitFor();
|
||||
if (close === "plugin") {
|
||||
await openView("Overview");
|
||||
@@ -326,8 +312,7 @@ try {
|
||||
await page.waitForFunction(() => window.tabTest.prompts === 1);
|
||||
assert.equal(await page.evaluate(() => window.tabTest.destroys), 0);
|
||||
assert.match(await page.locator(".cm-content").innerText(), /Keep these unsaved edits/);
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.screenshot({ path: ".audit/secondary-last-tab-cancel.png" });
|
||||
await page.screenshot({ path: path.join(output, "secondary-last-tab-cancel.png") });
|
||||
await page.evaluate(() => window.tabTest.answer = "Ok");
|
||||
await page.keyboard.press("Control+w");
|
||||
} else if (close === "button") {
|
||||
@@ -345,13 +330,6 @@ try {
|
||||
await page.waitForFunction(() => window.tabTest.destroys === 1);
|
||||
assert.equal(await page.evaluate(() => window.tabTest.closeRequests), close === "dirty" ? 2 : 1);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
assert.deepEqual(pages.flatMap(page => page.errors), []);
|
||||
console.log("PASS: secondary windows close through the window guard for the last empty, document, or plugin tab; Cancel preserves unsaved edits");
|
||||
} catch (error) {
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.screenshot({ path: ".audit/plugin-tab-order-failure.png" });
|
||||
console.error("Browser errors:", errors);
|
||||
throw error;
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { createRequire } from "node:module";
|
||||
// Tab sessions: restore after a normal close, missing files, cancelled closes, plugin documents, and plugin tab transfers between windows and workspaces.
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const context = await browser.newContext({ viewport: { width: 1400, height: 900 } });
|
||||
import path from "node:path";
|
||||
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const pluginCode = `export function activate(api) {
|
||||
let state = "Board state";
|
||||
api.registerView({ id: "board", title: "Board", icon: "kanban", placement: "editor", navigation: true,
|
||||
@@ -20,122 +18,129 @@ const pluginCode = `export function activate(api) {
|
||||
mount(container) { container.textContent = "Saved board document"; return () => { container.textContent = ""; }; }
|
||||
});
|
||||
}`;
|
||||
await context.addInitScript(({ pluginCode }) => {
|
||||
window.isTauri = true;
|
||||
localStorage.setItem("runestone.settings", JSON.stringify({ autosaveEnabled: false }));
|
||||
const params = new URLSearchParams(location.search);
|
||||
const root = params.has("other") ? "C:\\other-lifecycle" : params.has("plugins") ? "C:\\plugins-lifecycle" : "C:\\document-lifecycle";
|
||||
const files = new Map(["a.md", "b.md", "c.md"].map(name => [name, `# ${name}\n\nSaved text.\n`]));
|
||||
files.set("saved.board", "board document");
|
||||
if (params.has("missing")) files.delete("a.md");
|
||||
let sequence = 0;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
const emit = async event => { for (const id of listeners.get(event) || []) await callbacks.get(id)?.({ event, id, payload: null }); };
|
||||
window.lifecycle = { answer: "Cancel", close: () => emit("tauri://close-requested"), root, transfer: null };
|
||||
const manifest = { schemaVersion: 1, id: "test.lifecycle", name: "Lifecycle", author: "Tests", description: "Tab fixture", version: "1.0.0", apiVersion: 1, entry: "main.js", access: "full-app" };
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: fn => { const id = ++sequence; callbacks.set(id, fn); return id; },
|
||||
unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") { const ids = listeners.get(args.event) || []; ids.push(args.handler); listeners.set(args.event, ids); return args.handler; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("plugin:window|")) return;
|
||||
if (command === "plugin:dialog|message") return window.lifecycle.answer;
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "Lifecycle", watch_mode: "native" };
|
||||
if (command === "workspace_open_window") { window.lifecycle.transfer = args.transfer; return; }
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("Missing file"); return files.get(args.rel); }
|
||||
if (command === "workspace_list") return args.rel ? [] : [...files.keys()].map(name => ({ name, rel_path: name, kind: "file" }));
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "plugins_snapshot") return { root, plugins: params.has("disabled") ? [] : [{ manifest, hash: "test", enabled: true, path: root, error: null, removal: false }] };
|
||||
if (command === "plugins_load") return pluginCode;
|
||||
if (command === "plugins_data") return "null";
|
||||
if (command === "plugins_release") return;
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
}, { pluginCode });
|
||||
const url = process.env.SMOKE_URL || "http://127.0.0.1:1420";
|
||||
const errors = [];
|
||||
const dragSources = new Map();
|
||||
const tab = (page, name) => page.getByRole("tab", { name, exact: true });
|
||||
const bar = page => page.getByRole("tablist", { name: "Working tabs" });
|
||||
async function create(query = "") {
|
||||
const page = await context.newPage(); page.setDefaultTimeout(15000);
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.goto(url + query); await page.getByRole("tab").first().waitFor(); return page;
|
||||
}
|
||||
async function open(page, name) {
|
||||
await page.bringToFront(); 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(page, name === "saved.board" ? "saved" : name).waitFor();
|
||||
}
|
||||
async function openBoard(page) {
|
||||
await page.getByRole("navigation", { name: "Plugin shortcuts" }).getByRole("button", { name: "Board", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "Board state" }).waitFor();
|
||||
}
|
||||
async function pin(page, name) {
|
||||
await tab(page, name).click({ button: "right" }); await page.getByRole("menuitem", { name: "Pin", exact: true }).click();
|
||||
}
|
||||
async function start(page, name) {
|
||||
const data = await tab(page, name).evaluate(node => {
|
||||
assertDraggable(node);
|
||||
function assertDraggable(node) { if (node.getAttribute("draggable") !== "true") throw new Error("The tab must support native transfer."); }
|
||||
const transfer = new DataTransfer(); node.dispatchEvent(new DragEvent("dragstart", { bubbles: true, dataTransfer: transfer }));
|
||||
return transfer.getData("application/x-runestone-tab");
|
||||
|
||||
// `window.requestClose()` sends the native close request and waits for the async close guard, which the harness emit does not await.
|
||||
function closeRequests(target) {
|
||||
return target.addInitScript(() => {
|
||||
const internals = window.__TAURI_INTERNALS__;
|
||||
const { transformCallback, invoke } = internals;
|
||||
const callbacks = new Map(), handlers = [];
|
||||
internals.transformCallback = (callback, once) => { const id = transformCallback(callback, once); callbacks.set(id, callback); return id; };
|
||||
internals.invoke = (command, args = {}) => {
|
||||
if (command === "plugin:event|listen" && args.event === "tauri://close-requested") handlers.push(args.handler);
|
||||
return invoke(command, args);
|
||||
};
|
||||
window.requestClose = async () => {
|
||||
for (const id of handlers) await callbacks.get(id)?.({ event: "tauri://close-requested", id, payload: null });
|
||||
};
|
||||
});
|
||||
dragSources.set(data, { page, name });
|
||||
return data;
|
||||
}
|
||||
async function drop(page, data) {
|
||||
await bar(page).evaluate((node, data) => {
|
||||
const transfer = new DataTransfer(); transfer.setData("application/x-runestone-tab", data);
|
||||
const options = { bubbles: true, cancelable: true, clientX: node.getBoundingClientRect().left, dataTransfer: transfer };
|
||||
node.dispatchEvent(new DragEvent("dragover", options)); node.dispatchEvent(new DragEvent("drop", options));
|
||||
}, data);
|
||||
const source = dragSources.get(data);
|
||||
if (source) {
|
||||
await tab(source.page, source.name).evaluateAll(nodes => nodes[0]?.dispatchEvent(new DragEvent("dragend", { bubbles: true })));
|
||||
|
||||
await runSmoke("tabs/lifecycle", async ({ browser }) => {
|
||||
const output = await outputDir("tabs/lifecycle");
|
||||
const context = await browser.newContext({ viewport: { width: 1400, height: 900 } });
|
||||
await mockTauri(context, {
|
||||
state: { pluginCode },
|
||||
commands: test => {
|
||||
localStorage.setItem("runestone.settings", JSON.stringify({ autosaveEnabled: false }));
|
||||
const params = new URLSearchParams(location.search);
|
||||
const root = params.has("other") ? "C:\\other-lifecycle" : params.has("plugins") ? "C:\\plugins-lifecycle" : "C:\\document-lifecycle";
|
||||
const files = Object.fromEntries(["a.md", "b.md", "c.md"].map(name => [name, `# ${name}\n\nSaved text.\n`]));
|
||||
files["saved.board"] = "board document";
|
||||
if (params.has("missing")) delete files["a.md"];
|
||||
const manifest = { schemaVersion: 1, id: "test.lifecycle", name: "Lifecycle", author: "Tests", description: "Tab fixture", version: "1.0.0", apiVersion: 1, entry: "main.js", access: "full-app" };
|
||||
Object.assign(test, { answer: "Cancel", root, transfer: null });
|
||||
return {
|
||||
...test.workspace({ root, name: "Lifecycle", files }),
|
||||
"plugin:window|is_maximized": () => false,
|
||||
"plugin:window|destroy": () => null,
|
||||
"plugin:dialog|message": () => test.answer,
|
||||
workspace_open_window: ({ transfer }) => { test.transfer = transfer; },
|
||||
plugins_snapshot: () => ({ root, plugins: params.has("disabled") ? [] : [{ manifest, hash: "test", enabled: true, path: root, error: null, removal: false }] }),
|
||||
plugins_load: () => test.state.pluginCode,
|
||||
};
|
||||
},
|
||||
});
|
||||
await closeRequests(context);
|
||||
const pages = [];
|
||||
const dragSources = new Map();
|
||||
const tab = (page, name) => page.getByRole("tab", { name, exact: true });
|
||||
const bar = page => page.getByRole("tablist", { name: "Working tabs" });
|
||||
const session = page => page.evaluate(() => JSON.parse(localStorage.getItem(`runestone.document-session.${encodeURIComponent(window.__TEST__.root)}`)));
|
||||
async function create(query = "") {
|
||||
const page = await openPage(context, { timeout: 15000 });
|
||||
pages.push(page);
|
||||
await page.goto(smokeUrl + query); await page.getByRole("tab").first().waitFor(); return page;
|
||||
}
|
||||
}
|
||||
async function screenshots(page, prefix) {
|
||||
await mkdir("output/tab-lifecycle", { recursive: true });
|
||||
for (const mode of ["dark", "light"]) {
|
||||
await page.evaluate(async mode => { const { applyAppearance } = await import("/src/lib/theme/appearance.ts"); await applyAppearance({ theme: "default", mode }); }, mode);
|
||||
await page.screenshot({ path: `output/tab-lifecycle/${prefix}-${mode}.png` });
|
||||
async function open(page, name) {
|
||||
await page.bringToFront(); 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(page, name === "saved.board" ? "saved" : name).waitFor();
|
||||
}
|
||||
await page.setViewportSize({ width: 700, height: 700 });
|
||||
await page.screenshot({ path: `output/tab-lifecycle/${prefix}-narrow.png` });
|
||||
await page.setViewportSize({ width: 1400, height: 900 });
|
||||
}
|
||||
try {
|
||||
async function openBoard(page) {
|
||||
await page.getByRole("navigation", { name: "Plugin shortcuts" }).getByRole("button", { name: "Board", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "Board state" }).waitFor();
|
||||
}
|
||||
async function pin(page, name) {
|
||||
await tab(page, name).click({ button: "right" }); await page.getByRole("menuitem", { name: "Pin", exact: true }).click();
|
||||
}
|
||||
async function start(page, name) {
|
||||
const data = await tab(page, name).evaluate(node => {
|
||||
if (node.getAttribute("draggable") !== "true") throw new Error("The tab must support native transfer.");
|
||||
const transfer = new DataTransfer(); node.dispatchEvent(new DragEvent("dragstart", { bubbles: true, dataTransfer: transfer }));
|
||||
return transfer.getData("application/x-runestone-tab");
|
||||
});
|
||||
dragSources.set(data, { page, name });
|
||||
return data;
|
||||
}
|
||||
async function drop(page, data) {
|
||||
await bar(page).evaluate((node, data) => {
|
||||
const transfer = new DataTransfer(); transfer.setData("application/x-runestone-tab", data);
|
||||
const options = { bubbles: true, cancelable: true, clientX: node.getBoundingClientRect().left, dataTransfer: transfer };
|
||||
node.dispatchEvent(new DragEvent("dragover", options)); node.dispatchEvent(new DragEvent("drop", options));
|
||||
}, data);
|
||||
const source = dragSources.get(data);
|
||||
if (source) {
|
||||
await tab(source.page, source.name).evaluateAll(nodes => nodes[0]?.dispatchEvent(new DragEvent("dragend", { bubbles: true })));
|
||||
}
|
||||
}
|
||||
async function screenshots(page, prefix) {
|
||||
for (const mode of ["dark", "light"]) {
|
||||
await page.evaluate(async mode => { const { applyAppearance } = await import("/src/lib/theme/appearance.ts"); await applyAppearance({ theme: "default", mode }); }, mode);
|
||||
await page.screenshot({ path: path.join(output, `${prefix}-${mode}.png`) });
|
||||
}
|
||||
await page.setViewportSize({ width: 700, height: 700 });
|
||||
await page.screenshot({ path: path.join(output, `${prefix}-narrow.png`) });
|
||||
await page.setViewportSize({ width: 1400, height: 900 });
|
||||
}
|
||||
|
||||
const page = await create();
|
||||
for (const name of ["a.md", "b.md", "c.md"]) await open(page, name);
|
||||
await tab(page, "c.md").focus(); await page.keyboard.press("Alt+Shift+ArrowLeft"); await page.keyboard.press("Alt+Shift+ArrowLeft");
|
||||
await pin(page, "b.md"); await tab(page, "b.md").click();
|
||||
await page.evaluate(() => window.lifecycle.close());
|
||||
const session = await page.evaluate(() => JSON.parse(localStorage.getItem(`runestone.document-session.${encodeURIComponent(window.lifecycle.root)}`)));
|
||||
assert.deepEqual(session.documents.map(item => item.path), ["c.md", "a.md", "b.md"]);
|
||||
assert.equal(session.activePath, "b.md"); assert.equal(session.documents[2].pinned, true);
|
||||
assert.ok(!JSON.stringify(session).includes("Saved text"));
|
||||
await page.goto(url + "?missing"); await tab(page, "b.md").waitFor();
|
||||
await page.evaluate(() => window.requestClose());
|
||||
const saved = await session(page);
|
||||
assert.deepEqual(saved.documents.map(item => item.path), ["c.md", "a.md", "b.md"]);
|
||||
assert.equal(saved.activePath, "b.md"); assert.equal(saved.documents[2].pinned, true);
|
||||
assert.ok(!JSON.stringify(saved).includes("Saved text"));
|
||||
await page.goto(smokeUrl + "?missing"); await tab(page, "b.md").waitFor();
|
||||
assert.deepEqual(await bar(page).getByRole("tab").evaluateAll(nodes => nodes.map(node => node.dataset.path)), ["c.md", "b.md"]);
|
||||
assert.equal(await tab(page, "b.md").getAttribute("aria-selected"), "true");
|
||||
await tab(page, "b.md").click({ button: "right" }); await page.getByRole("menuitem", { name: "Unpin", exact: true }).waitFor(); await page.keyboard.press("Escape");
|
||||
await screenshots(page, "restored-documents");
|
||||
await page.locator(".cm-content").fill("Unsaved draft");
|
||||
await page.evaluate(() => window.lifecycle.close());
|
||||
assert.deepEqual(await page.evaluate(() => JSON.parse(localStorage.getItem(`runestone.document-session.${encodeURIComponent(window.lifecycle.root)}`))), session);
|
||||
await page.evaluate(() => { window.lifecycle.answer = "Ok"; return window.lifecycle.close(); });
|
||||
await page.evaluate(() => window.requestClose());
|
||||
assert.deepEqual(await session(page), saved);
|
||||
await page.evaluate(() => { window.__TEST__.answer = "Ok"; return window.requestClose(); });
|
||||
page.on("dialog", dialog => dialog.accept());
|
||||
await page.reload(); await tab(page, "b.md").waitFor();
|
||||
assert.match(await page.locator(".cm-content").innerText(), /Saved text/);
|
||||
await open(page, "saved.board"); await page.getByText("Saved board document", { exact: true }).waitFor();
|
||||
await page.evaluate(() => window.lifecycle.close()); await page.reload();
|
||||
await page.evaluate(() => window.requestClose()); await page.reload();
|
||||
await tab(page, "saved").waitFor(); await page.getByText("Saved board document", { exact: true }).waitFor();
|
||||
console.log("PASS: normal-close restore, order, active tab, pins, missing files, canceled close, disk-only restore, and plugin documents");
|
||||
|
||||
const source = await create("?plugins"), target = await create("?plugins"), other = await create("?other"), disabled = await create("?plugins&disabled");
|
||||
assert.equal(await tab(other, "New tab").count(), 1);
|
||||
await openBoard(source); await source.getByRole("textbox", { name: "Board state" }).fill("Transferred board state"); await pin(source, "Board");
|
||||
@@ -154,14 +159,11 @@ try {
|
||||
assert.equal(await target.getByRole("textbox", { name: "Board state" }).inputValue(), "Destination state"); assert.equal(await tab(source, "Board").count(), 1);
|
||||
await tab(source, "Board").evaluate(node => node.dispatchEvent(new DragEvent("dragend", { bubbles: true })));
|
||||
await tab(source, "Board").click({ button: "right" }); await source.getByRole("menuitem", { name: "Open in new window", exact: true }).click();
|
||||
const token = await source.evaluate(() => window.lifecycle.transfer); assert.ok(token);
|
||||
const token = await source.evaluate(() => window.__TEST__.transfer); assert.ok(token);
|
||||
const detached = await create(`?plugins&tabTransfer=${token}`); await detached.getByRole("textbox", { name: "Board state" }).waitFor();
|
||||
await tab(source, "Board").waitFor({ state: "detached" });
|
||||
data = await start(detached, "Board"); await drop(source, data); await tab(detached, "Board").waitFor({ state: "detached" });
|
||||
assert.equal(await source.getByRole("textbox", { name: "Board state" }).inputValue(), "Transferred board state");
|
||||
assert.deepEqual(errors, []);
|
||||
console.log("PASS: normal-close restore, order, active tab, pins, missing files, workspace isolation, canceled close, disk-only restore, plugin documents, plugin join, duplicate protection, disabled plugin, and tear-out return");
|
||||
} catch (reason) {
|
||||
for (const page of context.pages()) console.error(page.url(), (await page.locator("body").innerText()).slice(-1000));
|
||||
throw reason;
|
||||
} finally { await browser.close(); }
|
||||
assert.deepEqual(pages.flatMap(page => page.errors), []);
|
||||
console.log("PASS: workspace isolation, plugin join, duplicate protection, disabled plugin, and tear-out return");
|
||||
});
|
||||
|
||||
@@ -1,55 +1,36 @@
|
||||
import { createRequire } from "node:module";
|
||||
// Tab menus: active and inactive tabs, keyboard focus, pinning, view modes, file actions, ordered closes, cancelled discards, and empty tabs.
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(15000);
|
||||
const errors = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = "C:\\tab-menu-workspace";
|
||||
const files = new Map(["a.md", "b.md", "c.md", "d.md"].map(name => [name, `# ${name}\n\nOriginal text.\n`]));
|
||||
window.tabMenuTest = { prompts: [], answer: "Cancel", revealed: null, clipboard: null };
|
||||
Object.defineProperty(navigator, "clipboard", { value: { writeText: async text => { window.tabMenuTest.clipboard = text; } } });
|
||||
let sequence = 0;
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: () => ++sequence, unregisterCallback: () => {},
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") return ++sequence;
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "tab-menu-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_list") return args.rel ? [] : [...files.keys()].map(name => ({ name, rel_path: name, kind: "file" }));
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "workspace_write") throw new Error("Keep unsaved edits for the close test");
|
||||
if (command === "workspace_rename") { files.set(args.to, files.get(args.from)); files.delete(args.from); return; }
|
||||
if (command === "workspace_abs_path") return `${root}\\${args.rel}`;
|
||||
if (command === "workspace_reveal") { window.tabMenuTest.revealed = args.rel; return; }
|
||||
if (command === "plugin:dialog|message") { window.tabMenuTest.prompts.push(args.message); return window.tabMenuTest.answer; }
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("tabs/menus", async ({ page }) => {
|
||||
const output = await outputDir("tabs/menus");
|
||||
await mockTauri(page, {
|
||||
commands: test => {
|
||||
test.prompts = [];
|
||||
test.answer = "Cancel";
|
||||
Object.defineProperty(navigator, "clipboard", { value: { writeText: async text => { test.clipboard = text; } } });
|
||||
return {
|
||||
...test.workspace({ root: "C:\\tab-menu-workspace", files: Object.fromEntries(["a.md", "b.md", "c.md", "d.md"].map(name => [name, `# ${name}\n\nOriginal text.\n`])) }),
|
||||
workspace_write: () => { throw new Error("Keep unsaved edits for the close test"); },
|
||||
workspace_reveal: ({ rel }) => { test.revealed = rel; },
|
||||
"plugin:dialog|message": ({ message }) => { test.prompts.push(message); return test.answer; },
|
||||
};
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
const tab = name => page.getByRole("tab", { name, exact: true });
|
||||
const menu = () => page.getByRole("menu", { name: "Tab actions", exact: true });
|
||||
const item = name => page.getByRole("menuitem", { name, exact: true });
|
||||
const order = () => page.getByRole("tab").evaluateAll(nodes => nodes.map(node => node.dataset.path));
|
||||
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();
|
||||
}
|
||||
async function show(name) { await tab(name).click({ button: "right" }); await menu().waitFor(); }
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || "http://127.0.0.1:1420");
|
||||
});
|
||||
const tab = name => page.getByRole("tab", { name, exact: true });
|
||||
const menu = () => page.getByRole("menu", { name: "Tab actions", exact: true });
|
||||
const item = name => page.getByRole("menuitem", { name, exact: true });
|
||||
const order = () => page.getByRole("tab").evaluateAll(nodes => nodes.map(node => node.dataset.path));
|
||||
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();
|
||||
}
|
||||
async function show(name) { await tab(name).click({ button: "right" }); await menu().waitFor(); }
|
||||
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText("tab-menu-workspace", { exact: true }).waitFor();
|
||||
for (const name of ["a.md", "b.md", "c.md", "d.md"]) await open(name);
|
||||
await page.locator(".cm-content").filter({ hasText: "Original text." }).waitFor();
|
||||
@@ -58,13 +39,13 @@ try {
|
||||
assert.equal(await item("Rename…").count(), 0);
|
||||
assert.equal(await item("Reading view").count(), 0);
|
||||
assert.doesNotMatch(await menu().innerText(), /Alt|Shift|Ctrl/);
|
||||
await page.screenshot({ path: ".audit/tab-menu-inactive.png" });
|
||||
await page.screenshot({ path: path.join(output, "inactive.png") });
|
||||
await item("Pin").click();
|
||||
assert.equal(await tab("d.md").getAttribute("aria-selected"), "true");
|
||||
assert.ok(await tab("b.md").getAttribute("aria-describedby"));
|
||||
await show("d.md");
|
||||
assert.equal(await item("Close tabs after").isDisabled(), true);
|
||||
await page.screenshot({ path: ".audit/tab-menu-active.png" });
|
||||
await page.screenshot({ path: path.join(output, "active.png") });
|
||||
await page.keyboard.press("Escape");
|
||||
assert.equal(await tab("d.md").evaluate(node => node === document.activeElement), true);
|
||||
await tab("d.md").press("Shift+F10");
|
||||
@@ -89,10 +70,10 @@ try {
|
||||
await show("d.md");
|
||||
await item("Copy path").click();
|
||||
await item("Workspace path").click();
|
||||
assert.equal(await page.evaluate(() => window.tabMenuTest.clipboard), "d.md");
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.clipboard), "d.md");
|
||||
await show("d.md");
|
||||
await item("Show in system explorer").click();
|
||||
assert.equal(await page.evaluate(() => window.tabMenuTest.revealed), "d.md");
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.revealed), "d.md");
|
||||
await show("d.md");
|
||||
await item("Rename…").click();
|
||||
await page.getByRole("dialog").getByRole("textbox").fill("renamed.md");
|
||||
@@ -113,9 +94,9 @@ try {
|
||||
await tab("c.md •").waitFor();
|
||||
await show("c.md •");
|
||||
await item("Close all").click();
|
||||
await page.waitForFunction(() => window.tabMenuTest.prompts.length === 1);
|
||||
await page.waitForFunction(() => window.__TEST__.prompts.length === 1);
|
||||
assert.deepEqual(await order(), ["b.md", "c.md"]);
|
||||
await page.evaluate(() => { window.tabMenuTest.answer = "Ok"; });
|
||||
await page.evaluate(() => { window.__TEST__.answer = "Ok"; });
|
||||
await show("c.md •");
|
||||
await item("Close all").click();
|
||||
await tab("c.md •").waitFor({ state: "detached" });
|
||||
@@ -126,14 +107,14 @@ try {
|
||||
await show("b.md");
|
||||
await item("Close").click();
|
||||
await tab("b.md").waitFor({ state: "detached" });
|
||||
// Closing the last tab leaves an empty tab (src/lib/layout/Workbench.svelte:291), so the plus button adds a second one.
|
||||
await tab("New tab").waitFor();
|
||||
await page.getByRole("button", { name: "New tab (Ctrl T)", exact: true }).click();
|
||||
await show("New tab");
|
||||
const added = page.getByRole("tab", { name: "New tab", exact: true, selected: true });
|
||||
await page.waitForFunction(() => document.querySelectorAll('[role="tab"][data-path^="empty:"]').length === 2);
|
||||
await added.click({ button: "right" });
|
||||
await menu().waitFor();
|
||||
assert.equal(await item("Rename…").count(), 0);
|
||||
assert.equal(await item("Reading view").count(), 0);
|
||||
await page.keyboard.press("Escape");
|
||||
assert.deepEqual(errors, []);
|
||||
console.log("PASS: active/inactive menus, keyboard focus, pinning, view modes, file actions, ordered closes, cancelled discard, and empty tabs");
|
||||
} catch (error) {
|
||||
await page.screenshot({ path: ".audit/tab-menu-failure.png" });
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
}, { timeout: 15000 });
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { createRequire } from "node:module";
|
||||
// Tab drops on the titlebar ribbon: broad and nearby targets, exact ordering, rejected areas, ordinary drags, pinned unsaved documents, and plugin tabs.
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const context = await browser.newContext({ viewport: { width: 1400, height: 900 } });
|
||||
import path from "node:path";
|
||||
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const pluginCode = `export function activate(api) {
|
||||
let state = "Board state";
|
||||
api.registerView({ id: "board", title: "Board", icon: "kanban", placement: "editor", navigation: true,
|
||||
@@ -15,119 +13,95 @@ const pluginCode = `export function activate(api) {
|
||||
return () => input.remove();
|
||||
}
|
||||
});
|
||||
api.registerDocumentType({ id: "document", title: "Board document", extensions: ["board"], icon: "kanban",
|
||||
identify: (path, source) => source === "board document" ? { id: path } : null,
|
||||
mount(container) { container.textContent = "Saved board document"; return () => { container.textContent = ""; }; }
|
||||
});
|
||||
}`;
|
||||
await context.addInitScript(({ pluginCode }) => {
|
||||
window.isTauri = true;
|
||||
localStorage.setItem("runestone.settings", JSON.stringify({ autosaveEnabled: false }));
|
||||
const params = new URLSearchParams(location.search);
|
||||
const root = params.has("other") ? "C:\\other-lifecycle" : params.has("plugins") ? "C:\\plugins-lifecycle" : "C:\\document-lifecycle";
|
||||
const files = new Map(["a.md", "b.md", "c.md"].map(name => [name, `# ${name}\n\nSaved text.\n`]));
|
||||
files.set("saved.board", "board document");
|
||||
if (params.has("missing")) files.delete("a.md");
|
||||
let sequence = 0;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
const emit = async event => { for (const id of listeners.get(event) || []) await callbacks.get(id)?.({ event, id, payload: null }); };
|
||||
window.lifecycle = { answer: "Cancel", close: () => emit("tauri://close-requested"), root, transfer: null };
|
||||
const manifest = { schemaVersion: 1, id: "test.lifecycle", name: "Lifecycle", author: "Tests", description: "Tab fixture", version: "1.0.0", apiVersion: 1, entry: "main.js", access: "full-app" };
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: fn => { const id = ++sequence; callbacks.set(id, fn); return id; },
|
||||
unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") { const ids = listeners.get(args.event) || []; ids.push(args.handler); listeners.set(args.event, ids); return args.handler; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("plugin:window|")) return;
|
||||
if (command === "plugin:dialog|message") return window.lifecycle.answer;
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "Lifecycle", watch_mode: "native" };
|
||||
if (command === "workspace_open_window") { window.lifecycle.transfer = args.transfer; return; }
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("Missing file"); return files.get(args.rel); }
|
||||
if (command === "workspace_list") return args.rel ? [] : [...files.keys()].map(name => ({ name, rel_path: name, kind: "file" }));
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "plugins_snapshot") return { root, plugins: params.has("disabled") ? [] : [{ manifest, hash: "test", enabled: true, path: root, error: null, removal: false }] };
|
||||
if (command === "plugins_load") return pluginCode;
|
||||
if (command === "plugins_data") return "null";
|
||||
if (command === "plugins_release") return;
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
|
||||
await runSmoke("tabs/ribbonDrop", async ({ browser }) => {
|
||||
const output = await outputDir("tabs/ribbonDrop");
|
||||
const context = await browser.newContext({ viewport: { width: 1400, height: 900 } });
|
||||
await mockTauri(context, {
|
||||
state: { pluginCode },
|
||||
commands: test => {
|
||||
localStorage.setItem("runestone.settings", JSON.stringify({ autosaveEnabled: false }));
|
||||
const root = "C:\\plugins-lifecycle";
|
||||
const manifest = { schemaVersion: 1, id: "test.lifecycle", name: "Lifecycle", author: "Tests", description: "Tab fixture", version: "1.0.0", apiVersion: 1, entry: "main.js", access: "full-app" };
|
||||
return {
|
||||
...test.workspace({ root, name: "Lifecycle", files: Object.fromEntries(["a.md", "b.md", "c.md"].map(name => [name, `# ${name}\n\nSaved text.\n`])) }),
|
||||
"plugin:window|is_maximized": () => false,
|
||||
plugins_snapshot: () => ({ root, plugins: [{ manifest, hash: "test", enabled: true, path: root, error: null, removal: false }] }),
|
||||
plugins_load: () => test.state.pluginCode,
|
||||
};
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
}, { pluginCode });
|
||||
const url = process.env.SMOKE_URL || "http://127.0.0.1:1420";
|
||||
const errors = [];
|
||||
const tab = (page, name) => page.getByRole("tab", { name, exact: true });
|
||||
const bar = page => page.getByRole("tablist", { name: "Working tabs" });
|
||||
async function create(query = "") {
|
||||
const page = await context.newPage(); page.setDefaultTimeout(15000);
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.goto(url + query); await page.getByRole("tab").first().waitFor(); return page;
|
||||
}
|
||||
async function open(page, name) {
|
||||
await page.bringToFront(); 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(page, name === "saved.board" ? "saved" : name).waitFor();
|
||||
}
|
||||
async function openBoard(page) {
|
||||
await page.getByRole("navigation", { name: "Plugin shortcuts" }).getByRole("button", { name: "Board", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "Board state" }).waitFor();
|
||||
}
|
||||
async function pin(page, name) {
|
||||
await tab(page, name).click({ button: "right" }); await page.getByRole("menuitem", { name: "Pin", exact: true }).click();
|
||||
}
|
||||
async function start(page, name) {
|
||||
const data = await tab(page, name).evaluate(node => {
|
||||
assertDraggable(node);
|
||||
function assertDraggable(node) { if (node.getAttribute("draggable") !== "true") throw new Error("The tab must support native transfer."); }
|
||||
const transfer = new DataTransfer(); node.dispatchEvent(new DragEvent("dragstart", { bubbles: true, dataTransfer: transfer }));
|
||||
return transfer.getData("application/x-runestone-tab");
|
||||
});
|
||||
return data;
|
||||
}
|
||||
async function screenshots(page, prefix) {
|
||||
await mkdir("output/tab-ribbon-drop", { recursive: true });
|
||||
for (const mode of ["dark", "light"]) {
|
||||
await page.evaluate(async mode => { const { applyAppearance } = await import("/src/lib/theme/appearance.ts"); await applyAppearance({ theme: "default", mode }); }, mode);
|
||||
await page.screenshot({ path: `output/tab-ribbon-drop/${prefix}-${mode}.png` });
|
||||
const pages = [];
|
||||
const tab = (page, name) => page.getByRole("tab", { name, exact: true });
|
||||
const bar = page => page.getByRole("tablist", { name: "Working tabs" });
|
||||
const order = page => bar(page).getByRole("tab").evaluateAll(nodes => nodes.map(node => node.textContent.trim()));
|
||||
async function create() {
|
||||
const page = await openPage(context, { timeout: 15000 });
|
||||
pages.push(page);
|
||||
await page.goto(smokeUrl + "?plugins"); await page.getByRole("tab").first().waitFor(); return page;
|
||||
}
|
||||
await page.setViewportSize({ width: 700, height: 700 });
|
||||
await page.screenshot({ path: `output/tab-ribbon-drop/${prefix}-narrow.png` });
|
||||
await page.setViewportSize({ width: 1400, height: 900 });
|
||||
}
|
||||
const order = page => bar(page).getByRole("tab").evaluateAll(nodes => nodes.map(node => node.textContent.trim()));
|
||||
async function eventAt(page, data, point, type = "dragover", mime = "application/x-runestone-tab") {
|
||||
return page.evaluate(({ data, point, type, mime }) => {
|
||||
const transfer = new DataTransfer(); transfer.setData(mime, data);
|
||||
const node = document.elementFromPoint(point.x, point.y) || document.body;
|
||||
const event = new DragEvent(type, { bubbles: true, cancelable: true, clientX: point.x, clientY: point.y, dataTransfer: transfer });
|
||||
node.dispatchEvent(event);
|
||||
return event.defaultPrevented;
|
||||
}, { data, point, type, mime });
|
||||
}
|
||||
async function receive(page, data, point) {
|
||||
assert.equal(await eventAt(page, data, point), true);
|
||||
assert.equal(await eventAt(page, data, point, "drop"), true);
|
||||
}
|
||||
async function point(page, kind) {
|
||||
return page.locator(".header").evaluate((header, kind) => {
|
||||
const bounds = header.getBoundingClientRect();
|
||||
const bar = header.querySelector('[role="tablist"]').getBoundingClientRect();
|
||||
const plus = header.querySelector('[aria-label="New tab (Ctrl T)"]').getBoundingClientRect();
|
||||
const first = header.querySelector('.tab').getBoundingClientRect();
|
||||
if (kind === "near") return { x: first.left + first.width / 2, y: bounds.bottom + 18 };
|
||||
if (kind === "outside") return { x: first.left + first.width / 2, y: bounds.bottom + 80 };
|
||||
if (kind === "precise") return { x: bar.left + 2, y: bar.top + bar.height / 2 };
|
||||
if (kind === "controls") { const controls = header.querySelector('.window-controls').getBoundingClientRect(); return { x: controls.left + 10, y: controls.top + controls.height / 2 }; }
|
||||
if (kind === "blank") return { x: plus.right + 16, y: bounds.top + bounds.height / 2 };
|
||||
return { x: plus.left + plus.width / 2, y: plus.top + plus.height / 2 };
|
||||
}, kind);
|
||||
}
|
||||
try {
|
||||
const source = await create("?plugins"), target = await create("?plugins");
|
||||
async function open(page, name) {
|
||||
await page.bringToFront(); 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(page, name).waitFor();
|
||||
}
|
||||
async function openBoard(page) {
|
||||
await page.getByRole("navigation", { name: "Plugin shortcuts" }).getByRole("button", { name: "Board", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "Board state" }).waitFor();
|
||||
}
|
||||
async function pin(page, name) {
|
||||
await tab(page, name).click({ button: "right" }); await page.getByRole("menuitem", { name: "Pin", exact: true }).click();
|
||||
}
|
||||
function start(page, name) {
|
||||
return tab(page, name).evaluate(node => {
|
||||
if (node.getAttribute("draggable") !== "true") throw new Error("The tab must support native transfer.");
|
||||
const transfer = new DataTransfer(); node.dispatchEvent(new DragEvent("dragstart", { bubbles: true, dataTransfer: transfer }));
|
||||
return transfer.getData("application/x-runestone-tab");
|
||||
});
|
||||
}
|
||||
async function setTheme(page, mode) {
|
||||
await page.evaluate(async mode => { const { applyAppearance } = await import("/src/lib/theme/appearance.ts"); await applyAppearance({ theme: "default", mode }); }, mode);
|
||||
}
|
||||
async function screenshots(page, prefix) {
|
||||
for (const mode of ["dark", "light"]) {
|
||||
await setTheme(page, mode);
|
||||
await page.screenshot({ path: path.join(output, `${prefix}-${mode}.png`) });
|
||||
}
|
||||
await page.setViewportSize({ width: 700, height: 700 });
|
||||
await page.screenshot({ path: path.join(output, `${prefix}-narrow.png`) });
|
||||
await page.setViewportSize({ width: 1400, height: 900 });
|
||||
}
|
||||
async function eventAt(page, data, point, type = "dragover", mime = "application/x-runestone-tab") {
|
||||
return page.evaluate(({ data, point, type, mime }) => {
|
||||
const transfer = new DataTransfer(); transfer.setData(mime, data);
|
||||
const node = document.elementFromPoint(point.x, point.y) || document.body;
|
||||
const event = new DragEvent(type, { bubbles: true, cancelable: true, clientX: point.x, clientY: point.y, dataTransfer: transfer });
|
||||
node.dispatchEvent(event);
|
||||
return event.defaultPrevented;
|
||||
}, { data, point, type, mime });
|
||||
}
|
||||
async function receive(page, data, point) {
|
||||
assert.equal(await eventAt(page, data, point), true);
|
||||
assert.equal(await eventAt(page, data, point, "drop"), true);
|
||||
}
|
||||
async function point(page, kind) {
|
||||
return page.locator(".header").evaluate((header, kind) => {
|
||||
const bounds = header.getBoundingClientRect();
|
||||
const bar = header.querySelector('[role="tablist"]').getBoundingClientRect();
|
||||
const plus = header.querySelector('[aria-label="New tab (Ctrl T)"]').getBoundingClientRect();
|
||||
const first = header.querySelector('.tab').getBoundingClientRect();
|
||||
if (kind === "near") return { x: first.left + first.width / 2, y: bounds.bottom + 18 };
|
||||
if (kind === "outside") return { x: first.left + first.width / 2, y: bounds.bottom + 80 };
|
||||
if (kind === "precise") return { x: bar.left + 2, y: bar.top + bar.height / 2 };
|
||||
if (kind === "controls") { const controls = header.querySelector('.window-controls').getBoundingClientRect(); return { x: controls.left + 10, y: controls.top + controls.height / 2 }; }
|
||||
if (kind === "blank") return { x: plus.right + 16, y: bounds.top + bounds.height / 2 };
|
||||
return { x: plus.left + plus.width / 2, y: plus.top + plus.height / 2 };
|
||||
}, kind);
|
||||
}
|
||||
|
||||
const source = await create(), target = await create();
|
||||
await open(target, "b.md");
|
||||
await open(source, "a.md"); await pin(source, "a.md");
|
||||
await source.locator(".cm-content").fill("Unsaved ribbon transfer");
|
||||
@@ -139,11 +113,10 @@ try {
|
||||
assert.equal(await bar(target).evaluate(node => node.classList.contains("receiving")), false);
|
||||
assert.equal(await eventAt(target, data, await point(target, "controls")), false, "Window controls stay outside the drop target");
|
||||
assert.equal(await eventAt(target, data, broad, "dragover", "text/plain"), false, "Ordinary file and text drags retain their behavior");
|
||||
await mkdir("output/tab-ribbon-drop", { recursive: true });
|
||||
for (const mode of ["light", "dark"]) {
|
||||
await target.evaluate(async mode => { const { applyAppearance } = await import("/src/lib/theme/appearance.ts"); await applyAppearance({ theme: "default", mode }); }, mode);
|
||||
await setTheme(target, mode);
|
||||
await eventAt(target, data, broad);
|
||||
await target.screenshot({ path: `output/tab-ribbon-drop/${mode}-blank-receiving.png` });
|
||||
await target.screenshot({ path: path.join(output, `${mode}-blank-receiving.png`) });
|
||||
}
|
||||
await receive(target, data, broad);
|
||||
await tab(target, "a.md •").waitFor(); await tab(source, "a.md •").waitFor({ state: "detached" });
|
||||
@@ -160,7 +133,7 @@ try {
|
||||
const nearby = await point(target, "near");
|
||||
await eventAt(target, data, nearby);
|
||||
await bar(target).and(target.locator('.receiving')).waitFor();
|
||||
await target.screenshot({ path: "output/tab-ribbon-drop/narrow-near-receiving.png" });
|
||||
await target.screenshot({ path: path.join(output, "narrow-near-receiving.png") });
|
||||
await receive(target, data, nearby);
|
||||
await tab(target, "Board").waitFor(); await tab(source, "Board").waitFor({ state: "detached" });
|
||||
assert.deepEqual(await order(target), ["c.md", "b.md", "a.md •", "Board"]);
|
||||
@@ -172,12 +145,5 @@ try {
|
||||
await receive(target, data, await point(target, "precise"));
|
||||
assert.deepEqual(await order(target), ["Board", "c.md", "b.md", "a.md •"]);
|
||||
await tab(target, "Board").evaluate(node => node.dispatchEvent(new DragEvent("dragend", { bubbles: true })));
|
||||
assert.deepEqual(errors, []);
|
||||
console.log("PASS: broad titlebar and nearby ribbon drops, exact tab ordering, rejection outside the ribbon and over window controls, ordinary drag isolation, pinned unsaved documents, narrow plugin transfers, and source acknowledgement");
|
||||
} catch (error) {
|
||||
await mkdir("output/tab-ribbon-drop", { recursive: true });
|
||||
for (const [index, page] of context.pages().entries()) await page.screenshot({ path: `output/tab-ribbon-drop/failure-${index}.png` });
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
|
||||
|
||||
assert.deepEqual(pages.flatMap(page => page.errors), []);
|
||||
});
|
||||
|
||||
@@ -1,148 +1,90 @@
|
||||
// Run against `pnpm dev`. PLAYWRIGHT_MODULE may point to a shared installation.
|
||||
import { createRequire } from "node:module";
|
||||
// Each tab keeps its own scroll position in the Writing, Reading, Split, and IDE layouts.
|
||||
import assert from "node:assert/strict";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(10000);
|
||||
const errors = [];
|
||||
page.on("console", message => { if (message.type() === "error" || message.type() === "warning") console.log(message.type(), message.text()); });
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = "C:\\smoke-workspace";
|
||||
const files = new Map([
|
||||
["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 callbacks = new Map();
|
||||
const listeners = new Map();
|
||||
let sequence = 0;
|
||||
const calls = [];
|
||||
const emit = (event, payload) => {
|
||||
for (const id of listeners.get(event) || []) callbacks.get(id)?.({ event, id, payload });
|
||||
};
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { const id = ++sequence; callbacks.set(id, callback); return id; },
|
||||
unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
calls.push({ command, args });
|
||||
if (command === "plugin:event|listen") {
|
||||
const list = listeners.get(args.event) || []; list.push(args.handler); listeners.set(args.event, list); return args.handler;
|
||||
}
|
||||
if (command === "plugin:event|unlisten") { callbacks.delete(args.eventId); return; }
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "smoke-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_write") {
|
||||
if (args.expected !== undefined && files.get(args.rel) !== args.expected) throw new Error("Save blocked: file changed on disk");
|
||||
files.set(args.rel, args.contents); emit("workspace-event", { root, kind: "modify", paths: [args.rel] }); return;
|
||||
}
|
||||
if (command === "workspace_list") {
|
||||
const prefix = args.rel ? args.rel + "/" : "";
|
||||
const entries = new Map();
|
||||
for (const path of files.keys()) {
|
||||
if (!path.startsWith(prefix) || path.startsWith(".runestone/")) continue;
|
||||
const tail = path.slice(prefix.length); const name = tail.split("/")[0];
|
||||
entries.set(name, { name, rel_path: prefix + name, kind: tail.includes("/") ? "folder" : "file" });
|
||||
}
|
||||
return [...entries.values()];
|
||||
}
|
||||
if (command === "workspace_create") { if (files.has(args.rel)) throw new Error("exists"); files.set(args.rel, ""); return; }
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "pty_profiles") return [{ id: "powershell", title: "PowerShell", kind: "powershell" }];
|
||||
if (command === "pty_open") {
|
||||
const data = [...new TextEncoder().encode("READY 🪨\r\n\x1b[6n")];
|
||||
emit("pty-data", { id: args.id, data: data.slice(0, 8) });
|
||||
emit("pty-data", { id: args.id, data: data.slice(8) });
|
||||
await new Promise(resolve => setTimeout(resolve, 50));
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("pty_")) return;
|
||||
if (command === "plugin:dialog|message") return "Cancel";
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: (_event, id) => callbacks.delete(id) };
|
||||
window.__TEST__ = { files, calls, emit, root };
|
||||
});
|
||||
import { mockTauri, runSmoke, settle as settleFrames, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
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();
|
||||
}
|
||||
async function settle() {
|
||||
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||
}
|
||||
async function roundTrip(selector, label) {
|
||||
const scroller = page.locator(selector);
|
||||
const position = async (top) => label === 'IDE'
|
||||
? page.evaluate(async top => {
|
||||
const { monaco } = await import('/src/lib/editor/monacoEnv.ts');
|
||||
const editor = monaco.editor.getEditors().find(view => view.getDomNode()?.isConnected);
|
||||
if (top !== undefined) editor.setScrollTop(top, 1);
|
||||
return editor.getScrollTop();
|
||||
}, top)
|
||||
: scroller.evaluate((el, top) => {
|
||||
if (top !== undefined) el.scrollTop = top;
|
||||
return el.scrollTop;
|
||||
}, top);
|
||||
await scroller.waitFor({ state: 'visible' });
|
||||
await settle();
|
||||
await position(1800);
|
||||
await settle();
|
||||
const first = await position();
|
||||
assert.ok(first > 1000, `${label}: first document is scrollable`);
|
||||
await page.getByRole('tab', { name: 'scroll-b.md', exact: true }).click();
|
||||
await scroller.waitFor({ state: 'visible' });
|
||||
await settle();
|
||||
await position(650);
|
||||
await settle();
|
||||
const second = await position();
|
||||
for (let repeat = 0; repeat < 2; repeat++) {
|
||||
for (const [name, expected] of [['scroll-a.md', first], ['scroll-b.md', second]]) {
|
||||
await page.getByRole('tab', { name, exact: true }).click();
|
||||
await scroller.waitFor({ state: 'visible' });
|
||||
await settle();
|
||||
const actual = await position();
|
||||
assert.ok(Math.abs(actual - expected) < 5, `${label}: ${name} expected ${expected}, got ${actual}`);
|
||||
}
|
||||
}
|
||||
console.log(`PASS: ${label} retains independent tab scroll positions`);
|
||||
await page.getByRole('tab', { name: 'scroll-a.md', exact: true }).click();
|
||||
}
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await page.getByText('smoke-workspace', { exact: true }).waitFor();
|
||||
await page.evaluate(() => {
|
||||
for (const name of ['scroll-a.md', 'scroll-b.md']) {
|
||||
window.__TEST__.files.set(name, Array.from({ length: 200 }, (_, i) => `Paragraph ${i} of ${name}.\n\n`).join(''));
|
||||
}
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['scroll-a.md', 'scroll-b.md'] });
|
||||
await runSmoke("tabs/scroll", async ({ page }) => {
|
||||
await mockTauri(page, {
|
||||
commands: test => test.workspace({
|
||||
root: "C:\\smoke-workspace",
|
||||
files: Object.fromEntries(["scroll-a.md", "scroll-b.md"].map(name => [name, Array.from({ length: 200 }, (_, i) => `Paragraph ${i} of ${name}.\n\n`).join("")])),
|
||||
}),
|
||||
});
|
||||
const settle = () => settleFrames(page);
|
||||
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();
|
||||
}
|
||||
async function roundTrip(selector, label) {
|
||||
const scroller = page.locator(selector);
|
||||
const position = async (top) => label === 'IDE'
|
||||
? page.evaluate(async top => {
|
||||
const { monaco } = await import('/src/lib/editor/monacoEnv.ts');
|
||||
const editor = monaco.editor.getEditors().find(view => view.getDomNode()?.isConnected);
|
||||
if (top !== undefined) editor.setScrollTop(top, 1);
|
||||
return editor.getScrollTop();
|
||||
}, top)
|
||||
: scroller.evaluate((el, top) => {
|
||||
if (top !== undefined) el.scrollTop = top;
|
||||
return el.scrollTop;
|
||||
}, top);
|
||||
// The Writing layout restores a line-anchored CodeMirror scrollSnapshot (src/lib/editor/LiveWriter.svelte:330-333).
|
||||
// Re-estimated heights of the lines above can move scrollTop, so compare the top visible line and its offset.
|
||||
const visibleTop = () => label === 'Writing'
|
||||
? scroller.evaluate(async el => {
|
||||
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
|
||||
const view = EditorView.findFromDOM(el.querySelector('.cm-content'));
|
||||
const top = el.getBoundingClientRect().top - view.documentTop;
|
||||
const block = view.lineBlockAtHeight(top);
|
||||
return { line: view.state.doc.lineAt(block.from).number, offset: top - block.top };
|
||||
})
|
||||
: position().then(top => ({ line: 0, offset: top }));
|
||||
await scroller.waitFor({ state: 'visible' });
|
||||
await settle();
|
||||
await position(1800);
|
||||
await settle();
|
||||
assert.ok(await position() > 1000, `${label}: first document is scrollable`);
|
||||
const first = await visibleTop();
|
||||
await page.getByRole('tab', { name: 'scroll-b.md', exact: true }).click();
|
||||
await scroller.waitFor({ state: 'visible' });
|
||||
await settle();
|
||||
await position(650);
|
||||
await settle();
|
||||
const second = await visibleTop();
|
||||
for (let repeat = 0; repeat < 2; repeat++) {
|
||||
for (const [name, expected] of [['scroll-a.md', first], ['scroll-b.md', second]]) {
|
||||
await page.getByRole('tab', { name, exact: true }).click();
|
||||
await scroller.waitFor({ state: 'visible' });
|
||||
await settle();
|
||||
const actual = await visibleTop();
|
||||
assert.ok(actual.line === expected.line && Math.abs(actual.offset - expected.offset) < 5, `${label}: ${name} expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`);
|
||||
}
|
||||
}
|
||||
console.log(`PASS: ${label} retains independent tab scroll positions`);
|
||||
await page.getByRole('tab', { name: 'scroll-a.md', exact: true }).click();
|
||||
}
|
||||
|
||||
// The view and layout switchers show only the current mode until hovered (src/lib/ui/ModeSwitcher.svelte:92, :153).
|
||||
async function mode(group, name) {
|
||||
const switcher = page.getByRole('group', { name: group, exact: true });
|
||||
await switcher.hover();
|
||||
await switcher.getByRole('button', { name, exact: true }).click();
|
||||
}
|
||||
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText('smoke-workspace', { exact: true }).waitFor();
|
||||
await open('scroll-b.md');
|
||||
await open('scroll-a.md');
|
||||
if (await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).count()) {
|
||||
await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).click();
|
||||
}
|
||||
await mode('Editor layout', 'Writer');
|
||||
await roundTrip('.cm-scroller', 'Writing');
|
||||
await page.getByRole('button', { name: 'Read', exact: true }).click();
|
||||
await mode('Document view', 'Read');
|
||||
await roundTrip('.md-page', 'Reading');
|
||||
await page.getByRole('button', { name: 'Split', exact: true }).click();
|
||||
await mode('Document view', 'Split');
|
||||
await roundTrip('.md-page', 'Split preview');
|
||||
await page.getByRole('button', { name: 'Edit', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Switch to IDE layout (Ctrl E)', exact: true }).click();
|
||||
await mode('Document view', 'Edit');
|
||||
await mode('Editor layout', 'IDE');
|
||||
await page.getByRole('tab', { name: 'scroll-b.md', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Switch to IDE layout (Ctrl E)', exact: true }).click();
|
||||
await mode('Editor layout', 'IDE');
|
||||
await page.getByRole('tab', { name: 'scroll-a.md', exact: true }).click();
|
||||
await roundTrip('.monaco-scrollable-element', 'IDE');
|
||||
assert.deepEqual(errors, []);
|
||||
} catch (error) {
|
||||
console.error('Browser errors:', errors);
|
||||
console.error((await page.locator('body').innerText()).slice(-2000));
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
});
|
||||
|
||||
@@ -1,79 +1,72 @@
|
||||
import { createRequire } from "node:module";
|
||||
// Tab transfer between windows: same-workspace moves with unsaved text and pins, insertion order, other-workspace rejection, duplicates, and source edits during a transfer.
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const context = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
||||
await context.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
localStorage.setItem("runestone.settings", JSON.stringify({ autosaveEnabled: false }));
|
||||
const root = location.search.includes("other") ? "C:\\other" : "C:\\transfer";
|
||||
let sequence = 0;
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: () => ++sequence, unregisterCallback: () => {},
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") return ++sequence;
|
||||
if (command === "plugin:event|unlisten" || command.startsWith("plugin:window|")) return;
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "transfer", watch_mode: "native" };
|
||||
if (command === "workspace_read") return "# " + args.rel + "\n\nOriginal text.\n";
|
||||
if (command === "workspace_list") return args.rel ? [] : ["a.md", "b.md"].map(name => ({ name, rel_path: name, kind: "file" }));
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "plugins_snapshot") return { root, plugins: [] };
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
import path from "node:path";
|
||||
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("tabs/transfer", async ({ browser }) => {
|
||||
const output = await outputDir("tabs/transfer");
|
||||
const context = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
||||
await mockTauri(context, {
|
||||
commands: test => {
|
||||
localStorage.setItem("runestone.settings", JSON.stringify({ autosaveEnabled: false }));
|
||||
const root = location.search.includes("other") ? "C:\\other" : "C:\\transfer";
|
||||
const workspace = test.workspace({ root, name: "transfer", files: Object.fromEntries(["a.md", "b.md"].map(name => [name, `# ${name}\n\nOriginal text.\n`])) });
|
||||
return {
|
||||
...workspace,
|
||||
plugins_snapshot: () => ({ root, plugins: [] }),
|
||||
"plugin:window|is_maximized": () => false,
|
||||
};
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
const url = process.env.SMOKE_URL || "http://127.0.0.1:1420";
|
||||
const source = await context.newPage(), target = await context.newPage(), other = await context.newPage();
|
||||
for (const page of [source, target, other]) page.setDefaultTimeout(10000);
|
||||
const errors = [];
|
||||
for (const page of [source, target, other]) page.on("pageerror", error => errors.push(error.message));
|
||||
const tab = (page, name) => page.locator('[role="tab"]').filter({ hasText: name });
|
||||
async function open(page, name) {
|
||||
await page.bringToFront();
|
||||
await page.getByRole("tablist", { name: "Working tabs" }).waitFor();
|
||||
await page.getByRole("tab").first().waitFor();
|
||||
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(page, name).waitFor();
|
||||
}
|
||||
async function start(page, name) {
|
||||
return tab(page, name).evaluate(node => {
|
||||
const transfer = new DataTransfer();
|
||||
node.dispatchEvent(new DragEvent("dragstart", { bubbles: true, dataTransfer: transfer }));
|
||||
return transfer.getData("application/x-runestone-tab");
|
||||
});
|
||||
}
|
||||
async function drop(page, data) {
|
||||
await page.getByRole("tablist", { name: "Working tabs" }).evaluate((node, data) => {
|
||||
const transfer = new DataTransfer();
|
||||
transfer.setData("application/x-runestone-tab", data);
|
||||
node.dispatchEvent(new DragEvent("dragover", { bubbles: true, cancelable: true, clientX: node.getBoundingClientRect().left, dataTransfer: transfer }));
|
||||
node.dispatchEvent(new DragEvent("drop", { bubbles: true, cancelable: true, clientX: node.getBoundingClientRect().left, dataTransfer: transfer }));
|
||||
}, data);
|
||||
}
|
||||
async function captureTransfer(page, data) {
|
||||
await mkdir("output/tab-transfer", { recursive: true });
|
||||
for (const theme of ["light", "dark"]) {
|
||||
const pages = [];
|
||||
async function newPage() {
|
||||
const page = await openPage(context);
|
||||
pages.push(page);
|
||||
return page;
|
||||
}
|
||||
const source = await newPage(), target = await newPage(), other = await newPage();
|
||||
const tab = (page, name) => page.locator('[role="tab"]').filter({ hasText: name });
|
||||
async function open(page, name) {
|
||||
await page.bringToFront();
|
||||
await page.getByRole("tablist", { name: "Working tabs" }).waitFor();
|
||||
await page.getByRole("tab").first().waitFor();
|
||||
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(page, name).waitFor();
|
||||
}
|
||||
async function start(page, name) {
|
||||
return tab(page, name).evaluate(node => {
|
||||
const transfer = new DataTransfer();
|
||||
node.dispatchEvent(new DragEvent("dragstart", { bubbles: true, dataTransfer: transfer }));
|
||||
return transfer.getData("application/x-runestone-tab");
|
||||
});
|
||||
}
|
||||
function dragOver(page, data, drop) {
|
||||
return page.getByRole("tablist", { name: "Working tabs" }).evaluate((node, { data, drop }) => {
|
||||
const transfer = new DataTransfer();
|
||||
transfer.setData("application/x-runestone-tab", data);
|
||||
const options = { bubbles: true, cancelable: true, clientX: node.getBoundingClientRect().left, dataTransfer: transfer };
|
||||
node.dispatchEvent(new DragEvent("dragover", options));
|
||||
if (drop) node.dispatchEvent(new DragEvent("drop", options));
|
||||
}, { data, drop });
|
||||
}
|
||||
const drop = (page, data) => dragOver(page, data, true);
|
||||
async function setTheme(page, mode) {
|
||||
await page.evaluate(async mode => {
|
||||
const { applyAppearance } = await import('/src/lib/theme/appearance.ts');
|
||||
await applyAppearance({ theme: 'default', mode });
|
||||
}, theme);
|
||||
await page.getByRole("tablist", { name: "Working tabs" }).evaluate((node, data) => {
|
||||
const transfer = new DataTransfer();
|
||||
transfer.setData("application/x-runestone-tab", data);
|
||||
node.dispatchEvent(new DragEvent("dragover", { bubbles: true, cancelable: true, clientX: node.getBoundingClientRect().left, dataTransfer: transfer }));
|
||||
}, data);
|
||||
await page.screenshot({ path: `output/tab-transfer/${theme}-receiving.png` });
|
||||
}, mode);
|
||||
}
|
||||
}
|
||||
try {
|
||||
await Promise.all([source.goto(url), target.goto(url), other.goto(url + "/?other")]);
|
||||
async function captureTransfer(page, data) {
|
||||
for (const theme of ["light", "dark"]) {
|
||||
await setTheme(page, theme);
|
||||
await dragOver(page, data, false);
|
||||
await page.screenshot({ path: path.join(output, `${theme}-receiving.png`) });
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all([source.goto(smokeUrl), target.goto(smokeUrl), other.goto(smokeUrl + "/?other")]);
|
||||
await open(source, "a.md");
|
||||
await open(target, "b.md");
|
||||
await tab(source, "a.md").click({ button: "right" });
|
||||
@@ -86,14 +79,11 @@ try {
|
||||
assert.equal(await tab(source, "a.md").count(), 1);
|
||||
await captureTransfer(target, data);
|
||||
await drop(target, data);
|
||||
console.log("Dropped into matching workspace");
|
||||
await tab(target, "a.md").waitFor();
|
||||
await tab(source, "a.md").waitFor({ state: "detached" });
|
||||
console.log("Source acknowledged transfer");
|
||||
assert.match(await target.locator(".cm-content").innerText(), /Unsaved transfer text/);
|
||||
const changedTarget = await context.newPage();
|
||||
changedTarget.on("pageerror", error => errors.push(error.message));
|
||||
await changedTarget.goto(url);
|
||||
const changedTarget = await newPage();
|
||||
await changedTarget.goto(smokeUrl);
|
||||
await changedTarget.getByRole("tab").first().waitFor();
|
||||
await open(source, "a.md");
|
||||
data = await start(source, "a.md");
|
||||
@@ -110,20 +100,11 @@ try {
|
||||
await target.getByText("This tab is already open in this window. The source tab remains open.").waitFor();
|
||||
assert.equal(await tab(source, "a.md").count(), 1);
|
||||
assert.match(await target.locator(".cm-content").innerText(), /Unsaved transfer text/);
|
||||
await mkdir("output/tab-transfer", { recursive: true });
|
||||
for (const theme of ["light", "dark"]) {
|
||||
await target.evaluate(async mode => {
|
||||
const { applyAppearance } = await import('/src/lib/theme/appearance.ts');
|
||||
await applyAppearance({ theme: 'default', mode });
|
||||
}, theme);
|
||||
await target.screenshot({ path: `output/tab-transfer/${theme}.png` });
|
||||
await setTheme(target, theme);
|
||||
await target.screenshot({ path: path.join(output, `${theme}.png`) });
|
||||
}
|
||||
await target.setViewportSize({ width: 700, height: 700 });
|
||||
await target.screenshot({ path: "output/tab-transfer/narrow.png" });
|
||||
assert.deepEqual(errors, []);
|
||||
console.log("PASS: same-workspace transfer, unsaved text, pinned state, insertion order, other-workspace rejection, duplicate protection, and source edits during transfer");
|
||||
} catch (reason) {
|
||||
console.log(await other.locator("body").innerText());
|
||||
console.log(await target.locator("body").innerText());
|
||||
throw reason;
|
||||
} finally { await browser.close(); }
|
||||
await target.screenshot({ path: path.join(output, "narrow.png") });
|
||||
assert.deepEqual(pages.flatMap(page => page.errors), []);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// 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");
|
||||
});
|
||||
Reference in New Issue
Block a user