feat(applications): preserve submitted packages

This commit is contained in:
cesnimda
2026-08-31 16:54:41 +02:00
parent 47e8e3e50e
commit 5337ba3a5e
22 changed files with 903 additions and 11 deletions
@@ -62,6 +62,7 @@ function routeGet(overrides: Record<string, any> = {}) {
mockedApi.get.mockImplementation((url: string) => {
if (url.endsWith("/tailoring")) return Promise.resolve({ data: overrides.tailoring ?? tailoring } as any);
if (url.endsWith("/cover-letter")) return Promise.resolve({ data: overrides.coverLetter ?? coverLetter } as any);
if (url.endsWith("/submitted-packages")) return Promise.resolve({ data: overrides.submittedPackages ?? [] } as any);
return Promise.resolve({ data: overrides.cv ?? cv } as any);
});
}
@@ -126,6 +127,21 @@ test("tailoring asks for a career profile when there is none", async () => {
expect(await screen.findByText(/Build your career profile/i)).toBeInTheDocument();
});
test("submitted package capture appends an immutable history entry", async () => {
routeGet();
mockedApi.post.mockResolvedValue({ data: {
id: 12, version: 1, cvVariantId: 3, cvVariantName: "Backend CV", cvVariantVersion: 4,
cvThemeId: "nordic", hasCv: true, hasCoverLetter: true, createdAtUtc: "2026-08-31T12:00:00Z", attachments: [],
} } as any);
render(<ApplicationCvSection jobId={7} />);
fireEvent.click(await screen.findByRole("button", { name: /Freeze current package/i }));
await waitFor(() => expect(mockedApi.post).toHaveBeenCalledWith("/jobapplications/7/submitted-packages"));
expect(await screen.findByText("Submission package v1")).toBeInTheDocument();
expect(screen.getByText(/Backend CV · v4/)).toBeInTheDocument();
});
// ---------- Cover letter ----------
test("cover letter loads the current text and its history", async () => {