Файли
openidea/e2e/findExport.spec.ts
T
Muuтаmuutot 703c33a089 feat(find): export results to a text file (#7835)
Add Export to Text File… (find.exportToTextFile) to the Find tool window's toolbar and results context menu. The report follows the tree as shown: the tab title, the match/file summary, then each file with its folder and its 1-based match lines; excluded matches are left out and a failed write shows an error notification.

The per-tab exclude/replace marks move to a small store in the find feature so the action can read them.

Co-authored-by: muutot <[email protected]>
2026-12-04 01:35:28 +08:00

45 рядки
1.8 KiB
TypeScript

import { expect, stubDesktop, test } from "./fixtures";
const FILE = "/dev/acme-api/main.ts";
test("Find results expose Export to Text File", async ({ workbench: page }) => {
await stubDesktop(page);
await page.evaluate((path) => {
const h = window.__ipc.handlers;
h.search_validate = () => null;
h.search_start = ({ query, onEvent }) => {
if ((query as { pattern: string }).pattern !== "total") return null;
setTimeout(() => {
window.__ipc.send(onEvent, {
type: "file",
file: {
path,
relPath: "main.ts",
matches: [{ line: 0, text: "const total = 1;", ranges: [[6, 11]], textOffset: 0 }],
},
});
window.__ipc.send(onEvent, {
type: "done",
summary: { files: 1, matches: 1, limitHit: false, cancelled: false, elapsedMs: 1 },
});
}, 20);
return null;
};
}, FILE);
await page.keyboard.press("Meta+Shift+f");
const dialog = page.getByRole("dialog", { name: "Find in Files" });
await dialog.getByRole("textbox", { name: "Text to find" }).fill("total");
await expect(dialog.getByRole("listbox", { name: "Matches" }).getByRole("option")).toHaveCount(1);
await dialog.getByRole("button", { name: "Open in Find Window", exact: true }).click();
const find = page.getByRole("region", { name: "Find", exact: true });
await expect(find).toBeVisible();
const result = find.getByText("const total = 1;");
await expect(result).toBeVisible();
await expect(find.getByRole("button", { name: /Export to Text File/ })).toBeVisible();
await result.click({ button: "right" });
const menu = page.getByRole("menu").last();
const item = menu.getByRole("menuitem", { name: /Export to Text File/ });
await expect(item).toBeVisible();
await expect(item).toBeEnabled();
});