Release RuneStone 0.1.7 with plugin documents and shared menus
This commit is contained in:
+24
-1
@@ -2,7 +2,8 @@ import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { ContributionRegistry, pluginHost } from "../src/lib/plugins/registry.ts";
|
||||
import { ExternalSession } from "../src/lib/plugins/externalSession.ts";
|
||||
import { activate } from "../plugins/table-formulas/index.ts";
|
||||
// @ts-ignore The compiled package is generated by pnpm build:plugins.
|
||||
import { activate } from "../plugin-packages/table-formulas/main.js";
|
||||
import { renderMarkdownHtml, renderMarkdownSections } from "../src/lib/workspace/noteHtml.ts";
|
||||
import type { PluginApi } from "../src/lib/plugins/sdk.ts";
|
||||
|
||||
@@ -11,6 +12,28 @@ const services = {
|
||||
settings: { read: async () => null, write: async () => {} },
|
||||
assets: { read: async () => new Uint8Array() },
|
||||
};
|
||||
|
||||
test("optional workspace creation and reads stop when the plugin is disabled", async () => {
|
||||
const files = new Map<string, string>();
|
||||
let api!: PluginApi;
|
||||
const session = new ExternalSession("workspace-test", {
|
||||
...services,
|
||||
workspace: {
|
||||
...services.workspace,
|
||||
readOptional: async path => files.get(path) ?? null,
|
||||
create: async (path, contents) => { if (files.has(path)) throw new Error("exists"); files.set(path, contents); },
|
||||
},
|
||||
}, () => {}, () => {});
|
||||
await session.start({ activate(value) { api = value; } });
|
||||
assert.equal(await api.workspace.readOptional!("board.json"), null);
|
||||
await api.workspace.create!("board.json", "{}");
|
||||
assert.equal(await api.workspace.readOptional!("board.json"), "{}");
|
||||
await assert.rejects(api.workspace.create!("board.json", "replacement"), /exists/);
|
||||
await session.stop();
|
||||
assert.throws(() => api.workspace.create!("other.json", "{}"), /disabled/);
|
||||
assert.throws(() => api.workspace.readOptional!("board.json"), /disabled/);
|
||||
assert.equal(files.size, 1);
|
||||
});
|
||||
test("core starts without optional features and formula packages preserve source when stopped", async () => {
|
||||
assert.equal(pluginHost.get("terminal"), undefined);
|
||||
assert.equal(pluginHost.get("tableFormulas"), undefined);
|
||||
|
||||
Reference in New Issue
Block a user