Skip to content

Commit da486bc

Browse files
authored
Merge pull request #992 from Thechamp969/949-sidebar-tooltips-mobile-scroll
Add collapsed sidebar tooltips and interaction tests
2 parents 84ec0c1 + 766b33b commit da486bc

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

‎src/components/Sidebar.test.tsx‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,50 @@ describe("Sidebar", () => {
276276
});
277277
});
278278

279+
describe("issue #949 sidebar behavior", () => {
280+
beforeEach(() => {
281+
localStorage.setItem("sorokit-sidebar-collapsed", "true");
282+
});
283+
284+
it("shows the collapsed navigation tooltip on pointer hover", async () => {
285+
render(
286+
<Sidebar active="wallet" onNavigate={onNavigate} open={false} onClose={onClose} />,
287+
);
288+
const transactions = screen.getByRole("button", { name: "Transactions" });
289+
290+
fireEvent.pointerMove(transactions, { pointerType: "mouse" });
291+
292+
expect(await screen.findByRole("tooltip")).toHaveTextContent("Transactions");
293+
});
294+
295+
it("shows the collapsed navigation tooltip when focused by keyboard", async () => {
296+
render(
297+
<Sidebar active="wallet" onNavigate={onNavigate} open={false} onClose={onClose} />,
298+
);
299+
const transactions = screen.getByRole("button", { name: "Transactions" });
300+
301+
fireEvent.focus(transactions);
302+
303+
expect(await screen.findByRole("tooltip")).toHaveTextContent("Transactions");
304+
expect(transactions).toHaveAttribute("aria-describedby");
305+
});
306+
307+
it("highlights the Transactions item for a nested transaction route", () => {
308+
render(
309+
<Sidebar
310+
active="/transactions/123"
311+
onNavigate={onNavigate}
312+
open={false}
313+
onClose={onClose}
314+
/>,
315+
);
316+
317+
const transactions = screen.getByRole("button", { name: "Transactions" });
318+
expect(transactions).toHaveAttribute("aria-current", "page");
319+
expect(transactions.className).toContain("bg-surface-3");
320+
});
321+
});
322+
279323
describe("nav semantics and keyboard access (#550)", () => {
280324
const NAV_ITEMS = [
281325
"Wallet",

0 commit comments

Comments
 (0)