Skip to content

Test/unit test generateinvoice file generation libinvoicets - #363

Merged
kOaDT merged 3 commits into
kOaDT:mainfrom
pedruck:test/unit-test-generateinvoice-file-generation-libinvoicets
Nov 2, 2026
Merged

kOaDT merged 3 commits into
kOaDT:mainfrom
pedruck:test/unit-test-generateinvoice-file-generation-libinvoicets

Conversation

@Mateiki

@Mateiki Mateiki commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Description

Add unit tests for generateInvoice covering invoice path generation, file writing, and invoice directory creation.

Type of change

  • Bug fix
  • New feature (e-commerce site improvement)
  • New vulnerability / flag
  • Walkthrough / writeup
  • Documentation update
  • Other: Unit test coverage

Testing done

  • npx jest --runInBand tests/unit/invoice.test.ts — passed (2 tests)
  • npm run lint — passed with existing warnings
  • npm run format:check — passed
  • npm run test:unit — one unrelated pre-existing failure in create-oss-store-node-guard.test.ts

Checklist

  • Documentation updated (if applicable)

If adding a new challenge

Not applicable.

  • Flag added in prisma/flags.ts with format OSS{...}
  • Three progressive hints added in flagHints (vague → near-solution)
  • Vulnerable code path is exploitable and reachable from the UI
  • Reference doc added under content/vulnerabilities/ (concept + fix only — no exploit steps, payloads, or flag value)
  • Flag value mirrored in tests/helpers/flags.ts
  • Regression tests added (unit, API, and/or E2E), asserting the vulnerable behaviour
  • Walkthrough added under docs/src/data/blog/, with a matching walkthroughSlug
  • Challenge added to docs/src/data/roadmap.ts (slug, difficulty, category and walkthrough matching the flag)
  • Counts and catalog updated in README.md and EDUCATORS.md (including the OWASP grid and syllabus plans)
  • No real-world secrets introduced

@github-actions github-actions Bot added the size/M PR size: M label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Welcome @Mateiki, and thanks for your first PR here!

Code Quality and the exploitation suite are running now. You can follow them in the Checks tab. If one goes red and the message isn't obvious, ask in this thread rather than force-pushing blind.

Contributing guide · Code of conduct. A maintainer will pick this up shortly.

@kOaDT
kOaDT force-pushed the test/unit-test-generateinvoice-file-generation-libinvoicets branch from 4f85912 to d46a687 Compare November 2, 2026 23:21

@kOaDT kOaDT left a comment

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.

Thanks for the PR, and welcome! I pushed a commit on top of yours before merging:

  • The tests now write a real PDF into a temporary directory instead of mocking fs and pdf-lib. The old second test checked that mkdir wasn't called, which pins the implementation rather than the behaviour (mkdir with recursive: true is a no-op on an existing folder).
  • Added cases for item-name truncation at 40 chars, Date/string createdAt, two-decimal amounts, and a failing write.

About the create-oss-store-node-guard.test.ts failure you mentioned: it passes on main in CI and locally on Node 24. Could you share the failure output, your node --version and your OS? It may be an environment issue worth fixing separately.

@kOaDT
kOaDT merged commit 1b1425e into kOaDT:main Nov 2, 2026
6 checks passed
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Merged — and it's your first one here, @Mateiki. Thank you!

If the project was useful to you, a star helps other people find it!

@Mateiki

Mateiki commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Node version: 26.10.13
NPM version: 11.20.0
OS: Windows 10

It was really a environment issue!
image

Test create-oss-store-node-guard.test.ts passed after some environment fix

It was something related to some path configuration of npm dependence (the resources that npm accesses via paths). I can't tell exactly which one it was because i just re-instaled all node and npm from zero, and in the setup part i configured all paths again.

Good all working normally, thx for the feedback

@kOaDT

kOaDT commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thanks for checking, glad it's sorted! The PR is merged and your commits are on main. Welcome as a contributor 🙌

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

Labels

size/M PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants