Files
RuneStone/tests/smoke/editor/listNesting.smoke.mjs
T
Knotty Wyvern 9cf82503d0 Show one view control and name the file once
Phase 5-3.

- One radio group shows Write, Source, and Read at all times, with an
  icon and a name. Narrow panes show only the icons. The arrow keys
  move the choice, and the group has one Tab stop. The current choice
  gets the selection fill and an accent bar. Hover gets only a fill.
- A Split toggle shows Read beside Write or Source. Each document pane
  keeps a split flag beside its reading flag. Read ends Split.
- Ctrl+Shift+E switches between Read and the editor. Ctrl+E still
  switches between Write and Source.
- "IDE" becomes "Source" in the Chrome type, the tab menu (a View
  submenu), the status bar, the catalog, the tests, and the docs.
- Settings, General, File name title hides the title in Write and
  Read. It is on by default.
- The breadcrumb shows only the folder of the file. The status bar
  shows the view, not the path.
- ModeSwitcher.svelte and its hover test are gone. The new test
  layout/viewModes covers the control.
- The command palette from 5-2 gets its row in docs/menu-surfaces.json.
- The user guide Format table is whole again. The 5-2 edit had put
  the Paragraph and Insert rows under the shortcut table.
- 8 new catalog rows and 10 removed rows, in French, Japanese, and
  Simplified Chinese.
- Docs: UI-049, the user guide, ui-design.md, document-tools.md,
  development.md, and the README feature list.

Tests: the new layout/viewModes, new cases in documentPanes.spec.ts
and settings.spec.ts, and the chooseView harness helper. 21 smoke
tests use the new control. Tests that read the full path from the
breadcrumb now read its tooltip.
2026-10-28 19:45:08 -07:00

117 lines
6.5 KiB
JavaScript

// List nesting: Tab and Shift+Tab in Write, nested labels in Write and Read, one undo history in Write and Source, and the 4-space indent in Source.
import assert from "node:assert/strict";
import { chooseView, mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/listNesting", async ({ page }) => {
await mockTauri(page, {
commands: test => ({
...test.workspace({
root: "C:\\smoke-workspace",
files: {
"notes/readme.md": "# Requirements\n\n1. Topic\n2. \n3. A\n",
"src/hello.py": "print('hello')\n",
},
}),
spelling_menu_install: () => null,
}),
});
const output = await outputDir("editor/listNesting");
await page.goto(smokeUrl);
await page.getByText("smoke-workspace", { exact: true }).waitFor();
async function open(name, editor) {
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("textbox", { name: editor, exact: true }).waitFor();
await page.evaluate(async () => {
const { EditorView } = await import("/node_modules/@codemirror/view/dist/index.js");
window.__CM__ = EditorView.findFromDOM(document.querySelector(".cm-content"));
});
}
const doc = () => page.evaluate(() => window.__CM__.state.doc.toString());
const caretAt = (text, offset = text.length) => page.evaluate(([text, offset]) => {
window.__CM__.dispatch({ selection: { anchor: window.__CM__.state.doc.toString().indexOf(text) + offset } });
window.__CM__.focus();
}, [text, offset]);
const labels = () => page.locator(".live-writer .writer-list-label").allTextContents();
await open("readme.md", "Writing editor");
await caretAt("2. ");
await page.keyboard.press("Tab");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. \n2. A\n", "Tab nests the empty item and renumbers the next item");
assert.deepEqual(await labels(), ["a."], "The nested item shows a letter before it has text");
await page.keyboard.type("Sub item");
await page.keyboard.press("Enter");
await page.keyboard.type("Second");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. Sub item\n 2. Second\n2. A\n");
assert.deepEqual(await labels(), ["a.", "b."]);
for (const width of [1440, 600]) {
if (width === 600) {
await page.getByRole("button", { name: "Files", exact: true }).click();
await page.getByRole("button", { name: "Hide outline", exact: true }).click();
}
await page.setViewportSize({ width, height: 800 });
for (const mode of ["dark", "light"]) {
await page.evaluate(async mode => (await import("/src/lib/theme/appearance.ts")).saveAppearance({ theme: "default", mode }), mode);
await page.locator(".live-writer .cm-content").screenshot({ path: `${output}/writer-${mode}-${width}.png` });
}
}
await page.setViewportSize({ width: 1440, height: 900 });
await page.locator(".live-writer .cm-content").focus();
await page.keyboard.press("Shift+Tab");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. Sub item\n2. Second\n3. A\n", "Shift+Tab moves the item up and renumbers the outer list");
assert.deepEqual(await labels(), ["a."]);
await page.keyboard.press("Control+z");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. Sub item\n 2. Second\n2. A\n", "One undo step restores the nesting and the numbers");
await caretAt("1. Topic");
await page.keyboard.press("Tab");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. Sub item\n 2. Second\n2. A\n", "The first item stays in place");
await chooseView(page, "Read");
await page.locator(".md-page ol ol").waitFor();
assert.equal(await page.locator(".md-page ol ol").evaluate(list => getComputedStyle(list).listStyleType), "lower-alpha");
assert.equal(await page.locator(".md-page > .reading > ol, .md-page ol").first().evaluate(list => getComputedStyle(list).listStyleType), "decimal");
await page.locator(".md-page").screenshot({ path: `${output}/reader.png` });
await chooseView(page, "Write");
await page.getByRole("textbox", { name: "Writing editor", exact: true }).waitFor();
// Write and Source share the undo history of the document.
await caretAt("2. A");
await page.keyboard.type(" more");
await page.keyboard.press("Control+e");
await page.locator('.source-editor[data-chrome="Source"] .cm-gutters').waitFor();
assert.equal(await page.locator(".source-editor .cm-content").getAttribute("data-language"), "markdown");
await page.locator(".source-editor .cm-content").focus();
await page.keyboard.press("Control+z");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. Sub item\n 2. Second\n2. A\n", "Source undoes the last edit from Write");
await page.keyboard.press("Control+Shift+KeyZ");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. Sub item\n 2. Second\n2. A more\n");
await caretAt("2. A more");
await page.keyboard.press("Tab");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. Sub item\n 2. Second\n 3. A more\n", "Tab nests list items in Source too");
await page.keyboard.press("Control+e");
await page.getByRole("textbox", { name: "Writing editor", exact: true }).waitFor();
assert.deepEqual(await labels(), ["a.", "b.", "c."]);
// Source indents code to the next 4-column stop.
await open("hello.py", "Editor");
await caretAt("print", 0);
await page.keyboard.press("Tab");
assert.equal(await doc(), " print('hello')\n");
await caretAt("print", 2);
await page.keyboard.press("Tab");
assert.equal(await doc(), " pr int('hello')\n", "Tab inside a line fills to the next stop");
await page.keyboard.press("Control+z");
await page.keyboard.press("Control+z");
assert.equal(await doc(), "print('hello')\n");
await page.locator(".source-editor").screenshot({ path: `${output}/source-ide.png` });
// The history of a document stays while its tab stays open.
await open("readme.md", "Writing editor");
await page.locator(".live-writer .cm-content").focus();
await page.keyboard.press("Control+z");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. Sub item\n 2. Second\n2. A more\n", "Undo after a tab change reverts the Tab from Source");
console.log("PASS: Tab and Shift+Tab nesting, renumbering, Write labels, Read letters, shared undo in Write and Source and across tabs, Source list Tab, and 4-space code indent.");
});