дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
Adds Maximize Commit Message after Copy Revision Number in the Git Log and File History commit menus and on the commit details toolbar. It opens a resizable, scrollable dialog with the full message and metadata of every selected commit (read-only commits included); disabled without a selection. Co-authored-by: muutot <[email protected]>
240 рядки
10 KiB
TypeScript
240 рядки
10 KiB
TypeScript
/**
|
|
* Renaming a branch follows in the Git Log: the Branch filter chip keeps naming
|
|
* the branch under its new name (and the remembered choice follows), instead of
|
|
* filtering an unknown revision. Git is stubbed at the IPC layer.
|
|
*/
|
|
import type { Page } from "@playwright/test";
|
|
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
|
|
|
const ROOT = "/dev/acme-api";
|
|
|
|
interface StubBranch {
|
|
name: string;
|
|
current: boolean;
|
|
remote: boolean;
|
|
upstream: string | null;
|
|
ahead: number;
|
|
behind: number;
|
|
lastCommitMs: number | null;
|
|
commit: string;
|
|
}
|
|
|
|
/** Installs a two-branch repository (`sd` checked out) and opens the Git Log on `HEAD`. */
|
|
async function openLogOnSd(page: Page) {
|
|
await stubDesktop(page);
|
|
await page.evaluate(async (root) => {
|
|
const h = window.__ipc.handlers;
|
|
const commits = Array.from({ length: 6 }, (_, i) => ({
|
|
id: i.toString(16).padStart(40, "0"),
|
|
shortId: i.toString(16).padStart(8, "0"),
|
|
parents: i + 1 < 6 ? [(i + 1).toString(16).padStart(40, "0")] : [],
|
|
refs: i === 0 ? ["HEAD", "sd"] : [],
|
|
author: "Author",
|
|
email: "[email protected]",
|
|
timeMs: 20 - i,
|
|
summary: `Commit ${i}`,
|
|
message: `Commit ${i}\n\nBody ${i}`,
|
|
}));
|
|
let head = "sd";
|
|
let branches: StubBranch[] = [
|
|
{
|
|
name: "sd",
|
|
current: true,
|
|
remote: false,
|
|
upstream: null,
|
|
ahead: 0,
|
|
behind: 0,
|
|
lastCommitMs: 20,
|
|
commit: commits[0]!.id,
|
|
},
|
|
{
|
|
name: "main",
|
|
current: false,
|
|
remote: false,
|
|
upstream: null,
|
|
ahead: 0,
|
|
behind: 0,
|
|
lastCommitMs: 20,
|
|
commit: commits[5]!.id,
|
|
},
|
|
];
|
|
h.vcs_log = ({ query }) => {
|
|
const { skip, limit } = query as { skip: number; limit: number };
|
|
return commits.slice(skip, limit ? skip + limit : undefined);
|
|
};
|
|
h.vcs_log_refs = () => ({});
|
|
h.vcs_log_users = () => ["Author <[email protected]>"];
|
|
h.vcs_roots = () => [{ root, operation: null, head, headCommit: commits[0]!.id, hasRemotes: false }];
|
|
h.vcs_branch_info = () => ({
|
|
head,
|
|
headCommit: commits[0]!.id,
|
|
upstream: null,
|
|
ahead: 0,
|
|
behind: 0,
|
|
operation: null,
|
|
});
|
|
h.vcs_status = () => [];
|
|
h.fs_entry_kind = ({ path }) => (/\.(ts|md)$/.test(String(path)) ? "file" : "dir");
|
|
h.vcs_branches = () => branches;
|
|
h.vcs_stashes = () => [];
|
|
h.vcs_tags = () => [];
|
|
h.vcs_config_get = () => null;
|
|
h.vcs_rename_branch = (args) => {
|
|
const { from, to } = args as { from: string; to: string };
|
|
if (!branches.some((b) => !b.remote && b.name === from))
|
|
throw { kind: "failed", message: "no such branch", detail: null };
|
|
head = to;
|
|
branches = branches.map((b) => (b.name === from ? { ...b, name: to } : b));
|
|
return null;
|
|
};
|
|
h.vcs_commit_files = () => [];
|
|
h.vcs_log_details_batch = ({ revisions }) =>
|
|
(revisions as string[]).map(() => ({
|
|
message: "",
|
|
containingBranches: [],
|
|
signature: "N",
|
|
signer: "",
|
|
key: "",
|
|
fingerprint: "",
|
|
}));
|
|
const storeModule = "/src/features/vcs/store.ts";
|
|
const { useVcs, refreshNow, loadBranches } = await import(/* @vite-ignore */ storeModule);
|
|
useVcs.setState({ available: true, root, repo: root, roots: [root], branchesLoaded: false, stashesLoaded: false });
|
|
const contextModule = "/src/platform/context.ts";
|
|
const { setContext } = await import(/* @vite-ignore */ contextModule);
|
|
setContext("vcsAvailable", true);
|
|
await refreshNow();
|
|
await loadBranches();
|
|
const actionsModule = "/src/platform/actions.ts";
|
|
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
|
await executeAction("vcs.showLog");
|
|
}, ROOT);
|
|
await expect(page.getByRole("listbox", { name: "Commits" }).getByRole("option").first()).toBeVisible();
|
|
}
|
|
|
|
test("Maximize Commit Message opens one or several full messages and closes with Escape", async ({
|
|
workbench: page,
|
|
}) => {
|
|
await openLogOnSd(page);
|
|
const commits = page.getByRole("listbox", { name: "Commits" });
|
|
const first = commits.getByRole("option").nth(0);
|
|
const second = commits.getByRole("option").nth(1);
|
|
|
|
await first.click({ button: "right" });
|
|
await page.getByRole("menuitem", { name: "Maximize Commit Message", exact: true }).click();
|
|
const single = page.getByRole("dialog", { name: "Commit Message", exact: true });
|
|
await expect(single).toContainText("Commit 0");
|
|
await expect(single).toContainText("Body 0");
|
|
await page.keyboard.press("Escape");
|
|
await expect(single).toBeHidden();
|
|
|
|
await first.click();
|
|
await second.click({ modifiers: ["ControlOrMeta"] });
|
|
await first.click({ button: "right" });
|
|
await page.getByRole("menuitem", { name: "Maximize Commit Message", exact: true }).click();
|
|
const multiple = page.getByRole("dialog", { name: "Commit Messages", exact: true });
|
|
await expect(multiple).toContainText("Body 0");
|
|
await expect(multiple).toContainText("Body 1");
|
|
await page.keyboard.press("Escape");
|
|
await expect(multiple).toBeHidden();
|
|
});
|
|
|
|
test("Refresh (Cmd+R) refreshes the visible Git Log and File History repositories", async ({ workbench: page }) => {
|
|
await openLogOnSd(page);
|
|
const commits = page.getByRole("listbox", { name: "Commits" });
|
|
const first = commits.getByRole("option").first();
|
|
const logCalls = await ipcCalls(page, "vcs_log");
|
|
const signatureCalls = await ipcCalls(page, "vcs_invalidate_log_signatures");
|
|
|
|
await commits.focus();
|
|
await page.keyboard.press("Meta+R");
|
|
await expect.poll(async () => (await ipcCalls(page, "vcs_log")).length).toBeGreaterThan(logCalls.length);
|
|
await expect
|
|
.poll(async () => (await ipcCalls(page, "vcs_invalidate_log_signatures")).length)
|
|
.toBeGreaterThan(signatureCalls.length);
|
|
await expect(first).toBeVisible();
|
|
|
|
await page.getByRole("treeitem", { name: "README.md", exact: true }).click({ button: "right" });
|
|
await page.getByRole("menuitem", { name: "Git", exact: true }).hover();
|
|
await page.getByRole("menuitem", { name: "Show History", exact: true }).click();
|
|
const historyTab = page.getByRole("tablist", { name: "Git" }).getByRole("tab", { name: /History: README.md/ });
|
|
await expect(historyTab).toHaveAttribute("aria-selected", "true");
|
|
await expect(first).toBeVisible();
|
|
const historyLogCalls = (await ipcCalls(page, "vcs_log")).length;
|
|
const historySignatureCalls = (await ipcCalls(page, "vcs_invalidate_log_signatures")).length;
|
|
|
|
await commits.focus();
|
|
await page.keyboard.press("Meta+R");
|
|
await expect.poll(async () => (await ipcCalls(page, "vcs_log")).length).toBeGreaterThan(historyLogCalls);
|
|
await expect
|
|
.poll(async () => (await ipcCalls(page, "vcs_invalidate_log_signatures")).length)
|
|
.toBeGreaterThan(historySignatureCalls);
|
|
await expect(first).toBeVisible();
|
|
});
|
|
|
|
test("Ctrl+L toggles focus between Git Log filters and commits, including File History", async ({
|
|
workbench: page,
|
|
}) => {
|
|
await openLogOnSd(page);
|
|
const toolbar = page.getByRole("toolbar", { name: "Log filters", exact: true });
|
|
const filter = toolbar.getByRole("textbox", { name: "Filter by message" });
|
|
const commits = page.getByRole("listbox", { name: "Commits" });
|
|
|
|
await commits.focus();
|
|
await page.keyboard.press("Control+L");
|
|
await expect(filter).toBeFocused();
|
|
await page.keyboard.press("Control+L");
|
|
await expect(commits).toBeFocused();
|
|
|
|
await page.getByRole("treeitem", { name: "README.md", exact: true }).click({ button: "right" });
|
|
await page.getByRole("menuitem", { name: "Git", exact: true }).hover();
|
|
await page.getByRole("menuitem", { name: "Show History", exact: true }).click();
|
|
const historyTab = page.getByRole("tablist", { name: "Git" }).getByRole("tab", { name: /History: README.md/ });
|
|
await expect(historyTab).toHaveAttribute("aria-selected", "true");
|
|
await expect(filter).toBeVisible();
|
|
await commits.focus();
|
|
await page.keyboard.press("Control+L");
|
|
await expect(filter).toBeFocused();
|
|
await page.keyboard.press("Control+L");
|
|
await expect(commits).toBeFocused();
|
|
});
|
|
|
|
test("the log branch filter follows a branch rename from the log's own toolbar", async ({ workbench: page }) => {
|
|
await openLogOnSd(page);
|
|
const toolbar = page.getByRole("toolbar", { name: "Log filters", exact: true });
|
|
// First open settles the filter on HEAD; the chip names it.
|
|
await expect(toolbar.getByRole("button", { name: "Branch: HEAD", exact: true })).toBeVisible();
|
|
|
|
// Choose the branch `sd` in the filter popup, as the user would.
|
|
await toolbar.getByRole("button", { name: "Branch: HEAD", exact: true }).click();
|
|
const popup = page.getByRole("dialog", { name: "Filter by Branch" });
|
|
await expect(popup).toBeVisible();
|
|
await popup.getByRole("option", { name: "Local", exact: true }).click();
|
|
await popup.getByRole("option", { name: "sd", exact: true }).click();
|
|
await expect(toolbar.getByRole("button", { name: "Branch: sd", exact: true })).toBeVisible();
|
|
|
|
// Rename the branch from its Branches pane context menu, as the user would.
|
|
await page.getByRole("tree", { name: "Branches" }).getByRole("treeitem", { name: "sd current" }).click({
|
|
button: "right",
|
|
});
|
|
await page.getByRole("menuitem", { name: "Rename…", exact: true }).click();
|
|
// The prompt dialog: type the new name and confirm.
|
|
const dialog = page.getByRole("dialog", { name: "Rename Branch sd" });
|
|
await expect(dialog).toBeVisible();
|
|
const field = dialog.getByRole("textbox");
|
|
await field.fill("feature");
|
|
await dialog.getByRole("button", { name: "Rename", exact: true }).click();
|
|
|
|
// No error balloon (the old filter would produce "unknown revision sd").
|
|
await expect(page.getByText(/unknown revision/)).toHaveCount(0);
|
|
await expect
|
|
.poll(() => ipcCalls(page, "vcs_rename_branch"))
|
|
.toMatchObject([{ repo: ROOT, from: "sd", to: "feature" }]);
|
|
|
|
// The chip follows the rename; the log reloads without an error row.
|
|
await expect(toolbar.getByRole("button", { name: "Branch: feature", exact: true })).toBeVisible();
|
|
await expect(toolbar.getByRole("button", { name: "Branch: sd", exact: true })).toHaveCount(0);
|
|
await expect(page.getByText(/unknown revision/)).toHaveCount(0);
|
|
await expect(page.getByRole("listbox", { name: "Commits" }).getByRole("option").first()).toBeVisible();
|
|
});
|