- Move the Terminal plugin into src/lib/features/terminal/ on the host Svelte runtime, with xterm 6.0.0 and addon-fit 0.11.0. - Buttons, shortcuts, Help rows, and the close guard follow the Terminal switch. The first use loads the module. - Add Settings → Terminal and the terminal settings section. The first start copies the old runestone.terminal key. - The 16 ANSI colors come from the --rs-ansi-* tokens. - Off asks first when a shell runs in any window (pty_running). - Rust: no pty-data or pty-exit events, an owner check for write, resize, and close, output joined up to 64 KiB or 8 ms, and the sessions of a reloaded page close. - Remove api.pty, the terminal contribution, TerminalSlot, and the plugin loader of the smoke harness. - Check only the tested switches in the Background smoke test. - Update the tests, the menu inventory, the docs, and UI-058.
66 lines
4.4 KiB
JavaScript
66 lines
4.4 KiB
JavaScript
// Custom window controls: maximize, restore, minimize, the terminal close guard, the keyboard tooltip, and the header at 1400 and 880 px.
|
|
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { mockTauri, outputDir, repoRoot, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
|
|
|
await runSmoke("layout/windowControls", async ({ page }) => {
|
|
const output = await outputDir("layout/windowControls");
|
|
await mockTauri(page, {
|
|
state: { maximized: false, confirm: "Cancel" },
|
|
commands: test => ({
|
|
workspace_last_path: () => null,
|
|
"plugin:window|is_maximized": () => test.state.maximized,
|
|
"plugin:window|toggle_maximize": () => { test.state.maximized = !test.state.maximized; test.emit("tauri://resize", { width: 1400, height: 900 }); },
|
|
"plugin:window|minimize": () => {},
|
|
"plugin:window|destroy": () => {},
|
|
"plugin:window|close": () => { test.emit("tauri://close-requested"); },
|
|
"plugin:dialog|message": () => test.state.confirm,
|
|
}),
|
|
});
|
|
// The Terminal button belongs to the Terminal feature, which is on by default (src/lib/features/catalog.ts).
|
|
const called = command => page.evaluate(command => window.__TEST__.calls.some(call => call.command === command), command);
|
|
|
|
const config = JSON.parse(await readFile(path.join(repoRoot, "src-tauri/tauri.conf.json"), "utf8"));
|
|
assert.equal(config.app.windows[0].decorations, false);
|
|
const capability = JSON.parse(await readFile(path.join(repoRoot, "src-tauri/capabilities/default.json"), "utf8"));
|
|
for (const permission of ["close", "minimize", "toggle-maximize", "start-dragging"]) {
|
|
assert.ok(capability.permissions.includes(`core:window:allow-${permission}`));
|
|
}
|
|
await page.goto(smokeUrl);
|
|
await page.getByRole("button", { name: "Maximize window", exact: true }).click();
|
|
await page.getByRole("button", { name: "Restore window", exact: true }).waitFor();
|
|
await page.getByRole("button", { name: "Restore window", exact: true }).click();
|
|
await page.getByRole("button", { name: "Maximize window", exact: true }).waitFor();
|
|
// Native maximize/restore (e.g. double-clicking the drag region) updates the button too.
|
|
await page.evaluate(() => { window.__TEST__.state.maximized = true; window.__TEST__.emit("tauri://resize", { width: 1920, height: 1080 }); });
|
|
await page.getByRole("button", { name: "Restore window", exact: true }).waitFor();
|
|
await page.getByRole("button", { name: "Minimize window", exact: true }).click();
|
|
assert.ok(await called("plugin:window|minimize"));
|
|
await page.getByRole("button", { name: "Close window", exact: true }).focus();
|
|
await page.getByRole("tooltip", { name: "Close window", exact: true }).waitFor();
|
|
// Opening the terminal engages the existing close guard; cancellation must not destroy the window.
|
|
await page.getByRole("button", { name: "Terminal", exact: true }).click();
|
|
await page.getByRole("button", { name: "Close window", exact: true }).click();
|
|
await page.waitForFunction(() => window.__TEST__.calls.some(call => call.command === "plugin:dialog|message"));
|
|
assert.equal(await called("plugin:window|destroy"), false);
|
|
await page.evaluate(() => window.__TEST__.state.confirm = "Ok");
|
|
await page.getByRole("button", { name: "Close window", exact: true }).click();
|
|
await page.waitForFunction(() => window.__TEST__.calls.some(call => call.command === "plugin:window|destroy"));
|
|
await page.getByRole("button", { name: "Terminal", exact: true }).click();
|
|
for (const width of [1400, 880]) {
|
|
await page.setViewportSize({ width, height: 900 });
|
|
const layout = await page.evaluate(() => {
|
|
const header = document.querySelector(".header").getBoundingClientRect();
|
|
const controls = [...document.querySelectorAll(".header button")].map(el => el.getBoundingClientRect());
|
|
return { height: header.height, top: header.top, fits: controls.every(rect => rect.x >= 0 && rect.right <= innerWidth && rect.y >= header.y && rect.bottom <= header.bottom), drag: document.querySelector(".window-drag-space").getBoundingClientRect().width };
|
|
});
|
|
assert.equal(layout.height, 36);
|
|
assert.equal(layout.top, 0);
|
|
assert.ok(layout.fits);
|
|
assert.ok(layout.drag >= 40);
|
|
await page.screenshot({ path: path.join(output, `window-controls-${width}.png`) });
|
|
}
|
|
console.log("Window controls smoke passed: actions, restore state, close guard, keyboard tooltip, and 1400/880px layouts.");
|
|
}, { viewport: { width: 1400, height: 900 }, timeout: 30000 });
|