Files
co-lite/solvway-customer-portal/app/components/BottomNav.test.tsx
T
ngqileandClaude Opus 5.5 5ee51d1913 chore: copy kept Tastefully modules and portals into Co-Lite
Backend modules from tastefully 8bd93d15: core-libs, core-session,
api-gateway, mobile-api, services-auth, services-system,
services-counter, services-member, services-log, services-email.
solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal
from tastefully 8bd93d15. Copied as tracked files only.

Literal secrets replaced with environment placeholders:
- services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY,
  MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default)
- services-system: JUMIO_TOKEN, JUMIO_SECRET (optional)
- services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed
- core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default
  removed, ipgeolocation key read from IPGEOLOCATION_API_KEY
- services-system EkycAppConfig: commented Jumio credentials removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-26 15:55:45 +08:00

72 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
// Non-auth path so the nav renders (it returns null on auth paths).
vi.mock("next/navigation", () => ({
usePathname: () => "/",
useRouter: () => ({ push: vi.fn(), replace: vi.fn() }),
}));
vi.mock("@/app/lib/ThemeContext", () => ({
useTheme: () => ({ isDark: false, toggle: vi.fn() }),
}));
// next/link needs the app-router context; stub it to a plain anchor.
vi.mock("next/link", () => ({
default: ({ href, children, className }: { href: string; children: React.ReactNode; className?: string }) => (
<a href={href} className={className}>{children}</a>
),
}));
import BottomNav from "./BottomNav";
describe("BottomNav", () => {
it("reserves the bottom safe-area inset so controls clear the home indicator", () => {
const { container } = render(<BottomNav />);
const nav = container.querySelector("nav");
expect(nav).not.toBeNull();
expect(nav!.className).toContain("pb-[env(safe-area-inset-bottom)]");
});
it("gives the icon-only centre check-in button an accessible name (TASTE-148)", () => {
render(<BottomNav />);
expect(screen.getByRole("button", { name: "Scan QR to check in" })).toBeInTheDocument();
});
describe("at large device font sizes", () => {
// Regression: at 150–200% font the rem-based bar/FAB ballooned, labels touched, and the
// right-hand tabs ran off a 390px screen. These guard the intent; the layout itself was
// verified in a real browser at 100/150/200%.
it("caps each tab label's size so four labels still fit beside the check-in button", () => {
render(<BottomNav />);
for (const label of ["Home", "Events", "Points", "Profile"]) {
const el = screen.getByText(label);
// jsdom cannot parse min() in inline styles, so the cap is a Tailwind class.
expect(el.className).toContain("text-[length:min(0.875rem,20px)]");
expect(el.className).toContain("whitespace-nowrap");
}
});
it("lets the bar height follow its content instead of a fixed rem height", () => {
const { container } = render(<BottomNav />);
const row = container.querySelector("nav > div") as HTMLElement;
const tokens = row.className.split(/\s+/);
expect(tokens).toContain("min-h-[64px]");
expect(tokens).not.toContain("h-16");
});
it("keeps the check-in button and its spacer a fixed 64px so they do not grow with the font", () => {
render(<BottomNav />);
const fab = screen.getByRole("button", { name: "Scan QR to check in" });
expect(fab.className).toContain("w-[64px]");
expect(fab.className).toContain("h-[64px]");
expect(fab.className).not.toMatch(/(^|\s)w-16(\s|$)/);
// the spacer column that reserves the FAB's width in the row
expect((fab.closest(".relative.flex.justify-center") as HTMLElement).className).toContain("w-[64px]");
});
it("lets a tab shrink (min-w-0) so one long label cannot push its neighbours off screen", () => {
render(<BottomNav />);
expect(screen.getByText("Profile").closest("a")!.className).toContain("min-w-0");
});
});
});