Support the migrated plugins in the host tests

- The pty_open mocks in layout/workbench and plugins/lifecycle send
  output through the channel that api.pty passes. Without a channel they
  keep the old events, so released Terminal versions still pass.
- plugins/gitToolbar resolves the Git plugin's "@runestone/plugin-sdk"
  imports to this repository's SDK build. The smoke runner builds the
  SDK when it is missing.
- The menu audit no longer compares the Terminal plugin's copies of the
  host menu files. The plugin now uses host menus through the SDK.

Checked with the released plugins and with the migrated Terminal, Git,
and Project Management branches.
This commit is contained in:
Knotty Wyvern
2026-10-28 03:11:07 -07:00
parent d62ee5d0b7
commit 4d09da30d9
6 changed files with 33 additions and 17 deletions
+7 -3
View File
@@ -34,9 +34,13 @@ await runSmoke("layout/workbench", async ({ page }) => {
workspace_search: () => [],
pty_profiles: () => [{ id: "powershell", title: "PowerShell", kind: "powershell" }],
pty_open: async args => {
const data = [...new TextEncoder().encode("READY 🪨\r\n\x1b[6n")];
test.emit("pty-data", { id: args.id, data: data.slice(0, 8) });
test.emit("pty-data", { id: args.id, data: data.slice(8) });
const data = new TextEncoder().encode("READY 🪨\r\n\x1b[6n");
// A Terminal plugin that uses api.pty passes a channel and gets raw bytes. Released versions listen for events.
if (args.channel) setTimeout(() => { args.channel.onmessage(data.slice(0, 8).buffer); args.channel.onmessage(data.slice(8).buffer); }, 0);
else {
test.emit("pty-data", { id: args.id, data: [...data.slice(0, 8)] });
test.emit("pty-data", { id: args.id, data: [...data.slice(8)] });
}
await new Promise(resolve => setTimeout(resolve, 50));
},
"plugin:dialog|message": () => "Cancel",
+10 -2
View File
@@ -1,18 +1,26 @@
// 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, runSmoke, smokeUrl } from "../_harness/index.mjs";
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, await readFile(path.join(source, "src", file), "utf8")])));
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" } }),
+8 -4
View File
@@ -33,10 +33,14 @@ await runSmoke('plugins/lifecycle', async ({ browser }) => {
},
settings_open_window: () => null,
pty_profiles: () => [{ id: 'powershell', title: 'PowerShell', kind: 'powershell' }],
pty_open: async ({ id }) => {
const data = [...new TextEncoder().encode('READY 🪨\r\n\x1b[6n')];
test.emit('pty-data', { id, data: data.slice(0, 8) });
test.emit('pty-data', { id, data: data.slice(8) });
pty_open: async ({ id, channel }) => {
const data = new TextEncoder().encode('READY 🪨\r\n\x1b[6n');
// A Terminal plugin that uses api.pty passes a channel and gets raw bytes. Released versions listen for events.
if (channel) setTimeout(() => { channel.onmessage(data.slice(0, 8).buffer); channel.onmessage(data.slice(8).buffer); }, 0);
else {
test.emit('pty-data', { id, data: [...data.slice(0, 8)] });
test.emit('pty-data', { id, data: [...data.slice(8)] });
}
await new Promise(resolve => setTimeout(resolve, 50));
},
pty_write: () => null,