32 lines
1.4 KiB
JavaScript
32 lines
1.4 KiB
JavaScript
// 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");
|
|
});
|