ce76046a29
- consolidate API ownership and remove dead vendor code - add Stripe billing, learning paths, and public CV hardening - add migration, recovery, security, audit, and browser gates
36 lines
1.7 KiB
TypeScript
36 lines
1.7 KiB
TypeScript
import React from "react";
|
|
import "@testing-library/jest-dom";
|
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
import { MemoryRouter } from "react-router-dom";
|
|
|
|
import OnboardingChecklist from "./components/OnboardingChecklist";
|
|
import { I18nProvider } from "./i18n/I18nProvider";
|
|
import { api } from "./api";
|
|
|
|
jest.mock("./api", () => ({
|
|
api: { get: jest.fn(), interceptors: { request: { use: jest.fn() }, response: { use: jest.fn() } } },
|
|
}));
|
|
|
|
const mockedApi = api as jest.Mocked<typeof api>;
|
|
|
|
function renderChecklist() {
|
|
return render(<MemoryRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}><I18nProvider><OnboardingChecklist hasJobs={false} /></I18nProvider></MemoryRouter>);
|
|
}
|
|
|
|
test("uses structured career data and connected inbox status for onboarding progress", async () => {
|
|
mockedApi.get.mockImplementation((url: string) => {
|
|
if (url === "/auth/me") return Promise.resolve({ data: { firstName: "Ada" } } as any);
|
|
if (url === "/career/profile") return Promise.resolve({ data: { cvText: "", profile: { jobs: [{ title: "Engineer" }] } } } as any);
|
|
return Promise.resolve({ data: { connected: url === "/gmail/status" } } as any);
|
|
});
|
|
|
|
renderChecklist();
|
|
|
|
expect(await screen.findByText("5 / 6")).toBeInTheDocument();
|
|
expect(screen.queryByRole("button", { name: "Add CV" })).not.toBeInTheDocument();
|
|
expect(screen.queryByRole("button", { name: "Open profile" })).not.toBeInTheDocument();
|
|
expect(screen.queryByRole("button", { name: "Connect email" })).not.toBeInTheDocument();
|
|
expect(screen.getByRole("button", { name: "Add job" })).toBeInTheDocument();
|
|
await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith("/career/profile"));
|
|
});
|