- Add the native feature runtime in src/lib/features/: the catalog, the switches, the first-start migration, the loader, and the feature sessions. - Add Settings → Features and the features settings section. - Add features_legacy. It reads the old plugin packages and changes nothing. - Move Git from the plugin into src/lib/features/git/, on host internals. - Remove api.git, the git contribution key, and the SDK Git types. - Add pnpm check:features. It fails when a feature module loads at start. - Update the tests, the menu inventory, the docs, and UI-055.
66 lines
3.7 KiB
JavaScript
66 lines
3.7 KiB
JavaScript
// Settings → Features: the switch of each native feature, the migration default, search, keyboard use, both themes, and narrow windows.
|
|
// A switch in the Settings window changes the main window at once.
|
|
import assert from "node:assert/strict";
|
|
import path from "node:path";
|
|
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
|
|
|
await runSmoke("features/settings", async ({ browser }) => {
|
|
const output = await outputDir("features/settings");
|
|
const context = await browser.newContext({ viewport: { width: 1152, height: 815 } });
|
|
await mockTauri(context, {
|
|
commands: test => ({
|
|
...test.workspace({ root: "C:\\features-settings", files: { "note.md": "# Note\n" } }),
|
|
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
|
|
"plugin:window|is_maximized": () => false,
|
|
}),
|
|
});
|
|
const main = await openPage(context, { timeout: 10000 });
|
|
await main.goto(smokeUrl);
|
|
await main.locator('[data-tree-rel="note.md"]').waitFor();
|
|
const sourceControl = main.locator(".header-left").getByRole("button", { name: "Source control", exact: true });
|
|
await sourceControl.waitFor();
|
|
// Without an old package, the migration stores the default of each feature.
|
|
assert.deepEqual(await main.evaluate(() => window.__TEST__.settings("features")), { git: true });
|
|
|
|
const settings = await openPage(context, { timeout: 10000 });
|
|
await settings.goto(`${smokeUrl}/?settingsWindow=true`);
|
|
await settings.getByRole("heading", { name: "General", exact: true }).waitFor();
|
|
await settings.getByRole("button", { name: "Features", exact: true }).click();
|
|
await settings.getByRole("heading", { name: "Features", exact: true }).waitFor();
|
|
const git = settings.getByRole("switch", { name: "Git", exact: true });
|
|
assert.equal(await git.isChecked(), true);
|
|
assert.match(await git.getAttribute("aria-describedby"), /feature-git-description/);
|
|
|
|
await git.click();
|
|
await sourceControl.waitFor({ state: "detached" });
|
|
assert.deepEqual(await main.evaluate(() => window.__TEST__.settings("features")), { git: false });
|
|
assert.equal(await settings.getByRole("status").innerText(), "Changes saved.");
|
|
await git.focus();
|
|
await settings.keyboard.press("Space");
|
|
await sourceControl.waitFor();
|
|
assert.equal(await git.isChecked(), true);
|
|
|
|
// The settings search finds the page by the name and the words of a feature.
|
|
const search = settings.getByRole("textbox", { name: "Search settings", exact: true });
|
|
await search.fill("source control");
|
|
assert.deepEqual(await settings.locator('nav[aria-label="Settings categories"] button').allInnerTexts(), ["Features"]);
|
|
await search.fill("");
|
|
|
|
for (const theme of ["dark", "light"]) {
|
|
await settings.evaluate(value => { document.documentElement.dataset.theme = value; }, theme);
|
|
for (const width of [1152, 540, 360]) {
|
|
await settings.setViewportSize({ width, height: width === 1152 ? 815 : 520 });
|
|
assert(await settings.evaluate(() => document.documentElement.scrollWidth <= innerWidth), `No horizontal scroll at ${width} pixels`);
|
|
const row = settings.locator(".setting-row", { has: git });
|
|
const box = await row.boundingBox();
|
|
const toggle = await git.boundingBox();
|
|
assert(toggle.x + toggle.width <= box.x + box.width + 1, "The switch stays inside its row");
|
|
await settings.screenshot({ path: path.join(output, `features-${theme}-${width}.png`) });
|
|
}
|
|
}
|
|
await git.focus();
|
|
assert.equal(await git.evaluate(node => node.matches(":focus-visible")), true);
|
|
await settings.screenshot({ path: path.join(output, "features-focus.png") });
|
|
console.log("PASS: the Features page turns Git off and on in another window, with search, keyboard, both themes, and narrow widths");
|
|
}, { timeout: 60000 });
|