zjncs opened a new pull request, #6146:
URL: https://github.com/apache/rocketmq-dashboard/pull/6146

   ### What (demo/mock-mode alignment, not a production fix)
   
   `listTopicsPage` in mock mode clamped `page < 1` to 1 and `pageSize` to 
1..100, so the demo answered requests the backend 
`MetadataService.listTopicsPage` rejects with 400 — tests built against the 
mock stayed green for inputs the real API refuses:
   
   | Input | Backend (`MetadataService.listTopicsPage`) | Old mock |
   | --- | --- | --- |
   | `page < 1` | 400 `page must be greater than zero` | clamped to page 1, 
quietly answered |
   | `pageSize < 1` or `> 100` | 400 `pageSize must be between 1 and 100` | 
clamped to 1..100, quietly answered |
   
   Same shape as the ACL-rules mock alignment (#5881); the sibling mocks that 
already enforce the bound were the reference.
   
   ### Change
   
   `web/src/services/topicService.ts` — in the mock branch of `listTopicsPage`, 
replace the `Math.max`/`Math.min` clamping with the backend bound:
   
   ```ts
   if ((params?.page ?? 1) < 1 || (params?.pageSize ?? 20) < 1 || 
(params?.pageSize ?? 20) > 100) {
     throw new Error('page must be greater than zero and pageSize must be 
between 1 and 100');
   }
   ```
   
   `web/src/services/topicServicePagination.test.ts` — 5 tests (3 
discriminating + 2 controls), stated as demo/mock-mode alignment in the file 
header.
   
   ### Verification
   
   - New tests with the fix: **5/5 passed** (`vitest run 
src/services/topicServicePagination.test.ts`).
   - Fail-before (clamping restored, tests kept): **3 failed / 2 passed** — 
exactly the three discriminating tests redden; the controls stay green.
   - Regression: `vitest run src/services/` — **14 files / 116 tests passed**.
   - `npx tsc -b` — **exit 0, no diagnostics**.
   - `npx eslint src/services/topicService.ts 
src/services/topicServicePagination.test.ts` — **exit 0, no findings**.
   
   ### Collision check
   
   Checked against all open PRs on `apache/rocketmq-dashboard` — no other PR 
touches `web/src/services/topicService.ts` or adds 
`topicServicePagination.test.ts`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to