pelagia-portal/App/tests/unit
Hardik 7d4ad6a9b8
All checks were successful
PR checks / checks (pull_request) Successful in 44s
PR checks / integration (pull_request) Successful in 32s
feat(po): prompt to save as draft when leaving with unsaved changes
Closes #18. Navigating away from a PO create/edit screen with unsaved
changes could silently lose in-progress work. The forms now track a dirty
flag and guard both navigation paths:

- Hard navigations (refresh / tab close / external link) → the browser's
  native "Leave site?" prompt via beforeunload.
- In-app navigations (sidebar / header / any internal link) → a capture-phase
  click interceptor opens a modal offering Save as draft / Discard changes /
  Stay on page. Save as draft runs the form's existing draft save (which
  redirects to the PO); Discard continues to the intended destination.

The guard (components/po/unsaved-changes-guard.tsx) is reusable and wired into
both new-po-form and edit-po-form. dirty is cleared before a successful submit
so saving never trips the prompt. SPA back-button (popstate) is left to
beforeunload only; the manager inline-edit panel is out of scope (saves in
place, no draft concept).

Tests: 7 new unit cases for the guard (intercept-when-dirty, no-op-when-clean,
external links pass through, Stay/Discard/Save actions, beforeunload arming).
Unit suite 296 green; tsc clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 06:37:33 +05:30
..
application-pipeline.test.ts feat(crewing): Phase 3b — recruitment pipeline (flagged) 2026-06-22 18:49:12 +05:30
appraisal-state-machine.test.ts feat(crewing): Phase 5b — appraisal (flagged) 2026-06-22 22:09:32 +05:30
attachments.test.ts fix(po): show all attachments grouped by type on PO details 2026-06-19 04:43:44 +05:30
cancel-po-controls.test.tsx fix(po): make cancel buttons red & visible (use defined danger tokens) 2026-06-21 12:59:20 +05:30
crew-pii.test.ts fix(crewing): mask Aadhaar/PAN document numbers server-side 2026-06-22 23:29:11 +05:30
image-size.test.ts fix(po): size XLSX export images by pixels (aspect preserved) 2026-06-21 13:27:15 +05:30
pagination.test.ts feat(history): paginate PO history with items-per-page control 2026-06-24 03:26:47 +05:30
permissions-crewing.test.ts feat(crewing): admin crew management — direct placement, CRUD, strength config 2026-06-22 21:23:31 +05:30
permissions.test.ts feat(po): submitter view-all of POs + History + export (feature-flagged) 2026-06-22 04:57:11 +05:30
po-export-layout.test.ts fix(po): keep the export stamp clear of the signature (no overlap) 2026-06-21 15:35:09 +05:30
po-import-parser.test.ts test+ci: green the test baseline and make type-check + unit tests hard gates 2026-06-19 13:03:54 +05:30
po-line-items-editor.test.tsx feat(po): add week, month, year to line-item unit options 2026-06-21 00:32:39 +05:30
po-state-machine.test.ts chore: restructure repo — flatten App/pelagia-portal to App, rename Prototype→Wireframe and Spec→Design 2026-05-18 23:18:58 +05:30
po-status-badge.test.tsx chore: restructure repo — flatten App/pelagia-portal to App, rename Prototype→Wireframe and Spec→Design 2026-05-18 23:18:58 +05:30
requisition-state-machine.test.ts feat(crewing): Phase 2 — requisitions + relief requests (flagged) 2026-06-22 18:22:59 +05:30
sidebar.test.tsx test(sidebar): cover PO links moved under Purchasing + renames 2026-06-24 06:10:55 +05:30
storage-keys.test.ts feat(po): per-company logo, stamp & brand bar on exported POs 2026-06-21 01:17:23 +05:30
unsaved-changes-guard.test.tsx feat(po): prompt to save as draft when leaving with unsaved changes 2026-06-24 06:37:33 +05:30
utils.test.ts feat(dashboard): compact INR formatting for Total Approved Spend card 2026-06-21 02:02:41 +05:30
validations.test.ts feat(po): allow submitter to set an optional PO date 2026-06-16 13:06:12 +05:30
vendor-select.test.tsx feat(po): make vendor field a searchable combobox 2026-06-24 05:16:57 +05:30
vendors-table.test.tsx refactor(routes): move /inventory/{items,vendors} → /catalogue/{items,vendors} 2026-06-24 05:04:29 +05:30