diff --git a/server/src/module/ats/__tests__/ats.service.test.ts b/server/src/module/ats/__tests__/ats.service.test.ts index 5e9148aee..1dc24c963 100644 --- a/server/src/module/ats/__tests__/ats.service.test.ts +++ b/server/src/module/ats/__tests__/ats.service.test.ts @@ -106,11 +106,12 @@ function mockCacheMiss() { function mockValidPdf(text = VALID_RESUME_TEXT) { vi.mocked(PDFParse).mockImplementation( - () => - ({ + function () { + return { getText: vi.fn().mockResolvedValue({ text }), destroy: vi.fn().mockResolvedValue(undefined), - }) as any, + } as any; + } ); } @@ -183,11 +184,12 @@ describe("AtsService", () => { mockUserOwnsResume(); mockCacheMiss(); vi.mocked(PDFParse).mockImplementation( - () => - ({ + function () { + return { getText: vi.fn().mockResolvedValue({ text: "too short" }), destroy: vi.fn().mockResolvedValue(undefined), - }) as any, + } as any; + } ); await expect( @@ -466,11 +468,12 @@ describe("AtsService", () => { it("throws when PDF text extraction yields insufficient content", async () => { mockUserOwnsResume(); vi.mocked(PDFParse).mockImplementation( - () => - ({ + function () { + return { getText: vi.fn().mockResolvedValue({ text: "tiny" }), destroy: vi.fn().mockResolvedValue(undefined), - }) as any, + } as any; + } ); await expect( diff --git a/server/src/module/student/student.service.ts b/server/src/module/student/student.service.ts index 9d2a3140b..2c794ea3f 100644 --- a/server/src/module/student/student.service.ts +++ b/server/src/module/student/student.service.ts @@ -383,6 +383,9 @@ Rules: if (!application) throw new Error("Application not found"); if (application.studentId !== studentId) throw new Error("Not authorized"); if (application.status === "WITHDRAWN") throw new Error("Already withdrawn"); + if (application.status === "HIRED" || application.status === "REJECTED") { + throw new Error("Cannot withdraw an application that is already HIRED or REJECTED"); + } return prisma.application.update({ where: { id: applicationId },