Make Git a native feature with an off switch
- 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.
This commit is contained in:
@@ -195,7 +195,7 @@ function installMock(options, commands) {
|
||||
if (target !== pageId) channel.postMessage({ event, payload, target });
|
||||
};
|
||||
const SETTINGS_FILE = "runestone.smoke.settings-file", TRANSFERS = "runestone.smoke.tab-transfers";
|
||||
const SECTIONS = ["general", "appearance", "customThemes", "customThemesLegacy", "language"];
|
||||
const SECTIONS = ["general", "appearance", "customThemes", "customThemesLegacy", "language", "features"];
|
||||
const readJson = (key, fallback) => { try { return JSON.parse(localStorage.getItem(key)) ?? fallback; } catch { return fallback; } };
|
||||
const settingsFile = () => readJson(SETTINGS_FILE, null);
|
||||
const snapshot = () => {
|
||||
@@ -223,6 +223,10 @@ function installMock(options, commands) {
|
||||
// src-tauri/src/browser_engine.rs. Tests of the engine setup replace it.
|
||||
browser_engine_status: () => ({ state: "installed", version: "0.1.8", bytes: 160612374, received: 0, error: null }),
|
||||
settings_read: () => snapshot(),
|
||||
// src-tauri/src/features.rs: no old plugin package of a native feature is installed.
|
||||
features_legacy: () => [],
|
||||
// The editor asks for the Git line of the cursor while the Git feature is on. Tests of Git replace it.
|
||||
git_blame: () => null,
|
||||
settings_migrate: ({ sections }) => {
|
||||
if (!settingsFile()) localStorage.setItem(SETTINGS_FILE, JSON.stringify({ schema: 1, revision: 1, ...sections }));
|
||||
return snapshot();
|
||||
|
||||
@@ -13,6 +13,12 @@ await runSmoke("appearance/density", async ({ page }) => {
|
||||
files: { "note.md": "# Layout test\n\nA note with a short paragraph.\n\nA second paragraph.\n\n| Name | Value |\n| --- | --- |\n| Alpha | 12 |\n| Beta | 24 |\n" },
|
||||
}),
|
||||
plugins_snapshot: () => ({ root: "D:\\LayoutTest\\plugins", plugins: [] }),
|
||||
// The Git feature asks the host for the line history. The test turns the answer on with `blameOn`.
|
||||
git_blame: ({ path, line }) => {
|
||||
if (!window.blameOn) return null;
|
||||
window.blameCalls.push({ path, line });
|
||||
return { commit: "123456789abcdef", author: "UI test", date: "2026-10-07T12:34:00Z", summary: `Changed line ${line}` };
|
||||
},
|
||||
}),
|
||||
});
|
||||
const row = page.locator('[data-tree-rel="note.md"]');
|
||||
@@ -40,14 +46,7 @@ await runSmoke("appearance/density", async ({ page }) => {
|
||||
assert.equal(await line.evaluate(el => getComputedStyle(el, "::before").width), "3px");
|
||||
assert.equal(await page.locator(".line-history").count(), 0);
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const { pluginHost } = await import("/src/lib/plugins/registry.ts");
|
||||
window.blameCalls = [];
|
||||
window.removeGit = pluginHost.register("ui-test", "git", { blame: async (path, line) => {
|
||||
window.blameCalls.push({ path, line });
|
||||
return { commit: "123456789abcdef", author: "UI test", date: "2026-10-07T12:34:00Z", summary: `Changed line ${line}` };
|
||||
} });
|
||||
});
|
||||
await page.evaluate(() => { window.blameCalls = []; window.blameOn = true; });
|
||||
await line.click();
|
||||
await page.locator(".line-history").waitFor();
|
||||
assert.match(await page.locator(".line-history").getAttribute("title"), /Line 5 · UI test/);
|
||||
@@ -77,7 +76,8 @@ await runSmoke("appearance/density", async ({ page }) => {
|
||||
await view().press("ArrowRight");
|
||||
await page.locator(".source-editor .cm-content").waitFor();
|
||||
await page.locator(".line-history").waitFor();
|
||||
await page.evaluate(() => window.removeGit());
|
||||
// Git off removes the line history at once.
|
||||
await page.evaluate(() => { window.blameOn = false; window.__TEST__.writeSettings("features", { git: false }); });
|
||||
await page.locator(".line-history").waitFor({ state: "hidden" });
|
||||
await view().press("Home");
|
||||
await page.getByRole("button", { name: "Hide outline", exact: true }).click();
|
||||
|
||||
@@ -27,7 +27,7 @@ await runSmoke('browser/builtin', async ({ page }) => {
|
||||
if (id === 'board-a') { const b = document.createElement('button'); b.textContent = 'Select board B'; b.onclick = () => api.replaceView('board-a', 'board-b'); el.append(b); }
|
||||
return () => { window.__TEST__.cleanups.push(id); };
|
||||
}});
|
||||
api.registerView({ id:'source-control', title:'Source control', placement:'sidebar', navigation:true, icon:'git', mount(el) { el.textContent='Git sidebar fixture'; }});
|
||||
api.registerView({ id:'sidebar', title:'Sidebar fixture', placement:'sidebar', navigation:true, icon:'git', mount(el) { el.textContent='Plugin sidebar fixture'; }});
|
||||
}`;
|
||||
},
|
||||
browser_request: ({ session, command, args }) => {
|
||||
@@ -70,8 +70,8 @@ await runSmoke('browser/builtin', async ({ page }) => {
|
||||
await page.getByRole('tabpanel', { name: 'board-b', exact: true }).waitFor();
|
||||
await page.waitForFunction(() => window.__TEST__.mounts.includes('board-b') && window.__TEST__.cleanups.includes('board-a'));
|
||||
assert.deepEqual(await editorKeys(module), before);
|
||||
await page.getByRole('button', { name: 'Source control', exact: true }).click();
|
||||
await page.getByText('Git sidebar fixture', { exact: true }).waitFor();
|
||||
await page.getByRole('button', { name: 'Sidebar fixture', exact: true }).click();
|
||||
await page.getByText('Plugin sidebar fixture', { exact: true }).waitFor();
|
||||
assert.equal(await page.getByRole('tabpanel', { name: 'board-b', exact: true }).count(), 1);
|
||||
for (const theme of ['dark', 'light']) {
|
||||
await page.evaluate(theme => document.documentElement.dataset.theme = theme, theme);
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
// The native Git feature: the module loads only at first need, the Source control pane stages, unstages, and commits,
|
||||
// the diff and graph tabs open, errors show in the pane, and Off removes the feature at once.
|
||||
// It replaces plugins/gitToolbar, which loaded the old Git plugin from its sibling checkout.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("features/git", async ({ page }) => {
|
||||
const output = await outputDir("features/git");
|
||||
await mockTauri(page, {
|
||||
commands: test => {
|
||||
// The handlers run in the page, so the history is defined here.
|
||||
const commits = [
|
||||
{ id: "c3".padEnd(40, "3"), parents: ["c1".padEnd(40, "1"), "c2".padEnd(40, "2")], refs: ["HEAD -> main"], summary: "Merge the feature", author: "Ada", date: "2026-10-29" },
|
||||
{ id: "c2".padEnd(40, "2"), parents: ["c1".padEnd(40, "1")], refs: ["feature"], summary: "Add the feature", author: "Ada", date: "2026-10-28" },
|
||||
{ id: "c1".padEnd(40, "1"), parents: [], refs: [], summary: "First commit", author: "Ada", date: "2026-10-27" },
|
||||
];
|
||||
test.git = { calls: [], changes: [
|
||||
{ path: "staged.md", index: "M", worktree: " " },
|
||||
{ path: "changed.md", index: " ", worktree: "M" },
|
||||
{ path: "new.md", index: "?", worktree: "?" },
|
||||
] };
|
||||
const record = (command, value) => { test.git.calls.push([command, value]); return null; };
|
||||
return {
|
||||
...test.workspace({ root: "C:\\git-feature", files: { "staged.md": "A\n", "changed.md": "B\n", "new.md": "C\n" } }),
|
||||
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
|
||||
spelling_menu_install: () => null,
|
||||
"plugin:window|is_maximized": () => false,
|
||||
git_status: () => ({ available: true, repository: true, branch: "main", changes: test.git.changes }),
|
||||
git_diff: ({ path, staged }) => `diff --git a/${path} b/${path}\n@@ -1 +1 @@\n-old line\n+new line${staged ? " (staged)" : ""}`,
|
||||
git_stage: ({ paths }) => record("stage", paths),
|
||||
git_unstage: ({ paths }) => record("unstage", paths),
|
||||
git_commit: ({ message }) => record("commit", message),
|
||||
git_push: () => { throw "The branch has no upstream branch."; },
|
||||
git_pull: () => record("pull", null),
|
||||
git_graph: () => ({ commits }),
|
||||
git_commit_details: ({ commit }) => ({ id: commit, parents: commits.find(item => item.id === commit).parents, author: "Ada", date: "2026-10-29", message: "Details", files: [{ path: "one.md", status: "M" }, { path: "two.md", status: "A" }] }),
|
||||
git_commit_diff: ({ path }) => `@@ -0,0 +1 @@\n+${path}`,
|
||||
};
|
||||
},
|
||||
});
|
||||
await page.goto(smokeUrl);
|
||||
await page.locator('[data-tree-rel="staged.md"]').waitFor();
|
||||
const loaded = () => page.evaluate(() => performance.getEntriesByType("resource").some(entry => new URL(entry.name).pathname === "/src/lib/features/git/index.ts"));
|
||||
assert.equal(await loaded(), false, "The Git module does not load before first need");
|
||||
|
||||
const sourceControl = page.locator(".header-left").getByRole("button", { name: "Source control", exact: true });
|
||||
await sourceControl.click();
|
||||
const pane = page.locator(".source-control");
|
||||
await pane.getByText("main", { exact: true }).waitFor();
|
||||
assert.equal(await loaded(), true, "The Source control pane loads the Git module");
|
||||
await pane.getByRole("heading", { name: "Staged changes (1)", exact: true }).waitFor();
|
||||
await pane.getByRole("heading", { name: "Changes (2)", exact: true }).waitFor();
|
||||
|
||||
await pane.getByRole("button", { name: "Stage new.md", exact: true }).click();
|
||||
await page.waitForFunction(() => window.__TEST__.git.calls.some(([command]) => command === "stage"));
|
||||
assert.deepEqual(await page.evaluate(() => window.__TEST__.git.calls.at(-1)), ["stage", ["new.md"]]);
|
||||
await pane.getByRole("button", { name: "Unstage all", exact: true }).click();
|
||||
await page.waitForFunction(() => window.__TEST__.git.calls.some(([command]) => command === "unstage"));
|
||||
assert.deepEqual(await page.evaluate(() => window.__TEST__.git.calls.at(-1)), ["unstage", ["staged.md"]]);
|
||||
|
||||
const message = pane.getByRole("textbox", { name: "Commit message", exact: true });
|
||||
const commit = pane.getByRole("button", { name: "Commit staged", exact: true });
|
||||
assert.equal(await commit.isDisabled(), true, "Commit waits for a message");
|
||||
await message.fill("Write the notes");
|
||||
await message.press("Control+Enter");
|
||||
await pane.getByText("Commit created.", { exact: true }).waitFor();
|
||||
assert.deepEqual(await page.evaluate(() => window.__TEST__.git.calls.at(-1)), ["commit", "Write the notes"]);
|
||||
|
||||
await pane.getByRole("button", { name: "Push to the upstream branch", exact: true }).click();
|
||||
await pane.locator(".notice.error", { hasText: "no upstream branch" }).waitFor();
|
||||
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await page.evaluate(async mode => { const { saveAppearance } = await import("/src/lib/theme/appearance.ts"); saveAppearance({ theme: "default", mode }); }, theme);
|
||||
await page.waitForTimeout(100);
|
||||
await pane.screenshot({ path: path.join(output, `source-control-${theme}.png`) });
|
||||
}
|
||||
|
||||
await pane.getByRole("button", { name: /^changed\.md — Modified$/ }).click();
|
||||
const diff = page.locator(".git-diff");
|
||||
await diff.getByText("changed.md · Working tree", { exact: true }).waitFor();
|
||||
await diff.locator(".line.add", { hasText: "+new line" }).waitFor();
|
||||
assert.equal(await diff.locator(".line.remove").count(), 1);
|
||||
await page.screenshot({ path: path.join(output, "diff-tab.png") });
|
||||
|
||||
await pane.getByRole("button", { name: "Show Git graph", exact: true }).click();
|
||||
const graph = page.locator(".git-graph");
|
||||
const options = graph.getByRole("option");
|
||||
await options.first().waitFor();
|
||||
assert.equal(await options.count(), 3);
|
||||
assert.equal(await options.first().getAttribute("aria-selected"), "true");
|
||||
await graph.getByRole("button", { name: "one.md", exact: false }).first().waitFor();
|
||||
await options.first().focus();
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await page.waitForFunction(() => document.activeElement?.getAttribute("aria-selected") === "true" && document.activeElement?.textContent?.includes("Add the feature"));
|
||||
await graph.locator(".line.add", { hasText: "+one.md" }).waitFor();
|
||||
assert.equal(await graph.locator("path.boundary").count(), 0, "The full history has no dashed boundary line");
|
||||
await page.screenshot({ path: path.join(output, "graph-tab.png") });
|
||||
await page.setViewportSize({ width: 640, height: 720 });
|
||||
await page.screenshot({ path: path.join(output, "graph-tab-640.png") });
|
||||
await page.setViewportSize({ width: 1280, height: 800 });
|
||||
|
||||
// Off closes the Git tabs and the pane, and removes the button. The feature can start again.
|
||||
await page.evaluate(() => window.__TEST__.writeSettings("features", { git: false }));
|
||||
await sourceControl.waitFor({ state: "detached" });
|
||||
await graph.waitFor({ state: "detached" });
|
||||
await diff.waitFor({ state: "detached" });
|
||||
await pane.waitFor({ state: "detached" });
|
||||
await page.evaluate(() => window.__TEST__.writeSettings("features", { git: true }));
|
||||
await sourceControl.click();
|
||||
await pane.getByText("main", { exact: true }).waitFor();
|
||||
console.log("PASS: Git loads at first need, stages, unstages, commits, shows errors, diffs, and the graph, and Off removes it");
|
||||
}, { timeout: 60000 });
|
||||
@@ -0,0 +1,65 @@
|
||||
// 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 });
|
||||
@@ -1,76 +0,0 @@
|
||||
// Git plugin sidebar toolbar: the Graph control is icon-only, keeps its accessible name, shows hover and focus tooltips in both themes, and opens Graph.
|
||||
// @requires repo:RuneStone_Git/src
|
||||
// The source loads from the sibling RuneStone_Git checkout (RUNESTONE_PLUGIN_REPOS) without building a plugin ZIP.
|
||||
// Its "@runestone/plugin-sdk" imports resolve to this repository's SDK build (packages/plugin-sdk/dist), which the runner builds.
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, pluginRepo, repoRoot, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const sdkImport = /(\bfrom\s*|\bimport\s*\(\s*)(["'])@runestone\/plugin-sdk(?:\/([a-z-]+))?\2/g;
|
||||
const resolveSdk = source => source.replace(sdkImport, (_, keyword, quote, entry) => `${keyword}${quote}/__runestone_sdk/${entry || "index"}.js${quote}`);
|
||||
|
||||
const name = "plugins/gitToolbar";
|
||||
await runSmoke(name, async ({ page }) => {
|
||||
const output = await outputDir(name);
|
||||
const source = pluginRepo("RuneStone_Git");
|
||||
const files = new Map(await Promise.all(["view.js", "model.js"].map(async file => [file, resolveSdk(await readFile(path.join(source, "src", file), "utf8"))])));
|
||||
const css = await readFile(path.join(source, "src", "style.css"), "utf8");
|
||||
await page.route("**/__git_source/*", route => route.fulfill({ contentType: "text/javascript", body: files.get(new URL(route.request().url()).pathname.split("/").pop()) || "" }));
|
||||
await page.route("**/__runestone_sdk/*", async route => {
|
||||
const file = path.join(repoRoot, "packages/plugin-sdk/dist", path.basename(new URL(route.request().url()).pathname));
|
||||
await route.fulfill({ contentType: "text/javascript", body: await readFile(file, "utf8") });
|
||||
});
|
||||
await mockTauri(page, {
|
||||
commands: test => ({
|
||||
...test.workspace({ root: "C:\\git-toolbar", files: { "notes/draft.md": "Before.\n" } }),
|
||||
plugins_snapshot: () => ({ plugins: [], issues: [] }),
|
||||
spelling_menu_install: () => null,
|
||||
}),
|
||||
});
|
||||
await page.goto(smokeUrl);
|
||||
await page.locator('[data-tree-rel="notes"]').waitFor();
|
||||
await page.evaluate(async css => {
|
||||
const { mountSidebar } = await import("/__git_source/view.js");
|
||||
const container = document.createElement("div");
|
||||
container.id = "git-smoke";
|
||||
container.style.cssText = "position:fixed;inset:45px 0 0 0;z-index:1000;background:var(--rs-bg)";
|
||||
document.body.append(container);
|
||||
window.gitGraphOpens = 0;
|
||||
window.disposeGitSmoke = mountSidebar(container, {
|
||||
workspace: {},
|
||||
git: { status: async () => ({ available: true, repository: true, branch: "main", changes: [] }), pull: async () => {}, push: async () => {} },
|
||||
openView: () => window.gitGraphOpens++,
|
||||
}, css, () => {});
|
||||
}, css);
|
||||
const graph = page.locator("#git-smoke").getByRole("button", { name: "Graph", exact: true });
|
||||
// The plugin shows the shared host tooltip (a `.rs-tooltip` popover from `data-tooltip`) instead of a title and its own tooltip span.
|
||||
// RuneStone_Git/src/view.js: button() sets data-tooltip and aria-label; tooltipScope() shows the popover on hover and focus.
|
||||
const tooltip = page.locator(".rs-tooltip:popover-open");
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await page.evaluate(async mode => { const { saveAppearance } = await import("/src/lib/theme/appearance.ts"); saveAppearance({ theme: "default", mode }); }, theme);
|
||||
await graph.waitFor();
|
||||
assert.equal(await graph.locator("svg").count(), 1);
|
||||
assert.equal(await graph.getAttribute("title"), null);
|
||||
assert.equal(await graph.getAttribute("data-tooltip"), "Graph");
|
||||
assert.equal(await graph.evaluate(node => [...node.childNodes].filter(child => child.nodeType === Node.TEXT_NODE && child.textContent.trim()).length), 0);
|
||||
assert.equal(await graph.locator(":scope > :not(.rs-git-icon)").count(), 0, "Graph has no visible text label");
|
||||
await page.mouse.move(800, 800);
|
||||
await graph.evaluate(node => node.blur());
|
||||
assert.equal(await tooltip.count(), 0);
|
||||
await graph.hover();
|
||||
await tooltip.waitFor();
|
||||
assert.equal(await tooltip.innerText(), "Graph");
|
||||
await page.mouse.move(800, 800);
|
||||
await page.keyboard.press("Tab");
|
||||
await graph.focus();
|
||||
assert.equal(await graph.evaluate(node => node.matches(":focus-visible")), true);
|
||||
await tooltip.waitFor();
|
||||
assert.equal(await tooltip.innerText(), "Graph");
|
||||
await page.screenshot({ path: path.join(output, `git-toolbar-${theme}.png`) });
|
||||
}
|
||||
await graph.click();
|
||||
assert.equal(await page.evaluate(() => window.gitGraphOpens), 1);
|
||||
await page.evaluate(() => window.disposeGitSmoke());
|
||||
console.log("PASS: icon-only Graph control with accessible name, hover and focus tooltips in both themes, and Graph opens");
|
||||
}, { timeout: 15000 });
|
||||
@@ -1,24 +1,13 @@
|
||||
// Tree rename undo and redo keep folders expanded; New note templates, Git plug-in navigation, and detached tab layout isolation.
|
||||
// @requires repo:RuneStone_Git/dist
|
||||
// Tree rename undo and redo keep folders expanded; New note templates, native Git navigation, and detached tab layout isolation.
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { mockTauri, openPage, outputDir, pluginRepo, runSmoke, smokeUrl } from '../_harness/index.mjs';
|
||||
|
||||
const gitRoot = path.join(pluginRepo('RuneStone_Git'), 'dist');
|
||||
const git = {
|
||||
manifest: JSON.parse(await readFile(path.join(gitRoot, 'plugin.json'), 'utf8')),
|
||||
code: await readFile(path.join(gitRoot, 'main.js'), 'utf8'),
|
||||
css: (await readFile(path.join(gitRoot, 'style.css'))).toString('base64'),
|
||||
};
|
||||
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
|
||||
|
||||
await runSmoke('tree/renameUndo', async ({ browser }) => {
|
||||
const context = await browser.newContext({ viewport: { width: 1200, height: 850 } });
|
||||
await mockTauri(context, {
|
||||
strict: false,
|
||||
state: git,
|
||||
commands: test => {
|
||||
const git = test.state;
|
||||
const ws = test.workspace({
|
||||
root: 'C:\\host-todo-test',
|
||||
files: {
|
||||
@@ -46,10 +35,8 @@ await runSmoke('tree/renameUndo', async ({ browser }) => {
|
||||
},
|
||||
workspace_delete: ({ rel }) => { files.delete(rel); },
|
||||
workspace_search: () => [],
|
||||
plugins_snapshot: () => ({ root: 'C:/plugins', plugins: [{ manifest: git.manifest, hash: 'navigation-git', enabled: true, installedAt: 1, path: 'C:/plugins/runestone.git', error: null, removal: false }] }),
|
||||
plugins_load: () => git.code,
|
||||
plugins_asset: () => git.css,
|
||||
plugins_data: () => 'null',
|
||||
plugins_snapshot: () => ({ root: 'C:/plugins', plugins: [] }),
|
||||
git_status: () => ({ available: true, repository: true, branch: 'main', changes: [] }),
|
||||
'plugin:window|is_maximized': () => false,
|
||||
'plugin:dialog|message': () => 'Ok',
|
||||
};
|
||||
@@ -116,13 +103,15 @@ await runSmoke('tree/renameUndo', async ({ browser }) => {
|
||||
await page.waitForFunction(count => window.__TEST__.calls.filter(call => call.command === 'workspace_create').length === count + 1, creations);
|
||||
await page.getByRole('button', { name: 'Source control', exact: true }).waitFor();
|
||||
assert.equal(await page.locator('.header-left').getByRole('button', { name: 'Source control', exact: true }).count(), 1);
|
||||
await page.getByRole('button', { name: 'Plug-in views', exact: true }).click();
|
||||
const graph = page.getByRole('menuitem', { name: /Show Git graph/ });
|
||||
// Git is a native feature: no plug-in menu lists it, and its graph command is in the command palette.
|
||||
assert.equal(await page.getByRole('button', { name: 'Plug-in views', exact: true }).count(), 0);
|
||||
// The new note keeps the focus in its name field. Move the focus out of it before the palette shortcut.
|
||||
await page.evaluate(() => (document.activeElement instanceof HTMLElement) && document.activeElement.blur());
|
||||
await page.keyboard.press('Control+Shift+P');
|
||||
await page.getByRole('textbox', { name: 'Find a command', exact: true }).fill('Git graph');
|
||||
const graph = page.locator('#command-results .rs-picker-row', { hasText: 'Show Git graph' });
|
||||
await graph.waitFor();
|
||||
assert.equal(await page.getByRole('menuitem', { name: /source control/i }).count(), 0);
|
||||
const graphIcon = await graph.locator('.action-icon').innerHTML();
|
||||
const expectedIcon = await page.evaluate(async () => (await import('/src/lib/ui/actionIcons.ts')).actionIcon('git').innerHTML);
|
||||
assert.equal(graphIcon, expectedIcon, 'The real Git graph command uses the shared Git icon');
|
||||
assert.match(await graph.innerText(), /Git/);
|
||||
await shot(page, 'real-git-command-dark.png');
|
||||
await page.keyboard.press('Escape');
|
||||
await page.evaluate(async () => {
|
||||
|
||||
Reference in New Issue
Block a user