- Replaced the previous webapp with a new Mini App built using Next.js, improving performance and maintainability. - Updated the `.gitignore` to exclude Next.js build artifacts and node modules. - Revised documentation in `AGENTS.md`, `README.md`, and `architecture.md` to reflect the new Mini App structure and technology stack. - Enhanced Dockerfile to support the new build process for the Next.js application. - Updated CI workflow to build and test the Next.js application. - Added new configuration options for the Mini App, including `MINI_APP_SHORT_NAME` for improved deep linking. - Refactored frontend testing setup to accommodate the new structure and testing framework. - Removed legacy webapp files and dependencies to streamline the project.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
/**
|
|
* Integration test for main page: calendar and header visible, lang from store.
|
|
* Ported from webapp/js/main.test.js applyLangToUi.
|
|
*/
|
|
|
|
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
import Page from "./page";
|
|
import { resetAppStore } from "@/test/test-utils";
|
|
import { useAppStore } from "@/store/app-store";
|
|
|
|
vi.mock("@/hooks/use-telegram-auth", () => ({
|
|
useTelegramAuth: () => ({
|
|
initDataRaw: "test-init",
|
|
startParam: undefined,
|
|
isLocalhost: true,
|
|
}),
|
|
}));
|
|
|
|
vi.mock("@/hooks/use-month-data", () => ({
|
|
useMonthData: () => ({
|
|
retry: vi.fn(),
|
|
}),
|
|
}));
|
|
|
|
describe("Page", () => {
|
|
beforeEach(() => {
|
|
resetAppStore();
|
|
});
|
|
|
|
it("renders calendar and header when store has default state", async () => {
|
|
render(<Page />);
|
|
expect(await screen.findByRole("grid", { name: "Calendar" })).toBeInTheDocument();
|
|
expect(screen.getByRole("button", { name: /previous month/i })).toBeInTheDocument();
|
|
expect(screen.getByRole("button", { name: /next month/i })).toBeInTheDocument();
|
|
});
|
|
|
|
it("sets document title and lang from store lang", async () => {
|
|
useAppStore.getState().setLang("en");
|
|
render(<Page />);
|
|
await screen.findByRole("grid", { name: "Calendar" });
|
|
expect(document.title).toBe("Duty Calendar");
|
|
expect(document.documentElement.lang).toBe("en");
|
|
});
|
|
|
|
it("sets document title for ru when store lang is ru", async () => {
|
|
(globalThis.window as unknown as { __DT_LANG?: string }).__DT_LANG = "ru";
|
|
render(<Page />);
|
|
await screen.findByRole("grid", { name: "Calendar" });
|
|
await waitFor(() => {
|
|
expect(document.title).toBe("Календарь дежурств");
|
|
});
|
|
});
|
|
});
|