45 lines
1.9 KiB
TypeScript
45 lines
1.9 KiB
TypeScript
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
import { renderToString } from "react-dom/server";
|
|
import { MemoryRouter } from "react-router-dom";
|
|
import { describe, expect, it } from "vitest";
|
|
import { getGetCurrentSessionQueryKey } from "../../../shared/api/endpoints/identity/identity";
|
|
import type { Session } from "../../../shared/api/schemas";
|
|
import { CandidateNotificationsPage, EmployerNotificationsPage } from "./notifications-pages";
|
|
|
|
function render(scenario: "candidate" | "employer", element: React.ReactElement): string {
|
|
const queryClient = new QueryClient();
|
|
const session: Session = {
|
|
account: {
|
|
id: "11111111-1111-4111-8111-111111111111",
|
|
email: "person@example.test",
|
|
email_verified: true,
|
|
scenario,
|
|
onboarding_step: "completed",
|
|
created_at: "2026-10-07T12:00:00Z",
|
|
},
|
|
csrf_token: "A".repeat(43),
|
|
};
|
|
queryClient.setQueryData(getGetCurrentSessionQueryKey(), session);
|
|
return renderToString(
|
|
<QueryClientProvider client={queryClient}>
|
|
<MemoryRouter>{element}</MemoryRouter>
|
|
</QueryClientProvider>,
|
|
);
|
|
}
|
|
|
|
describe("notification pages", () => {
|
|
it("name the cabinet and carry the single h1", () => {
|
|
const candidate = render("candidate", <CandidateNotificationsPage />);
|
|
expect(candidate).toContain("Кабинет кандидата");
|
|
expect(candidate.match(/<h1/g)).toHaveLength(1);
|
|
const employer = render("employer", <EmployerNotificationsPage />);
|
|
expect(employer).toContain("Кабинет работодателя");
|
|
expect(employer.match(/<h1/g)).toHaveLength(1);
|
|
});
|
|
|
|
it("refuse the other cabinet's account instead of loading its inbox", () => {
|
|
expect(render("employer", <CandidateNotificationsPage />)).toContain("кабинету другого типа");
|
|
expect(render("candidate", <EmployerNotificationsPage />)).toContain("кабинета работодателя");
|
|
});
|
|
});
|