test(f8): host E2E — out-of-folder file + untitled + in-workspace regression; folder-less suite
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,21 +1,27 @@
|
||||
import * as assert from "assert";
|
||||
import * as vscode from "vscode";
|
||||
import type { CowritingApi } from "../../../src/extension";
|
||||
|
||||
// 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).
|
||||
// F8: with NO workspace folder open, authoring used to be stubbed (#8 registered
|
||||
// warning stubs and activate() returned undefined). F8 makes the authoring
|
||||
// commands REAL folder-less (the F6 #19 precedent), routing every doc to global
|
||||
// storage — so activate() returns a real API and propose→accept works on an
|
||||
// untitled buffer with no folder. This suite runs in a second EDH pass launched
|
||||
// WITHOUT a folder (see runTest.ts).
|
||||
|
||||
suite("no-workspace activation (#8)", () => {
|
||||
suite("no-workspace authoring (F8 — real folder-less, #8 lineage)", () => {
|
||||
test("EDH really has no workspace folder", () => {
|
||||
assert.strictEqual(vscode.workspace.workspaceFolders, undefined);
|
||||
});
|
||||
|
||||
test("all contributed coauthoring commands are registered as warning stubs", async () => {
|
||||
test("activate returns a real API even with no workspace folder (F8)", 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 api = (await ext.activate()) as CowritingApi;
|
||||
assert.ok(api?.proposalController, "no-folder activation returns the authoring API (F8)");
|
||||
assert.ok(api?.sidecarRouter, "router exposed");
|
||||
});
|
||||
|
||||
test("all contributed coauthoring commands are registered (real, not stubs)", async () => {
|
||||
const all = await vscode.commands.getCommands(true);
|
||||
for (const command of [
|
||||
"cowriting.createThread",
|
||||
@@ -33,9 +39,32 @@ suite("no-workspace activation (#8)", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("invoking a stub does not throw (shows a warning instead)", async () => {
|
||||
await vscode.commands.executeCommand("cowriting.editSelection");
|
||||
await vscode.commands.executeCommand("cowriting.createThread");
|
||||
test("authoring works folder-less: propose→accept on an untitled buffer routes to global storage (F8)", async () => {
|
||||
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
|
||||
const api = (await ext.activate()) as CowritingApi;
|
||||
const untitled = await vscode.workspace.openTextDocument({
|
||||
content: "Edit this scratch sentence please.\n",
|
||||
language: "markdown",
|
||||
});
|
||||
await vscode.window.showTextDocument(untitled);
|
||||
await new Promise((r) => setTimeout(r, 300));
|
||||
const key = untitled.uri.toString();
|
||||
const target = "Edit this scratch sentence please.";
|
||||
const start = untitled.getText().indexOf(target);
|
||||
const id = await vscode.commands.executeCommand<string>("cowriting.proposeAgentEdit", {
|
||||
uri: key,
|
||||
start,
|
||||
end: start + target.length,
|
||||
newText: "REPLACED scratch sentence.",
|
||||
model: "sonnet",
|
||||
sessionId: "e2e-nf",
|
||||
turnId: "turn-nf",
|
||||
});
|
||||
assert.ok(id, "propose returns an id for an untitled buffer with no folder");
|
||||
assert.ok(await api.proposalController.acceptById(key, id!), "accept applies");
|
||||
await new Promise((r) => setTimeout(r, 300));
|
||||
assert.ok(untitled.getText().includes("REPLACED scratch sentence."), "replacement landed in the untitled buffer");
|
||||
assert.strictEqual(api.sidecarRouter.sidecarPath(key), undefined, "untitled artifact is in-memory only (no disk)");
|
||||
});
|
||||
|
||||
// F6 (#19) is workspace-INDEPENDENT: its commands are real (not stubs) even
|
||||
|
||||
Reference in New Issue
Block a user