15d1df0f4c
Migrate test surface to URI-string keys; add out-of-workspace file (persisted in global storage) + untitled-buffer (in-memory, not persisted) cases; assert F6 toggle works with no folder open. No LLM. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
63 lines
2.7 KiB
TypeScript
63 lines
2.7 KiB
TypeScript
import * as assert from "assert";
|
|
import * as vscode from "vscode";
|
|
|
|
// Regression for #8: with NO workspace folder open, activate() used to return
|
|
// before registering the F2/F3 commands, so the palette errored with
|
|
// "command 'cowriting.editSelection' not found". The fix registers warning
|
|
// stubs instead. This suite runs in a second EDH pass launched WITHOUT a
|
|
// folder (see runTest.ts).
|
|
|
|
suite("no-workspace activation (#8)", () => {
|
|
test("EDH really has no workspace folder", () => {
|
|
assert.strictEqual(vscode.workspace.workspaceFolders, undefined);
|
|
});
|
|
|
|
test("all contributed coauthoring commands are registered as warning stubs", async () => {
|
|
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
|
|
const api = await ext.activate();
|
|
assert.strictEqual(api, undefined, "no-root activation returns no API");
|
|
const all = await vscode.commands.getCommands(true);
|
|
for (const command of [
|
|
"cowriting.createThread",
|
|
"cowriting.reply",
|
|
"cowriting.resolveThread",
|
|
"cowriting.reopenThread",
|
|
"cowriting.editSelection",
|
|
"cowriting.toggleAttribution",
|
|
"cowriting.applyAgentEdit",
|
|
"cowriting.acceptProposal",
|
|
"cowriting.rejectProposal",
|
|
"cowriting.proposeAgentEdit",
|
|
]) {
|
|
assert.ok(all.includes(command), `${command} is registered`);
|
|
}
|
|
});
|
|
|
|
test("invoking a stub does not throw (shows a warning instead)", async () => {
|
|
await vscode.commands.executeCommand("cowriting.editSelection");
|
|
await vscode.commands.executeCommand("cowriting.createThread");
|
|
});
|
|
|
|
// F6 (#19) is workspace-INDEPENDENT: its commands are real (not stubs) even
|
|
// with no folder open, and the toggle works on an untitled buffer.
|
|
test("F6 toggle works with no folder open (untitled buffer)", async () => {
|
|
const all = await vscode.commands.getCommands(true);
|
|
assert.ok(all.includes("cowriting.toggleDiffView"), "toggleDiffView registered");
|
|
assert.ok(all.includes("cowriting.pinDiffBaseline"), "pinDiffBaseline registered");
|
|
const untitled = await vscode.workspace.openTextDocument({ content: "no-folder scratch\n", language: "markdown" });
|
|
await vscode.window.showTextDocument(untitled);
|
|
await new Promise((r) => setTimeout(r, 300));
|
|
await vscode.commands.executeCommand("cowriting.toggleDiffView");
|
|
await new Promise((r) => setTimeout(r, 300));
|
|
const opened = vscode.window.tabGroups.all.some((g) =>
|
|
g.tabs.some(
|
|
(t) =>
|
|
t.input instanceof vscode.TabInputTextDiff &&
|
|
t.input.original.scheme === "cowriting-baseline" &&
|
|
t.input.modified.toString() === untitled.uri.toString(),
|
|
),
|
|
);
|
|
assert.ok(opened, "a cowriting-baseline diff opened for the untitled buffer with no folder");
|
|
});
|
|
});
|