feat: enhance theme handling and layout components for Telegram Mini App
- Updated theme resolution logic to utilize a shared inline script for consistent theme application across routes. - Introduced `AppShell` and `ReadyGate` components to manage app readiness and theme synchronization, improving user experience. - Enhanced `GlobalError` and `NotFound` pages with a unified full-screen layout for better accessibility and visual consistency. - Refactored CSS to implement safe area insets for sticky headers and content safety, ensuring proper layout on various devices. - Added unit tests for new functionality and improved existing tests for better coverage and reliability.
This commit is contained in:
@@ -9,11 +9,15 @@ import { ContactLinks } from "./ContactLinks";
|
||||
import { resetAppStore } from "@/test/test-utils";
|
||||
|
||||
const openPhoneLinkMock = vi.fn();
|
||||
const openTelegramProfileMock = vi.fn();
|
||||
const triggerHapticLightMock = vi.fn();
|
||||
|
||||
vi.mock("@/lib/open-phone-link", () => ({
|
||||
openPhoneLink: (...args: unknown[]) => openPhoneLinkMock(...args),
|
||||
}));
|
||||
vi.mock("@/lib/telegram-link", () => ({
|
||||
openTelegramProfile: (...args: unknown[]) => openTelegramProfileMock(...args),
|
||||
}));
|
||||
vi.mock("@/lib/telegram-haptic", () => ({
|
||||
triggerHapticLight: () => triggerHapticLightMock(),
|
||||
}));
|
||||
@@ -22,6 +26,7 @@ describe("ContactLinks", () => {
|
||||
beforeEach(() => {
|
||||
resetAppStore();
|
||||
openPhoneLinkMock.mockClear();
|
||||
openTelegramProfileMock.mockClear();
|
||||
triggerHapticLightMock.mockClear();
|
||||
});
|
||||
|
||||
@@ -82,4 +87,17 @@ describe("ContactLinks", () => {
|
||||
expect(openPhoneLinkMock).toHaveBeenCalledWith("+79991234567");
|
||||
expect(triggerHapticLightMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls openTelegramProfile and triggerHapticLight when Telegram link is clicked", () => {
|
||||
render(
|
||||
<ContactLinks phone={null} username="alice_dev" showLabels={false} />
|
||||
);
|
||||
const tgLink = document.querySelector<HTMLAnchorElement>('a[href*="t.me"]');
|
||||
expect(tgLink).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(tgLink!);
|
||||
|
||||
expect(openTelegramProfileMock).toHaveBeenCalledWith("alice_dev");
|
||||
expect(triggerHapticLightMock).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user