Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix: preserve answer edit time when recording review

Amruth Pillaifb415d825774
diff --git a/apps/web/src/features/career/workspace/shell.test.tsx b/apps/web/src/features/career/workspace/shell.test.tsx
index 358a2452b..f3c1280fe 100644
--- a/apps/web/src/features/career/workspace/shell.test.tsx
+++ b/apps/web/src/features/career/workspace/shell.test.tsx
@@ -237,7 +237,13 @@ it("requires initial workspace data before exposing edits, with recovery after a
expect(screen.queryByRole("button", { name: "Add a question from the form" })).toBeNull();
fireEvent.click(screen.getByRole("button", { name: "Try again" }));
expect(await screen.findByRole("textbox", { name: "Why this role?" })).toHaveValue("Current answer");
- expect(screen.getByText("1 of 4", { exact: true })).toBeTruthy();
+ expect(screen.getByText("0 of 3", { exact: true })).toBeTruthy();
+ expect(
+ screen.queryByRole("checkbox", { name: "Review the selected resume and cover letter in their editors." }),
+ ).toBeNull();
+ expect(
+ screen.getByRole("checkbox", { name: "Check every claim, date and result against your experience." }),
+ ).not.toBeChecked();
expect(api.save).not.toHaveBeenCalled();
});
diff --git a/packages/api/src/features/applications/service.ts b/packages/api/src/features/applications/service.ts
index d93ba3f8c..319572a61 100644
--- a/packages/api/src/features/applications/service.ts
+++ b/packages/api/src/features/applications/service.ts
@@ -263,7 +263,11 @@ export async function recordSentResume(row: ApplicationRow, client: DbOrTx): Pro
await client
.insert(schema.careerWorkspace)
.values({ applicationId: row.id, userId: row.userId, data })
- .onConflictDoUpdate({ target: schema.careerWorkspace.applicationId, set: { data, updatedAt: new Date() } });
+ // Recording review metadata must not make unchanged answers look edited after submission.
+ .onConflictDoUpdate({
+ target: schema.careerWorkspace.applicationId,
+ set: { data, updatedAt: sql`${schema.careerWorkspace.updatedAt}` },
+ });
}
if (row.resumeId && !row.sentResumeVersionId) {
diff --git a/packages/api/src/features/career/service.integration.test.ts b/packages/api/src/features/career/service.integration.test.ts
index f931d6524..c8dee5583 100644
--- a/packages/api/src/features/career/service.integration.test.ts
+++ b/packages/api/src/features/career/service.integration.test.ts
@@ -2109,9 +2109,24 @@ describe.skipIf(!databaseUrl)("career knowledge, context and data lifecycle", ()
});
it("keeps legacy capture of unchanged pre-submission answers immutable", async () => {
+ await getDb()
+ .update(tables.application)
+ .set({ sentResumeVersionId: null })
+ .where(eq(tables.application.id, "alice-app"));
const answers = [{ id: "why", question: "Why this role?", answer: "Original answer", factIds: [] }];
await service.saveWorkspace("alice", "alice-app", { answers }, { answers: [] });
- await applications.update({ userId: "alice", id: "alice-app", status: "applied" });
+ const [before] = await getDb()
+ .select()
+ .from(tables.careerWorkspace)
+ .where(eq(tables.careerWorkspace.applicationId, "alice-app"));
+ if (!before) throw new Error("Missing saved answers.");
+ vi.useFakeTimers({ toFake: ["Date"] });
+ try {
+ vi.setSystemTime(new Date(before.updatedAt.getTime() + 1000));
+ await applications.update({ userId: "alice", id: "alice-app", status: "applied" });
+ } finally {
+ vi.useRealTimers();
+ }
await service.snapshotAnswers("alice", "alice-app");
await service.saveWorkspace(
"alice",
diff --git a/tests/e2e/specs/application-submission.spec.ts b/tests/e2e/specs/application-submission.spec.ts
index 17ef85ac8..e67801d17 100644
--- a/tests/e2e/specs/application-submission.spec.ts
+++ b/tests/e2e/specs/application-submission.spec.ts
@@ -106,6 +106,7 @@ for (const entry of ["detail", "workspace", "api"] as const) {
const receipt = await stored.json();
expect(receipt.checklist).toEqual(checklist);
expect(receipt.submissionReview).toEqual({ at: expect.any(String), checklist, documents: false, answers: true });
+ if (entry === "api") await expect(await page.request.post(`${workspaceUrl}/answers`)).toBeOK();
expect(
(await page.request.patch(workspaceUrl, { data: { checklist: [2], expected: { checklist } } })).status(),
).toBe(409);