diff --git a/apps/web/src/components/sidebar/SidebarChrome.browser.test.tsx b/apps/web/src/components/sidebar/SidebarChrome.browser.test.tsx new file mode 100644 index 000000000000..b82a1c013d99 --- /dev/null +++ b/apps/web/src/components/sidebar/SidebarChrome.browser.test.tsx @@ -0,0 +1,46 @@ +import { expect, it, vi } from "vite-plus/test"; +import { page, userEvent } from "vite-plus/test/browser"; + +import "~/index.css"; +import { render } from "../../../test/render"; +import { SharedTooltipProvider } from "../ui/shared-tooltip"; +import { SidebarProvider } from "../ui/sidebar"; +import { SidebarChromeHeader } from "./SidebarChrome"; + +vi.mock(import("../../state/server"), async (original) => { + const actual = await original(); + const { Atom } = await import("effect/reactivity"); + const { compileResolvedKeybindingsConfig } = await import("@t3tools/shared/keybindings"); + const keybindings = compileResolvedKeybindingsConfig([ + { key: "alt+left", command: "navigation.back" }, + { key: "alt+right", command: "navigation.forward" }, + ]); + return { ...actual, primaryServerKeybindingsAtom: Atom.make(keybindings) }; +}); + +vi.mock(import("../../navigationHistory"), async (original) => ({ + ...(await original()), + useCanNavigateHistory: () => false, +})); + +it("shows the configured shortcut on each disabled desktop history button", async () => { + await page.viewport(1280, 800); + using _platform = vi.spyOn(navigator, "platform", "get").mockReturnValue("Linux x86_64"); + await using screen = await render( + + + + + , + ); + + for (const [label, shortcut] of [ + ["Go back", "Alt+Left"], + ["Go forward", "Alt+Right"], + ] as const) { + const button = screen.getByRole("button", { name: label }); + await expect.element(button).toBeDisabled(); + await userEvent.hover(button, { force: true }); + await expect.element(page.getByText(`${label} (${shortcut})`, { exact: true })).toBeVisible(); + } +}); diff --git a/apps/web/src/components/sidebar/SidebarChrome.tsx b/apps/web/src/components/sidebar/SidebarChrome.tsx index 76ff74960080..3bd45de5b215 100644 --- a/apps/web/src/components/sidebar/SidebarChrome.tsx +++ b/apps/web/src/components/sidebar/SidebarChrome.tsx @@ -141,20 +141,30 @@ function HistoryNavigationButton({ direction === "back" ? "navigation.back" : "navigation.forward", ); const Icon = direction === "back" ? ArrowLeftIcon : ArrowRightIcon; + const button = ( + + ); return ( navigateHistory(direction)} - size="icon-sm" - variant={onBackdrop ? "media-navigation" : "ghost"} - /> + enabled ? ( + button + ) : ( + {button} + ) } label={ <> @@ -163,9 +173,7 @@ function HistoryNavigationButton({ } side="bottom" - > - - + /> ); }