cdeb41ede4
Adds test/e2e/suite/f10Review.test.ts covering the F10 flow: open preview (mode "on", fresh baseline all-unchanged), type → cw-by-human span, propose → cw-proposal block with ✓/✗, accept → lands + baseline advances + block clears, reject → vanishes + doc untouched, toggle off → renderPlain has no cw- marks, status-bar PUC-6 (indicator with no panel, hidden once opened), and the clean-editor INV-32 facts (retired toggleAttribution, F6 ctrl+alt+d hidden). Rewrites the obsolete F9 authorship-mode test as an F10 review test (cw-by-claude in the on-state render; getMode defaults to "on"). Updates attribution.test.ts (drops the retired isVisible/toggleAttribution toggle, asserts the toggle is gone) and noWorkspace.test.ts (toggleAttribution + acceptProposal/rejectProposal are retired, preview-only — INV-32). Honesty fix in the status-bar seam: hideStatus() clears statusItem.text so statusText() reports undefined when the indicator is hidden (it previously returned its stale last value after a panel opened). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
98 lines
4.6 KiB
TypeScript
98 lines
4.6 KiB
TypeScript
import * as assert from "assert";
|
|
import * as vscode from "vscode";
|
|
import type { CowritingApi } from "../../../src/extension";
|
|
|
|
// 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 authoring (F8 — real folder-less, #8 lineage)", () => {
|
|
test("EDH really has no workspace folder", () => {
|
|
assert.strictEqual(vscode.workspace.workspaceFolders, undefined);
|
|
});
|
|
|
|
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()) 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",
|
|
"cowriting.reply",
|
|
"cowriting.resolveThread",
|
|
"cowriting.reopenThread",
|
|
"cowriting.editSelection",
|
|
"cowriting.applyAgentEdit",
|
|
"cowriting.proposeAgentEdit",
|
|
]) {
|
|
assert.ok(all.includes(command), `${command} is registered`);
|
|
}
|
|
// F10 (INV-32): proposals are preview-only — the in-editor accept/reject
|
|
// commands and the attribution toggle were retired (no editor decorations).
|
|
for (const retired of [
|
|
"cowriting.toggleAttribution",
|
|
"cowriting.acceptProposal",
|
|
"cowriting.rejectProposal",
|
|
]) {
|
|
assert.ok(!all.includes(retired), `${retired} is retired (F10 preview-only)`);
|
|
}
|
|
});
|
|
|
|
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
|
|
// 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");
|
|
});
|
|
});
|