feat: migrate to Next.js for Mini App and enhance project structure
- 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.
This commit is contained in:
17
webapp-next/src/test/setup.ts
Normal file
17
webapp-next/src/test/setup.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { vi } from "vitest";
|
||||
|
||||
// jsdom does not provide window.matchMedia (used by use-media-query and use-telegram-theme).
|
||||
Object.defineProperty(window, "matchMedia", {
|
||||
writable: true,
|
||||
value: vi.fn().mockImplementation((query: string) => ({
|
||||
matches: false,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addListener: vi.fn(),
|
||||
removeListener: vi.fn(),
|
||||
addEventListener: vi.fn(),
|
||||
removeEventListener: vi.fn(),
|
||||
dispatchEvent: vi.fn(),
|
||||
})),
|
||||
});
|
||||
34
webapp-next/src/test/test-utils.tsx
Normal file
34
webapp-next/src/test/test-utils.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Test utilities: custom render with app store and optional providers.
|
||||
*/
|
||||
|
||||
import React, { ReactElement } from "react";
|
||||
import { render, RenderOptions } from "@testing-library/react";
|
||||
import { useAppStore } from "@/store/app-store";
|
||||
|
||||
/** Reset app store to a known state before tests that need it. */
|
||||
export function resetAppStore() {
|
||||
const state = useAppStore.getState();
|
||||
state.setLang("en");
|
||||
state.setCurrentMonth(new Date(2025, 0, 1)); // Feb 2025
|
||||
state.setDuties([]);
|
||||
state.setCalendarEvents([]);
|
||||
state.setLoading(false);
|
||||
state.setError(null);
|
||||
state.setAccessDenied(false);
|
||||
state.setCurrentView("calendar");
|
||||
state.setSelectedDay(null);
|
||||
}
|
||||
|
||||
function AllTheProviders({ children }: { children: React.ReactNode }) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
function customRender(ui: ReactElement, options?: Omit<RenderOptions, "wrapper">) {
|
||||
return render(ui, {
|
||||
wrapper: AllTheProviders,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
export { customRender as render };
|
||||
Reference in New Issue
Block a user