cf65528711
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
36 lines
1.8 KiB
TypeScript
36 lines
1.8 KiB
TypeScript
import * as assert from "node:assert";
|
|
import * as vscode from "vscode";
|
|
import { activateApi, settle } from "./helpers";
|
|
|
|
async function api() {
|
|
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
|
|
return (await ext.activate()) as import("../../../src/extension").CowritingApi;
|
|
}
|
|
|
|
suite("coediting registry (PUC-7)", () => {
|
|
test("enter → isCoediting true; exit → false; persists in list()", async () => {
|
|
const { coeditingRegistry } = await api();
|
|
const doc = await vscode.workspace.openTextDocument({ language: "markdown", content: "# t\n\nbody\n" });
|
|
await vscode.window.showTextDocument(doc);
|
|
await vscode.commands.executeCommand("cowriting.coeditDocument");
|
|
assert.strictEqual(coeditingRegistry.isCoediting(doc.uri), true);
|
|
assert.ok(coeditingRegistry.list().includes(doc.uri.toString()));
|
|
await vscode.commands.executeCommand("cowriting.stopCoediting");
|
|
assert.strictEqual(coeditingRegistry.isCoediting(doc.uri), false);
|
|
});
|
|
|
|
// Task 3 (INV-10): a document that was never entered into coediting gets no
|
|
// native-diff surface at all. QuickDiff's `provideOriginalResource` isn't
|
|
// directly queryable from a host-E2E test, so this asserts the gate INPUTS
|
|
// structurally: `isCoediting` stays false and the SCM change count — which
|
|
// `ScmSurfaceController` only ever populates for a coediting doc — stays 0.
|
|
test("non-entered doc: no coediting, no change count (structural, INV-10)", async () => {
|
|
const api = await activateApi();
|
|
const doc = await vscode.workspace.openTextDocument({ language: "markdown", content: "untouched\n" });
|
|
await vscode.window.showTextDocument(doc);
|
|
await settle();
|
|
assert.strictEqual(api.coeditingRegistry.isCoediting(doc.uri), false);
|
|
assert.strictEqual(api.scmSurfaceController.changeCount(doc.uri.toString()), 0);
|
|
});
|
|
});
|