Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
fix(resume): download attached resume files under their original upload name
Khuram Niaz1091f2bfd980
diff --git a/__tests__/DownloadFileButton.spec.tsx b/__tests__/DownloadFileButton.spec.tsxnew file mode 100644index 0000000..37543e5--- /dev/null+++ b/__tests__/DownloadFileButton.spec.tsx@@ -0,0 +1,57 @@+import { render, screen, fireEvent, waitFor } from "@testing-library/react";+import { DownloadFileButton } from "@/components/profile/DownloadFileButton";++const RESTORED_PATH =+ "data/files/resumes/00000000-0000-4000-8000-000000000000-Sample Resume_2026-01-01T00-00-00.pdf";++describe("DownloadFileButton", () => {+ let downloads: string[];++ beforeEach(() => {+ downloads = [];+ global.fetch = vi.fn().mockResolvedValue({+ ok: true,+ blob: () => Promise.resolve(new Blob(["pdf"])),+ }) as unknown as typeof fetch;+ window.URL.createObjectURL = vi.fn(() => "blob:mock");+ window.URL.revokeObjectURL = vi.fn();+ vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(+ function (this: HTMLAnchorElement) {+ downloads.push(this.download);+ },+ );+ });++ afterEach(() => {+ vi.restoreAllMocks();+ });++ it("saves under the original upload name, not the stored path", async () => {+ render(+ DownloadFileButton(+ "resume-1",+ RESTORED_PATH,+ "Sample",+ "Sample Resume.pdf",+ ),+ );+ fireEvent.click(screen.getByRole("button"));++ await waitFor(() =>+ expect(downloads).toEqual(["Sample Resume.pdf"]),+ );+ expect(global.fetch).toHaveBeenCalledWith(+ "/api/profile/resume?resumeId=resume-1",+ expect.anything(),+ );+ });++ it("falls back to the path basename when fileName is empty", async () => {+ render(DownloadFileButton("resume-1", RESTORED_PATH, "Sample", ""));+ fireEvent.click(screen.getByRole("button"));++ await waitFor(() =>+ expect(downloads).toEqual([RESTORED_PATH.split("/").pop()]),+ );+ });+});diff --git a/src/components/profile/DownloadFileButton.tsx b/src/components/profile/DownloadFileButton.tsxindex 9a2f728..fc63a0c 100644--- a/src/components/profile/DownloadFileButton.tsx+++ b/src/components/profile/DownloadFileButton.tsx@@ -22,7 +22,8 @@ export function DownloadFileButton(const url = window.URL.createObjectURL(blob);const link = document.createElement("a");link.href = url;- link.download = filePath.split("/").pop(); // Get the file name+ // Stored basename carries a timestamp and, after a restore, a file id+ link.download = fileName || filePath.split("/").pop();link.target = "_blank";link.click();window.URL.revokeObjectURL(url); // Clean up