Skip to content

added feature and tests for uploading and downloading cv#268

Open
joos-too wants to merge 6 commits intomainfrom
21-add-printdownload-cv-button
Open

added feature and tests for uploading and downloading cv#268
joos-too wants to merge 6 commits intomainfrom
21-add-printdownload-cv-button

Conversation

@joos-too
Copy link
Copy Markdown
Collaborator

@joos-too joos-too commented Feb 26, 2026

PR will be reviewed once all boxes are checked (check boxes if they do not apply to this pr)

  • Did you fulfill the user story and its acceptance criteria?
  • Did you write all code and comments in english?
  • Did you update the major/minor/patch version in the package.json?
  • Did you review the merge request yourself in GitHub (& IDE)?

@joos-too joos-too linked an issue Feb 26, 2026 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 26, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 94.8% 4273 / 4507
🔵 Statements 94.8% 4273 / 4507
🔵 Functions 86.29% 170 / 197
🔵 Branches 87.78% 654 / 745
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/components/navbar.tsx 95.71% 83.92% 100% 95.71% 72-80, 114-115
src/components/portfolioEditor/cv-upload-control.tsx 100% 81.81% 100% 100%
src/components/portfolioEditor/file-dropzone.tsx 74.71% 33.33% 28.57% 74.71% 36-39, 42-45, 48-54, 57-58, 61-65, 75
src/components/portfolioEditor/import-export-controls.tsx 97.32% 96.15% 90% 97.32% 110-114
src/components/portfolioEditor/index.tsx 99.19% 90.9% 85.71% 99.19% 180, 214
src/lib/portfolio-export.ts 99.46% 98.57% 80% 99.46% 176
src/lib/portfolio.ts 88.11% 68% 83.33% 88.11% 15-16, 24, 77-79, 83-85, 121-123
src/lib/use-portfolio-editor.ts 80.32% 67.54% 86.95% 80.32% 63-65, 69-70, 83-86, 91, 96-97, 146-182, 195-198, 201-206, 213-214, 236-239, 261-271, 314, 391-392, 394-395, 414-435, 456-477, 621-623
Generated in workflow #760 for commit d6c4a14 by the Vitest Coverage Report Action

@joos-too joos-too requested a review from phillipc0 February 26, 2026 13:56
Copy link
Copy Markdown
Owner

@phillipc0 phillipc0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just looked @ the code, visual inspection will follow later

Comment on lines +84 to +93
deleteFileIfExists(path.join(DATA_UPLOADS_DIR, storedFileName));
deleteFileIfExists(path.join(FRONTEND_UPLOADS_DIR, storedFileName));
};

const persistPdfFile = (storedFileName: string, fileBuffer: Buffer): void => {
ensureDirectoryExists(DATA_UPLOADS_DIR);
ensureDirectoryExists(FRONTEND_UPLOADS_DIR);

fs.writeFileSync(path.join(DATA_UPLOADS_DIR, storedFileName), fileBuffer);
fs.writeFileSync(path.join(FRONTEND_UPLOADS_DIR, storedFileName), fileBuffer);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats why i was always hesitant of implementing profile picture uploads or similar, i am pretty sure its susceptible to path traversal attacks :(

But I guess since those functions can only be reached by authenticated users, its fine if you can "hack" your own system (as long as the pw is safe), still we should see if it can be hardened (or if it even is possible to do that attack here)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, haven't thought about that. Probably you can also fake mime types so you can upload any kind of file?
I also guess its not that critical here, but you can have a look pls. :)

Comment on lines +124 to +126
if (!BASE64_PATTERN.test(body.data)) {
return "Invalid file data";
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that common practise/necessary? How is the performance of that?

navigate("/edit");
};

const handleCvDownload = () => {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not fit better into the basic info tab, than the navbar?
In my mind, the navbar is more of a navigational/settings place and the pdf is more about all of the information

Copy link
Copy Markdown
Collaborator Author

@joos-too joos-too Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also though about that, in the Navbar was currently the easiest way. I will experiment where the button could be with respect to responsiveness on mobile.

}
}

// Check optional CV document metadata
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also check if the file exists if we plan on linking to it?
Although most of the time you use the feature when setting it up from scratch so there wont be a file, so do we even want to allow to import it then?

expect(res.status).toHaveBeenCalledWith(405);
expect(res.setHeader).toHaveBeenCalledWith("Allow", ["POST"]);
expect(res.json).toHaveBeenCalledWith({ error: "Method not allowed" });
});
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test for unauthenticated/unauthorized requests?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can! I guess

@joos-too joos-too self-assigned this Feb 26, 2026
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Upload/Download CV Button

2 participants