Файли
openidea/e2e/editorGitMenu.spec.ts
T
faysouтаfaysou cd3399df60 fix(vcs): keep selection history in the editor Git menu (#5654)
The shared Git submenu (#5611) dropped Show History for Selection from the editor's context menu. It is back for a right-click in the editor and stays out of the tab and Project view menus. The browser tests now use the shared menu's labels and groups, including keyboard navigation to Get from Version Control….

Co-authored-by: faysou <[email protected]>
2026-11-25 02:17:58 +08:00

84 рядки
3.5 KiB
TypeScript

import { expect, openFromTree, test } from "./fixtures";
test("editor Git submenu offers the registered file and repository actions in groups", async ({ workbench: page }) => {
const editor = await openFromTree(page, "README.md");
await editor.locator(".cm-content").click({ button: "right" });
await page.getByRole("menuitem", { name: "Git", exact: true }).hover();
const git = page
.getByRole("menu")
.filter({ has: page.getByRole("menuitem", { name: "Get from Version Control…", exact: true }) });
await expect(git.locator('[role="menuitem"], [role="menuitemcheckbox"]')).toHaveText([
/Commit File…/,
/^Add(?:⌥⌘A)?$/,
/Add to \.gitignore/,
/Annotate with Git Blame/,
/Show Diff/,
/Compare with Branch…/,
/Compare with Revision…/,
/Show History$/,
/Show Current Revision/,
/Show History for Selection/,
/Rollback…/,
/Push…/,
/Pull…/,
/Fetch/,
/Merge…/,
/Rebase…/,
/Branches…/,
/New Branch…/,
/New Tag…/,
/Reset HEAD…/,
/Stash Changes…/,
/Unstash Changes…/,
/GitHub/,
/Manage Remotes…/,
/Get from Version Control…/,
]);
await expect(git.getByRole("separator")).toHaveCount(6);
await git.getByRole("menuitem", { name: "GitHub", exact: true }).hover();
for (const name of ["View Pull Requests", "Create Pull Request…", "Checkout Pull Request…", "Open on GitHub"]) {
await expect(page.getByRole("menuitem", { name: new RegExp(`^${name}`) })).toBeEnabled();
}
});
test("editor Git submenu keeps repository actions disabled without Git", async ({ workbench: page }) => {
const editor = await openFromTree(page, "README.md");
await page.evaluate(async () => {
const projectModule = "/src/platform/project.ts";
const contextModule = "/src/platform/context.ts";
const { useProject } = await import(/* @vite-ignore */ projectModule);
const { setContext } = await import(/* @vite-ignore */ contextModule);
useProject.setState((s: { project: object }) => ({ project: { ...s.project, isGit: false } }));
setContext("vcsAvailable", false);
});
await editor.locator(".cm-content").click({ button: "right" });
await page.getByRole("menuitem", { name: "Git", exact: true }).hover();
for (const name of [
"Merge…",
"Rebase…",
"New Branch…",
"New Tag…",
"Reset HEAD…",
"Stash Changes…",
"Unstash Changes…",
"Manage Remotes…",
]) {
await expect(page.getByRole("menuitem", { name: new RegExp(`^${name}`) })).toBeDisabled();
}
await expect(page.getByRole("menuitem", { name: "Get from Version Control…", exact: true })).toBeEnabled();
});
test("Project view Git submenu ends with Manage Remotes and Clone", async ({ workbench: page }) => {
await page.getByRole("treeitem", { name: /README\.md/ }).click({ button: "right" });
await page.getByRole("menuitem", { name: "Git", exact: true }).hover();
const git = page
.getByRole("menu")
.filter({ has: page.getByRole("menuitem", { name: "Get from Version Control…", exact: true }) });
const items = git.locator('[role="menuitem"], [role="menuitemcheckbox"]');
await expect(items.nth(-3)).toHaveText(/GitHub/);
await expect(items.nth(-2)).toHaveText(/Manage Remotes…/);
await expect(items.nth(-1)).toHaveText(/Get from Version Control…/);
await git.getByRole("menuitem", { name: "Manage Remotes…", exact: true }).click();
await expect(page.getByRole("dialog", { name: "Git Remotes" })).toBeVisible();
});