API Pagination Repair: From 4/7 to 7/7 Tests by Shivansh JainAPI Pagination Repair: From 4/7 to 7/7 Tests by Shivansh Jain

API Pagination Repair: From 4/7 to 7/7 Tests

Shivansh Jain

Shivansh Jain

The first page looked correct. Following Next skipped eight products.
This is a deliberately constructed Node HTTP API demonstration with synthetic data, not a client incident or a production application.
Reproduce the failure The API serves 12 products in groups of four. Its page query parameter arrives as a string. Subtraction and multiplication silently coerce that value when calculating slice bounds, so page 1 appears to work. But adding 1 concatenates the string: "1" + 1 becomes "11". Following nextPage then returns an empty list.
Make one bounded change Keep the existing positive-safe-integer validation, then convert the validated rawPage using Number(rawPage) before arithmetic. The before and after snapshots differ at that assignment.
Run the same acceptance tests On Node v24.22.1, the identical seven HTTP integration checks produced: • Before: 4 passed, 3 failed; process exit 1. • After: 7 passed, 0 failed; process exit 0.
The checks cover numeric Next links; all 12 unique products in order; a default page; last-page termination; out-of-range pages; invalid page inputs; and unknown routes. They use actual loopback HTTP requests, not mocked request objects.
What this demonstrates A successful first response is not enough. Testing the full traversal catches a defect that a single-page spot check misses. The repository includes the failing and repaired code, unchanged tests, response evidence and a small diff.
Limits This is an API example, not a React UI, client case study, security audit, database test or deployment guarantee. No business outcome or universal repair success is claimed.
For a real app, I first agree one reproducible failure, expected behavior and safe test access. My bounded app-repair and monthly regression-QA services are listed on this profile.
Like this project

Posted Nov 5, 2026

Self-built Node HTTP API demo: one string-to-number fix, identical regression tests and reproducible evidence. Not client work.