Файли
openidea/e2e/gitAnnotateLayout.spec.ts
T
audichuang cc5d9d95e4 feat(vcs): bold the current revision's lines in the annotate gutter (#6594)
Lines last changed by the file's current revision are drawn bold in a last-commit colour in the Annotate gutter. The current revision is the last commit to the file at HEAD, or at the annotated revision for Annotate Revision and the diff/merge panes; it is read with vcs_log after the gutter paints and again when HEAD moves. The colour is a new token, --git-annotations-last-commit, listed under Color Scheme > Git > Annotations > Last commit and imported/exported as ANNOTATIONS_LAST_COMMIT_COLOR.

Refs #6397

Co-authored-by: audichuang <[email protected]>
2026-11-28 05:55:03 +08:00

113 рядки
5.2 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
import { expect, openFromTree, stubDesktop, test } from "./fixtures";
test("Git annotations align dates and full author names at UI text size", async ({ workbench: page }) => {
const editor = await openFromTree(page, "build.gradle.kts");
await stubDesktop(page);
const longEmail = `reconciliation+${"regional-settlement-".repeat(5)}[email protected]`;
await page.evaluate(async (email) => {
const root = "/dev/acme-api";
const file = `${root}/build.gradle.kts`;
const handlers = window.__ipc.handlers;
const lines = [
{
commit: "a1234567".padEnd(40, "a"),
author: "Lena Park",
timeMs: Date.UTC(2026, 4, 3, 12),
summary: "Update totals",
},
{
commit: "b1234567".padEnd(40, "b"),
author: "Lena Ortiz",
timeMs: Date.UTC(2026, 8, 23, 12),
summary: "Review totals",
},
];
handlers.vcs_blame = () => lines;
handlers.vcs_log = ({ query }) => {
const { branch, path } = query as { branch?: string | null; path?: string | null };
// The file's last commit, which Annotate draws bold, is the newer one.
const line = path && branch === "HEAD" ? lines[1] : lines.find(({ commit }) => commit === branch);
if (!line) return [];
return [
{
...line,
id: line.commit,
shortId: line.commit.slice(0, 8),
refs: [],
parents: [],
email: line === lines[0] ? "[email protected]" : email,
message: line.summary,
},
];
};
const projectModule = "/src/platform/project.ts";
const { useProject } = await import(/* @vite-ignore */ projectModule);
const { settings } = useProject.getState();
useProject.setState({
settings: {
...settings,
general: { ...settings?.general, dateFormat: { overrideSystem: true, pattern: "d MMMM yyyy" } },
},
});
const storeModule = "/src/features/vcs/store.ts";
const { useVcs } = await import(/* @vite-ignore */ storeModule);
useVcs.setState({ available: true, root, repo: root, roots: [root] });
const contextModule = "/src/platform/context.ts";
const { setContext } = await import(/* @vite-ignore */ contextModule);
setContext("vcsAvailable", true);
// Options › Names › Full Name: the default (Last Name) would hide what is measured here.
const blameModule = "/src/features/vcs/blame.ts";
const { useAnnotateNames } = await import(/* @vite-ignore */ blameModule);
useAnnotateNames.setState({ names: "fullName" });
const actionsModule = "/src/platform/actions.ts";
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
await executeAction("vcs.annotate", file);
}, longEmail);
const gutter = editor.locator(".cm-vcs-blame");
const first = gutter.locator("[data-commit]").filter({ hasText: "3 May 2026" });
const second = gutter.locator("[data-commit]").filter({ hasText: "23 September 2026" });
const firstAuthor = first.locator(".cm-vcs-blame-author");
const secondAuthor = second.locator(".cm-vcs-blame-author");
await expect(firstAuthor).toHaveText("Lena Park");
await expect(secondAuthor).toHaveText("Lena Ortiz");
await expect
.poll(async () => Math.abs((await firstAuthor.boundingBox())!.x - (await secondAuthor.boundingBox())!.x))
.toBeLessThan(1);
// The bold labels of the file's last commit still fit their columns.
await expect(secondAuthor).toHaveCSS("font-weight", "700");
await expect(firstAuthor).toHaveCSS("font-weight", "400");
for (const cell of [second.locator(".cm-vcs-blame-date"), secondAuthor])
await expect.poll(() => cell.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(0);
await first.hover();
const details = page.getByRole("dialog").filter({ has: page.getByTitle("Show Commit in Git Log") });
await expect(details).toContainText("[email protected]");
await expect.poll(async () => (await details.boundingBox())!.width).toBeLessThan(400);
await expect(details.getByTitle("Show Commit in Git Log")).toHaveCSS(
"font-family",
await details.evaluate((el) => getComputedStyle(el).fontFamily),
);
await page.setViewportSize({ width: 430, height: 640 });
await second.hover();
await expect(details).toContainText(longEmail);
await expect(details).toBeInViewport({ ratio: 1 });
await expect.poll(() => details.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
const uiSize = await editor.evaluate((el) => getComputedStyle(el).getPropertyValue("--fs-ui").trim());
await expect(firstAuthor).toHaveCSS("font-size", uiSize);
const firstRevision = first.locator(".cm-vcs-blame-revision");
await expect(firstRevision).toBeHidden();
await second.click({ button: "right" });
await page.getByRole("menuitem", { name: "Options", exact: true }).hover();
await page.getByRole("menuitemcheckbox", { name: "Revision", exact: true }).click();
await expect(firstRevision).toBeVisible();
expect((await firstRevision.boundingBox())!.x).toBeLessThan(
(await first.locator(".cm-vcs-blame-date").boundingBox())!.x,
);
await expect
.poll(async () => Math.abs((await firstAuthor.boundingBox())!.x - (await secondAuthor.boundingBox())!.x))
.toBeLessThan(1);
});