Improve editor, plugin updates, and window transfers for 0.1.41
This commit is contained in:
@@ -2,7 +2,6 @@ import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { ExternalSession } from "../src/lib/plugins/externalSession.ts";
|
||||
import type { PluginApi } from "../src/lib/plugins/sdk.ts";
|
||||
import { locale } from "../src/lib/i18n/index.ts";
|
||||
function fixture() {
|
||||
let writes = 0;
|
||||
const session = new ExternalSession("org.test.demo", {
|
||||
@@ -13,25 +12,6 @@ function fixture() {
|
||||
return { session, writes: () => writes };
|
||||
}
|
||||
|
||||
test("plugin language changes stop before cleanup and reject later access", async () => {
|
||||
const { session } = fixture();
|
||||
const changes: string[] = [];
|
||||
let api!: PluginApi;
|
||||
try {
|
||||
await session.start({ activate(value) {
|
||||
api = value;
|
||||
api.i18n!.subscribe(language => changes.push(language));
|
||||
api.onDispose(() => { locale.set('ja'); });
|
||||
} });
|
||||
locale.set('fr');
|
||||
assert.equal(api.i18n!.t('Settings'), 'Paramètres');
|
||||
await session.stop();
|
||||
assert.deepEqual(changes, ['en', 'fr']);
|
||||
assert.throws(() => api.i18n!.t('Settings'), /disabled/);
|
||||
assert.throws(() => api.i18n!.locale, /disabled/);
|
||||
} finally { await session.stop(); locale.set('en'); }
|
||||
});
|
||||
|
||||
test("native Markdown discovery remains optional and is revoked on disable", async () => {
|
||||
let api!: PluginApi;
|
||||
let scans = 0;
|
||||
@@ -133,3 +113,26 @@ test("batch workspace reads remain optional and stop when the plugin is disabled
|
||||
await old.start({ activate(value) { assert.equal(value.workspace.readMany, undefined); } });
|
||||
await old.stop();
|
||||
});
|
||||
|
||||
test("view launch selects a default while explicit opens preserve their target", async () => {
|
||||
const opened: string[] = [];
|
||||
let api!: PluginApi;
|
||||
const session = new ExternalSession("org.test.launch", {
|
||||
workspace: { list: async () => [], read: async () => "", write: async () => {} },
|
||||
settings: { read: async () => null, write: async () => {} },
|
||||
assets: { read: async () => new Uint8Array() },
|
||||
}, () => {}, id => { opened.push(id); });
|
||||
await session.start({ activate(value) {
|
||||
api = value;
|
||||
api.registerView({ id: "all", title: "All", launch: async () => { api.openView("board"); }, mount() {} });
|
||||
api.registerView({ id: "board", title: "Board", mount() {} });
|
||||
assert.throws(() => api.registerView({ id: "invalid", title: "Invalid", launch: true as never, mount() {} }), /launch handler/);
|
||||
} });
|
||||
await session.launch("all");
|
||||
api.openView("all");
|
||||
await session.launch("board");
|
||||
assert.deepEqual(opened, ["board", "all", "board"]);
|
||||
await assert.rejects(session.launch("missing"), /Unknown plugin view/);
|
||||
await session.stop();
|
||||
await assert.rejects(session.launch("all"), /disabled/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user