mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-09-03 12:13:46 +00:00
- footer read 'v0.1' forever; it's injected from package.json at build time now - region picker shows 'Failed to load' instead of an eternal Loading when /iatas errors - selecting text in a modal and releasing over the backdrop no longer closes it (close requires the press to start on the backdrop) - Escape in a dropdown inside the mobile filter sheet closes just the dropdown, not the whole sheet - Shift+Tab right after a modal opens wraps to the last control instead of escaping the focus trap - formatCount rolls 999,999 over to 1M instead of printing 1000k - TABS list moved to lib/constants so AppShell only exports components
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
import { Dropdown } from "../../src/components/Dropdown";
|
|
import { FilterSheet } from "../../src/components/FilterSheet";
|
|
|
|
function TestDropdown() {
|
|
return (
|
|
<Dropdown
|
|
renderTrigger={({ toggle }) => (
|
|
<button type="button" onClick={toggle}>trigger</button>
|
|
)}
|
|
>
|
|
{() => <div data-testid="dropdown-panel">option</div>}
|
|
</Dropdown>
|
|
);
|
|
}
|
|
|
|
describe("Dropdown", () => {
|
|
it("closes on Escape", () => {
|
|
render(<TestDropdown />);
|
|
fireEvent.click(screen.getByText("trigger"));
|
|
expect(screen.getByTestId("dropdown-panel")).toBeInTheDocument();
|
|
|
|
fireEvent.keyDown(document.body, { key: "Escape" });
|
|
expect(screen.queryByTestId("dropdown-panel")).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("Escape closes only the open dropdown, not the sheet underneath", () => {
|
|
// regression: Escape in an open dropdown inside the mobile FilterSheet closed both layers
|
|
const onClose = vi.fn();
|
|
render(
|
|
<FilterSheet onClose={onClose}>
|
|
<TestDropdown />
|
|
</FilterSheet>,
|
|
);
|
|
fireEvent.click(screen.getByText("trigger"));
|
|
expect(screen.getByTestId("dropdown-panel")).toBeInTheDocument();
|
|
|
|
fireEvent.keyDown(document.body, { key: "Escape" });
|
|
expect(screen.queryByTestId("dropdown-panel")).not.toBeInTheDocument();
|
|
expect(onClose).not.toHaveBeenCalled();
|
|
|
|
// with the dropdown closed, Escape reaches the sheet
|
|
fireEvent.keyDown(document.body, { key: "Escape" });
|
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|