refactor(profile): split account and career into dedicated components
Phase 2.2 — stop backing /profile and /career from one component behind a boolean. /career now renders a dedicated CareerProfilePage; /profile keeps ProfilePage. Each hardcodes its mode and saves only its own concern (identity vs master profile) via the partial-update endpoint. This commit is the behaviour-preserving checkpoint: the two components still share the full implementation (each carries all state, only its own JSX renders). The per-component pruning that removes the other concern's state/JSX follows in subsequent commits, verified by tsc at each step. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import { ToastProvider } from './toast';
|
||||
import { I18nProvider } from './i18n/I18nProvider';
|
||||
import ProfilePage from './views/ProfilePage';
|
||||
import CareerProfilePage from './views/CareerProfilePage';
|
||||
import { api } from './api';
|
||||
|
||||
const createObjectURLMock = jest.fn(() => 'blob:mock-pdf');
|
||||
@@ -76,16 +77,22 @@ const structuredCv = {
|
||||
],
|
||||
};
|
||||
|
||||
function renderPage(props: { careerOnly?: boolean } = {}) {
|
||||
function renderWith(Component: React.ComponentType) {
|
||||
return render(
|
||||
<ToastProvider>
|
||||
<I18nProvider>
|
||||
<ProfilePage {...props} />
|
||||
<Component />
|
||||
</I18nProvider>
|
||||
</ToastProvider>,
|
||||
);
|
||||
}
|
||||
|
||||
// /profile (account identity) — the CV-editing surface still renders here (display:none) because
|
||||
// the two components share the same underlying implementation; these tests exercise that surface.
|
||||
function renderPage() {
|
||||
return renderWith(ProfilePage);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
mockedApi.get.mockImplementation((url: string) => {
|
||||
if (url === '/auth/me') {
|
||||
@@ -282,9 +289,9 @@ test('profile page rewrite tools use selected template and saved job context', a
|
||||
});
|
||||
|
||||
test('saving the master profile (career) persists structured cv json', async () => {
|
||||
// Phase 2: the master-profile save lives on /career (careerOnly). It sends only the CV fields —
|
||||
// identity is saved separately on /profile — so the payload carries profileCvStructureJson.
|
||||
renderPage({ careerOnly: true });
|
||||
// Phase 2: the master-profile save lives on /career (CareerProfilePage). It sends only the CV
|
||||
// fields — identity is saved separately on /profile — so the payload carries profileCvStructureJson.
|
||||
renderWith(CareerProfilePage);
|
||||
|
||||
expect(await screen.findByText(/cv ready/i)).toBeInTheDocument();
|
||||
const fullNameInput = screen.getByLabelText(/full name/i);
|
||||
|
||||
Reference in New Issue
Block a user