diff --git a/e2e/logBranchRenameFollow.spec.ts b/e2e/logBranchRenameFollow.spec.ts index f60232491..61c83e3d6 100644 --- a/e2e/logBranchRenameFollow.spec.ts +++ b/e2e/logBranchRenameFollow.spec.ts @@ -74,6 +74,7 @@ async function openLogOnSd(page: Page) { 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 = () => []; @@ -99,6 +100,9 @@ async function openLogOnSd(page: Page) { 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"; @@ -108,6 +112,33 @@ async function openLogOnSd(page: Page) { await expect(page.getByRole("listbox", { name: "Commits" }).getByRole("option").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 }); diff --git a/src/features/vcs/__tests__/focusTextFilter.test.ts b/src/features/vcs/__tests__/focusTextFilter.test.ts new file mode 100644 index 000000000..49e35d8da --- /dev/null +++ b/src/features/vcs/__tests__/focusTextFilter.test.ts @@ -0,0 +1,73 @@ +import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { executeAction, getAction, isActionKeyEnabled } from "@/platform/actions"; +import { getContext, setContext } from "@/platform/context"; +import { IDEA_ACTIONS } from "@/platform/ideaActions"; +import { intellijMacos } from "@/platform/keymaps/intellij-macos"; +import { intellijWindows } from "@/platform/keymaps/intellij-windows"; +import { registerHistoryActions } from "../historyActions"; + +let unregister: (() => void) | undefined; +const originalContext = getContext(); + +beforeEach(() => { + setContext("vcsAvailable", true); + setContext("activeToolWindow", "git"); + document.body.innerHTML = ` +
+