Commit graph

3 commits

Author SHA1 Message Date
19029a5a77 chore: restructure repo — flatten App/pelagia-portal to App, rename Prototype→Wireframe and Spec→Design
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 23:18:58 +05:30
48e1f19e58 test: add comprehensive tests for all new features + test plan
Parser extraction:
- Move parseSheet/parseWorkbook/cellStr/cellNum to lib/po-import-parser.ts
  so they can be unit-tested without HTTP overhead
- Route now re-exports types and delegates to the lib

Unit tests (165 total, all passing):
- permissions.test.ts: +15 cases covering MANAGER create_po/submit_po/
  manage_vendors, ACCOUNTS manage_vendors, AUDITOR all-denied, ADMIN
  operational denial, SUPERUSER no manage_vendors
- po-state-machine.test.ts: +12 cases covering MANAGER submit from DRAFT
  and EDITS_REQUESTED, ACCOUNTS provide_vendor_id, AUDITOR/ADMIN denied
  on all transitions
- po-import-parser.test.ts (new, 32 cases): cellStr/cellNum edge cases;
  parseSheet against real Sample_PO.xlsx (1 line item, correct values,
  T&C not included, vendor/quotation/T&C extraction); synthetic sheet
  edge cases (GST normalisation, INSTRUCTIONS stop, zero-price skip,
  empty rows); parseWorkbook happy path and empty-workbook

Integration tests (new files):
- discard-po.test.ts: owner/MANAGER/SUPERUSER can discard; ACCOUNTS and
  non-owners denied; status guard blocks non-DRAFT; cascade cleanup of
  POActions and POLineItems verified in DB
- vendor-approval.test.ts: approval blocked without vendor; approval
  succeeds with vendor; ACCOUNTS can provideVendorId; unverified vendor
  rejected; AUDITOR denied; wrong-status denied
- manager-po-creation.test.ts: MANAGER creates DRAFT and submits; stores
  correct submitterId; can discard own draft; ACCOUNTS denied; unauth
  returns Unauthorized
- products-search.test.ts: 401 unauth; min-length validation; search by
  name/code/description; case-insensitive; max 10 results; lastPrice as
  number; inactive products excluded
- import-api.test.ts: 401 unauth; 403 for TECHNICAL and ACCOUNTS; 400
  no file; 400 invalid binary; 200 for MANAGER with Sample_PO.xlsx;
  correct line item values; T&C absent from results; vendor/PI extracted

Spec/TEST_PLAN.md (new):
- Testing strategy, stack, and environment setup
- Coverage matrix across unit/integration/E2E layers
- Permission test matrix for all 7 roles × 15 operations
- Feature-level scenario index (F-01 through F-06) with IDs mapping to test files
- Known gaps and out-of-scope items
- Authoring conventions (PREFIX isolation, negative-first, no any)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 19:15:58 +05:30
e07ce9bd02 test: unit, integration and E2E test suite (110 unit tests passing)
Unit (Vitest + jsdom):
  po-state-machine.test.ts   21 tests — all transitions and helpers
  permissions.test.ts        11 tests — all 7 roles
  utils.test.ts              17 tests — formatCurrency INR, formatDate, status labels
  validations.test.ts        24 tests — createPoSchema, lineItemSchema, TC defaults
  po-status-badge.test.tsx   17 tests — all 10 statuses
  po-line-items-editor.test.tsx 20 tests — add/remove, GST calc, read-only, diff mode

Integration (Vitest + real DB, mocked auth/notifier):
  create-po.test.ts          — S-01 create, S-02 draft, S-03 submit
  approval-actions.test.ts   — M-02 approve, M-03 reject, M-04 edits/vendor-id, S-06/S-07
  payment-actions.test.ts    — A-01 queue, A-02 mark paid with reference

E2E (Playwright):
  auth.spec.ts               — login, role nav, sign out
  submitter-journey.spec.ts  — S-01 to S-08
  manager-approvals.spec.ts  — M-01 to M-04
  accounts-payment.spec.ts   — A-01, A-02
  po-export.spec.ts          — export buttons, endpoint responses, PDF content
2026-05-06 00:16:10 +05:30