Files
vscode-cowriting-plugin/test/e2e/suite/helpers.ts
T
BenStullsBets 2170a0d282 feat!: sunset the review-panel webview — built-in preview + native diff are the review surfaces (D3/D17, spec §6.10); Keep/Reject lens copy (PUC-2)
Deletes the last bespoke UI surface (TrackChangesPreviewController + its
sealed webview client assets); every entry point re-points at native VS
Code chrome per spec §5: the #41 right-click entries become
cowriting.openReviewPreview (enter coediting if needed -> "Open Preview to
the Side"), Ctrl+Alt+R/Cmd+Alt+R moves to cowriting.reviewChanges (native
diff), and the F12 CodeLens per-proposal titles read "Keep"/"Reject" with
a top-of-file "Keep all (N)"/"Reject all" pair once >=2 proposals are
pending. EditFlow drops its own askClaude/askEditInstruction (the
webview's only caller) and its now-unused constructor params.

Coverage that lived only in the webview's test seams (renderHtmlFor,
receiveMessage, isOpen, ...) moves to direct calls against the surviving
controllers/pure renderReview (test/e2e/suite/helpers.ts gains a shared
renderHtmlFor probe); a genuine gap (pending-proposal + unchanged-block
rendering) is backfilled in test/previewAnnotations.test.ts. README's "how
it works" is rewritten as the native-surface map; the superseded F6/F7/F9/
F10/F11 sections are kept as a marked historical record rather than
deleted outright.

292 unit + 91 E2E green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 14:51:18 -07:00

53 lines
2.1 KiB
TypeScript

/**
* Shared host-E2E helpers (native-surfaces migration, Task 2). NEW suites use
* these; existing suites keep their own local copies (out of scope to
* refactor them onto this shared file — see the Task 2 brief).
*/
import * as assert from "node:assert";
import * as vscode from "vscode";
import type { CowritingApi } from "../../../src/extension";
import { renderReview } from "../../../src/trackChangesModel";
/** Activate the extension and return its exported API (asserts it is real). */
export async function activateApi(): Promise<CowritingApi> {
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
const api = (await ext.activate()) as CowritingApi;
assert.ok(api?.diffViewController, "extension exports diffViewController");
return api;
}
/**
* Task 8: the pure render probe the deleted TrackChangesPreviewController used
* to wrap (`renderHtmlFor`) — the sunset webview was a thin shell around this
* exact call (F6 baseline + F3 spans + F4 pending proposals -> `renderReview`).
* Suites that used to read `controller.renderHtmlFor(key)` now call this
* directly against the surviving controllers; no webview involved.
*/
export function renderHtmlFor(api: CowritingApi, doc: vscode.TextDocument, key: string): string {
const baseline = api.diffViewController.getBaseline(key);
const current = doc.getText();
return renderReview(
baseline?.text ?? current,
current,
api.attributionController.spansFor(doc),
api.proposalController.listProposals(doc),
{ pinned: baseline?.reason === "pinned" },
);
}
/** A short fixed settle, for state that updates synchronously-ish after a command. */
export function settle(): Promise<void> {
return new Promise((r) => setTimeout(r, 150));
}
/** Poll `predicate` every 100ms until it is true, or fail after `timeoutMs`. */
export async function settleUntil(predicate: () => boolean, timeoutMs = 5000): Promise<void> {
const start = Date.now();
while (!predicate()) {
if (Date.now() - start > timeoutMs) {
assert.fail(`settleUntil: predicate did not become true within ${timeoutMs}ms`);
}
await new Promise((r) => setTimeout(r, 100));
}
}