6d54963f15
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
2.1 KiB
TypeScript
49 lines
2.1 KiB
TypeScript
import * as assert from "assert";
|
|
import * as fs from "fs";
|
|
import * as path from "path";
|
|
import * as vscode from "vscode";
|
|
import type { CowritingApi } from "../../../src/extension";
|
|
|
|
const WS = process.env.E2E_WORKSPACE!;
|
|
const settle = () => new Promise((r) => setTimeout(r, 400));
|
|
|
|
async function getApi(): Promise<CowritingApi> {
|
|
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
|
|
const api = (await ext.activate()) as CowritingApi;
|
|
assert.ok(api?.trackChangesPreviewController && api?.proposalController, "exports controllers");
|
|
return api;
|
|
}
|
|
|
|
async function freshDoc(rel: string, body: string): Promise<{ doc: vscode.TextDocument; key: string }> {
|
|
const abs = path.join(WS, rel);
|
|
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
fs.writeFileSync(abs, body, "utf8");
|
|
const uri = vscode.Uri.file(abs);
|
|
const doc = await vscode.workspace.openTextDocument(uri);
|
|
await vscode.window.showTextDocument(doc);
|
|
await settle();
|
|
return { doc, key: uri.toString() };
|
|
}
|
|
|
|
suite("F12 inline diff — seam landBaseline (#64, INV-48)", () => {
|
|
test("applyAgentEdit with landBaseline:false applies text but does NOT advance the baseline", async () => {
|
|
const { doc, key } = await freshDoc("docs/f12-land.md", "# T\n\nalpha here.\n");
|
|
const api = await getApi();
|
|
await vscode.commands.executeCommand("cowriting.showTrackChangesPreview");
|
|
await settle();
|
|
const before = api.diffViewController.getBaseline(key)?.text ?? doc.getText();
|
|
const start = doc.getText().indexOf("alpha");
|
|
const ok = await api.attributionController.applyAgentEdit(
|
|
doc,
|
|
new vscode.Range(doc.positionAt(start), doc.positionAt(start + "alpha".length)),
|
|
"ALPHA",
|
|
{ kind: "agent", id: "claude", agent: { sdk: "x", model: "m", sessionId: "s" } },
|
|
{ landBaseline: false },
|
|
);
|
|
await settle();
|
|
assert.ok(ok, "edit applied");
|
|
assert.ok(doc.getText().includes("ALPHA"), "text in buffer");
|
|
assert.strictEqual(api.diffViewController.getBaseline(key)?.text ?? doc.getText(), before, "baseline unchanged");
|
|
});
|
|
});
|