Skip to content

test(vendors,po): add co-located unit tests for VendorsService and PurchaseOrdersService - #1373

Merged
yusuftomilola merged 1 commit into
DistinctCodes:mainfrom
Gracora:feat/issue-1288-vendors-po-test-coverage
Aug 26, 2026
Merged

test(vendors,po): add co-located unit tests for VendorsService and PurchaseOrdersService#1373
yusuftomilola merged 1 commit into
DistinctCodes:mainfrom
Gracora:feat/issue-1288-vendors-po-test-coverage

Conversation

@Gracora

@Gracora Gracora commented Aug 26, 2026

Copy link
Copy Markdown

Summary

Closes #1288
Closes #1289
Closes #1290
Closes #1291

Adds co-located vendors.service.spec.ts (11 tests) and purchase-orders.service.spec.ts (22 tests) covering every public method in both services, replacing the single happy-path assertions in ibinola.spec.ts with focused, discoverable coverage.

Why

The only tests touching VendorsService and PurchaseOrdersService were two it() blocks in backend/src/ibinola.spec.ts — a file bundling unrelated modules. Coverage missed VendorsService.update(), delete() with the open-PO guard, and the full PO status state machine (submit, approve, receive, cancel). Co-locating tests with the modules they exercise follows the project convention and makes failures immediately attributable.

What was built

backend/src/vendors/vendors.service.spec.ts:

Test group What it covers
findAll Paginated results, search filter, totalPages calculation
findById Returns vendor; NotFoundException for missing id
create Creates vendor record
update Updates existing; NotFoundException for missing id
delete Deletes with no open POs; NotFoundException; BadRequestException when open POs exist; allows delete when all POs are RECEIVED

backend/src/purchase-orders/purchase-orders.service.spec.ts:

Test group What it covers
findAll Paginated results, search filter on poNumber
findById Returns PO with line items; NotFoundException
create Auto-generated poNumber; with line items; initial DRAFT status
update Updates DRAFT PO; NotFoundException; BadRequestException for non-DRAFT; replaces line items
submit Submits DRAFT; BadRequestException for non-DRAFT; NotFoundException
approve Approves SUBMITTED; records approver; BadRequestException for non-SUBMITTED
receive Receives APPROVED; BadRequestException for non-APPROVED
cancel Cancels DRAFT; cancels SUBMITTED; BadRequestException for APPROVED; BadRequestException for RECEIVED; NotFoundException

No existing files modified — only additions, so regression risk is low.

Acceptance criteria coverage

  • Both modules have real, co-located coverage beyond their single existing happy-path tests (11 + 22 = 33 new tests across two spec files)

Test plan

  • npm test in backend/ — 33/33 passing (all new tests for this feature)

Env vars / Notes

No new environment variables. Tests use lightweight Jest mocks for TypeORM repositories — no database connection required.

…rchaseOrdersService

Covers findAll with pagination/search, findById, create, update, delete
(vendor), and full PO lifecycle: create, update, submit, approve, receive,
cancel. Tests all state-transition guard paths and the open-PO guard on
vendor delete. Replaces the single misplaced assertions in ibinola.spec.ts.

Closes DistinctCodes#1288
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@Gracora is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@Gracora Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@yusuftomilola yusuftomilola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No merge conflicts with main. Good co-located unit test coverage for VendorsService and PurchaseOrdersService - approving.

@yusuftomilola
yusuftomilola merged commit 948fb7f into DistinctCodes:main Aug 26, 2026
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants