test: retry first edit-path calls and wait for effects in flaky tests (#1271)

A provider call that starts a plugin instance (or reads files) can run past
the edit-path soft deadline on a slow runner and returns nothing; the tests
now ask again, as the editor does. The AI completion test cancels the slow
request only once the server has it, and measures from the cancel. The
SourcePreview test waits for the effect that marks the selection scope.

Closes #1269
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-04 21:07:03 +08:00
1 джерело 4b5ef7069c
коміт eaca68f263
2 files changed
+25 -14

No files matched your search

+3 -2
Переглянути файл
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import { render, screen, waitFor } from "@testing-library/react";
import { SourcePreview } from "./SourcePreview";
/** A stable loader reference (a new function reloads, like the real module-level ones). */
@@ -24,6 +24,7 @@ describe("SourcePreview", () => {
const { container } = render(<SourcePreview path="/p/a.ts" line={0} load={loadOf("// TODO")} />);
await screen.findByText("// TODO");
// The scroll pane is a selection scope: drags stay inside, text stays copyable.
expect(container.querySelector("[data-selection-scope]")).toBeTruthy();
// Set by an effect, which can run after the text is on screen.
await waitFor(() => expect(container.querySelector("[data-selection-scope]")).toBeTruthy());
});
});