дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 03:05:40 +02:00
Maximize Tool Window sized a window to a percentage, which left a strip of the editor and could shrink a window already larger. A maximized tool window now fills the workbench and hides the editor and other anchors, keeping saved sizes and split ratios for the restore. Opening or focusing an editor restores the layout, and closing the window returns focus to the editor. Fixes #2162
99 рядки
4.9 KiB
TypeScript
99 рядки
4.9 KiB
TypeScript
import type { Page } from "@playwright/test";
|
|
import { expect, test } from "./fixtures";
|
|
|
|
async function openChain(page: Page) {
|
|
await page.evaluate(async () => {
|
|
const inputPath = "/src/features/vcs/diffInput.ts";
|
|
const { openDiff, withChain } = await import(inputPath);
|
|
localStorage.setItem("openidea.vcs.diffOptions", JSON.stringify({ mode: "split", collapse: false }));
|
|
const files = ["a.ts", "b.ts"].map((name) => ({
|
|
path: `/dev/acme-api/${name}`,
|
|
left: { type: "text", text: "same\nbefore\ntail\n", label: "HEAD" },
|
|
right: { type: "text", text: "same\nafter\ntail\n", label: "Working tree" },
|
|
}));
|
|
await openDiff(withChain(files, 0), { preview: true });
|
|
});
|
|
const toolbar = page.getByRole("toolbar", { name: "Diff", exact: true });
|
|
await expect(toolbar).toContainText("1 difference");
|
|
return toolbar;
|
|
}
|
|
|
|
test("maximizes a diff preview tab and restores its previous layout", async ({ workbench: page }) => {
|
|
const toolbar = await openChain(page);
|
|
const viewer = toolbar.locator("..");
|
|
const project = page.getByRole("tree", { name: "Project", exact: true });
|
|
await expect(project).toBeVisible();
|
|
const before = (await viewer.boundingBox())!;
|
|
await toolbar.getByRole("button", { name: "Maximize Editor", exact: true }).click();
|
|
await expect(project).toBeHidden();
|
|
await expect.poll(async () => (await viewer.boundingBox())!.width).toBeGreaterThan(before.width + 100);
|
|
await expect(toolbar).toContainText("1 difference");
|
|
await toolbar.getByRole("button", { name: "Restore Size", exact: true }).click();
|
|
await expect(project).toBeVisible();
|
|
await expect.poll(async () => Math.abs((await viewer.boundingBox())!.width - before.width)).toBeLessThan(2);
|
|
await expect(toolbar).toContainText("1 difference");
|
|
});
|
|
|
|
test("continues between changed files from toolbar buttons and the keymap", async ({ workbench: page }) => {
|
|
const toolbar = await openChain(page);
|
|
const selected = page.getByRole("tablist", { name: "Editor tabs" }).locator('[aria-selected="true"]');
|
|
await toolbar.getByRole("button", { name: "Next Difference", exact: true }).click();
|
|
await expect(toolbar).toContainText("1 of 1 differences");
|
|
await toolbar.getByRole("button", { name: "Next Difference", exact: true }).click();
|
|
await expect(page.getByRole("status").filter({ hasText: "Press again to go to the next file" })).toBeVisible();
|
|
await expect(selected).toContainText("a.ts");
|
|
await page.keyboard.press("F7");
|
|
await expect(selected).toContainText("b.ts");
|
|
await expect(toolbar).toContainText("1 of 1 differences");
|
|
await toolbar.getByRole("button", { name: "Previous Difference", exact: true }).click();
|
|
await expect(page.getByRole("status").filter({ hasText: "Press again to go to the previous file" })).toBeVisible();
|
|
await toolbar.getByRole("button", { name: "Previous Difference", exact: true }).click();
|
|
await expect(selected).toContainText("a.ts");
|
|
await expect(toolbar).toContainText("1 of 1 differences");
|
|
});
|
|
|
|
test("skips binary and unchanged siblings and restores after changing preview files", async ({ workbench: page }) => {
|
|
const toolbar = await openChain(page);
|
|
await page.evaluate(async () => {
|
|
const inputPath = "/src/features/vcs/diffInput.ts";
|
|
const { openDiff, withChain } = await import(inputPath);
|
|
const files = [
|
|
["a.ts", "after\n"],
|
|
["binary.dat", "\0binary"],
|
|
["unchanged.ts", "before\n"],
|
|
["z.ts", "after\n"],
|
|
].map(([name, text]) => ({
|
|
path: `/dev/acme-api/${name}`,
|
|
left: { type: "text", text: "before\n", label: "HEAD" },
|
|
right: { type: "text", text, label: "Working tree" },
|
|
}));
|
|
await openDiff(withChain(files, 0), { preview: true });
|
|
});
|
|
await expect(toolbar).toContainText("1 difference");
|
|
await page.evaluate(async () => {
|
|
const layoutPath = "/src/workbench/toolwindows/store.ts";
|
|
const { useToolWindowLayout, hideAllToolWindows } = await import(layoutPath);
|
|
useToolWindowLayout.setState({ maximized: "left" });
|
|
hideAllToolWindows();
|
|
});
|
|
await toolbar.locator("..").locator(".cm-content").last().focus();
|
|
const selected = page.getByRole("tablist", { name: "Editor tabs" }).locator('[aria-selected="true"]');
|
|
await page.keyboard.press("F7");
|
|
await page.keyboard.press("F7");
|
|
await expect(selected).toContainText("z.ts");
|
|
await expect(toolbar).toContainText("1 of 1 differences");
|
|
await page.keyboard.press("F7");
|
|
await expect(selected).toContainText("z.ts");
|
|
await page.keyboard.press("Shift+F7");
|
|
await page.keyboard.press("Shift+F7");
|
|
await expect(selected).toContainText("a.ts");
|
|
await toolbar.getByRole("button", { name: "Restore Size", exact: true }).click();
|
|
const maximized = await page.evaluate(async () => {
|
|
const layoutPath = "/src/workbench/toolwindows/store.ts";
|
|
return (await import(layoutPath)).useToolWindowLayout.getState().maximized;
|
|
});
|
|
expect(maximized).toBe("left");
|
|
await expect(toolbar).toBeHidden();
|
|
await expect(page.getByRole("tree", { name: "Project", exact: true })).toBeVisible();
|
|
});
|