дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
Compare with Branch… / Compare with Revision… on a folder or multi-selection, two-commit Compare Versions from the Git Log, the branches' Show Branch Diff and Show Diff with Working Tree now open one closable, titled tab per comparison in the Compare tool window instead of a separate comparison window. Only the active comparison loads; closing the last tab, or switching projects, removes the stripe button, which shows the number of open comparisons as its badge. The tabs use the shared Tabs strip (hidden-tabs dropdown, Close Tab / Close All Tabs / Close Other Tabs). Compare with Current keeps the two-pane branch comparison editor and a single file still opens its diff tab. Closes #7813 Co-authored-by: Inf1mum <[email protected]>
116 рядки
5.8 KiB
TypeScript
116 рядки
5.8 KiB
TypeScript
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
|
|
|
test("Branch comparison reuses one editor tab and keeps both commit ranges independent", async ({
|
|
workbench: page,
|
|
}) => {
|
|
const branch = "feature/settlement-reconciliation-and-international-ledger-reporting";
|
|
const current = "feature/review-quarterly-settlement-audit";
|
|
const incomingSubject = "Keep regional settlement references stable during the report export";
|
|
const outgoingSubject = "Preserve the audit trail for settlement retries";
|
|
await page.setViewportSize({ width: 1120, height: 760 });
|
|
await stubDesktop(page);
|
|
await page.evaluate(
|
|
async ({ branch, current, incomingSubject, outgoingSubject }) => {
|
|
const root = "/dev/acme-api";
|
|
const branchInfo = {
|
|
head: current,
|
|
headCommit: "b".repeat(40),
|
|
upstream: null,
|
|
ahead: 0,
|
|
behind: 0,
|
|
operation: null,
|
|
};
|
|
const entry = (letter: string, summary: string) => ({
|
|
id: letter.repeat(40),
|
|
shortId: letter.repeat(8),
|
|
parents: ["a".repeat(40)],
|
|
refs: [],
|
|
summary,
|
|
message: summary + "\n\nUpdate the audit report context.",
|
|
author: "Sam Rivera",
|
|
email: "[email protected]",
|
|
timeMs: 1795100000000,
|
|
});
|
|
const h = window.__ipc.handlers;
|
|
h.vcs_roots = () => [{ root, ...branchInfo }];
|
|
h.vcs_branch_info = () => branchInfo;
|
|
h.vcs_status = () => [];
|
|
h.vcs_branches = () => [];
|
|
h.vcs_log_refs = () => ({});
|
|
h.vcs_config_get = () => null;
|
|
h.vcs_commit_files = () => [];
|
|
h.vcs_log_details_batch = ({ revisions }) =>
|
|
(revisions as string[]).map(() => ({ message: "", containingBranches: [], signature: "N" }));
|
|
h.vcs_log = ({ query }) => {
|
|
const { ranges, skip, text } = query as { ranges: string[]; skip: number; text: string | null };
|
|
if (skip) return [];
|
|
const range = ranges?.[0];
|
|
const rows =
|
|
range === `refs/heads/${current}..refs/heads/${branch}`
|
|
? [entry("c", incomingSubject)]
|
|
: range === `refs/heads/${branch}..refs/heads/${current}`
|
|
? [entry("b", outgoingSubject)]
|
|
: [];
|
|
return text ? rows.filter((commit) => commit.summary.includes(text)) : rows;
|
|
};
|
|
h.window_open_comparison = () => null;
|
|
const store = "/src/features/vcs/store.ts";
|
|
const { useVcs } = await import(/* @vite-ignore */ store);
|
|
useVcs.setState({ available: true, root, repo: root, roots: [root], branch: branchInfo });
|
|
const path = "/src/platform/actions.ts";
|
|
const { executeAction } = await import(/* @vite-ignore */ path);
|
|
const target = { name: branch, rev: `refs/heads/${branch}` };
|
|
await executeAction("vcs.log.compareBranches", target);
|
|
await executeAction("vcs.log.compareBranches", target);
|
|
},
|
|
{ branch, current, incomingSubject, outgoingSubject },
|
|
);
|
|
await expect(page.getByRole("tab", { name: new RegExp(`Compare ${current}`) })).toHaveCount(1);
|
|
const incomingPane = page.getByRole("region", { name: `In ${branch}, not in ${current}` });
|
|
const outgoingPane = page.getByRole("region", { name: `In ${current}, not in ${branch}` });
|
|
const incoming = incomingPane.getByRole("listbox", { name: "Commits" });
|
|
const outgoing = outgoingPane.getByRole("listbox", { name: "Commits" });
|
|
await expect(incoming.getByText(incomingSubject, { exact: true })).toBeVisible();
|
|
await expect(outgoing.getByText(outgoingSubject, { exact: true })).toBeVisible();
|
|
await incoming.getByText(incomingSubject, { exact: true }).click();
|
|
await outgoing.getByText(outgoingSubject, { exact: true }).click();
|
|
await expect(incoming.getByRole("option", { selected: true })).toHaveCount(1);
|
|
await expect(outgoing.getByRole("option", { selected: true })).toHaveCount(1);
|
|
const search = incomingPane.getByRole("textbox", { name: "Filter by message" });
|
|
await search.click();
|
|
await search.fill("does not match");
|
|
await expect(incoming.getByRole("option")).toHaveCount(0);
|
|
await expect(outgoing.getByText(outgoingSubject, { exact: true })).toBeVisible();
|
|
await search.fill("");
|
|
await expect(incoming.getByText(incomingSubject, { exact: true })).toBeVisible();
|
|
const divider = page.getByRole("separator", { name: "Resize branch comparison panes" });
|
|
await expect(divider).toHaveAttribute("aria-orientation", "horizontal");
|
|
const start = (await divider.boundingBox())!.y;
|
|
await divider.focus();
|
|
await page.keyboard.press("ArrowDown");
|
|
await expect.poll(async () => (await divider.boundingBox())!.y).toBeGreaterThan(start + 1);
|
|
|
|
await page.setViewportSize({ width: 440, height: 660 });
|
|
const heading = incomingPane.getByRole("heading", { name: new RegExp(`In ${branch}`) });
|
|
await expect.poll(() => heading.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
|
await expect(incoming.getByRole("option")).toBeVisible();
|
|
await expect(outgoing.getByRole("option")).toBeVisible();
|
|
await page.getByRole("button", { name: "Show Branch Diff", exact: true }).click();
|
|
// The comparison opens as a tab of the Compare tool window, not a separate window.
|
|
await expect(
|
|
page
|
|
.getByRole("tablist", { name: "Comparisons" })
|
|
.getByRole("tab", { name: new RegExp(`^Changes between .*${branch}`) }),
|
|
).toBeVisible();
|
|
expect(await ipcCalls(page, "window_open_comparison")).toEqual([]);
|
|
await page.getByRole("tablist", { name: "Editor tabs" }).getByRole("button", { name: "Close Tab" }).click();
|
|
await expect(incomingPane).toHaveCount(0);
|
|
await expect(outgoingPane).toHaveCount(0);
|
|
const openScopes = await page.evaluate(async () => {
|
|
const path = "/src/features/vcs/logStore.ts";
|
|
const { useGitLog } = await import(/* @vite-ignore */ path);
|
|
return useGitLog.getState().logTabs.filter((tab: { comparison?: unknown }) => tab.comparison).length;
|
|
});
|
|
expect(openScopes).toBe(0);
|
|
});
|