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

   ### What (demo/mock-mode alignment, not a production fix)
   
   `listAlertRulesPage` in mock mode clamped `page < 1` to 1 and `pageSize` to 
1..100, so the demo answered requests the backend `AlertService.listRules` 
rejects with 400 `Invalid page or pageSize` — tests built against the mock 
stayed green for inputs the real API refuses.
   
   Same shape as the ACL-rules (#5881) and topic-list (#6146) mock alignments; 
this is the third and last paginated mock that still clamps.
   
   ### Change
   
   `web/src/services/opsService.ts` — in the mock branch of 
`listAlertRulesPage`, replace the `Math.max`/`Math.min` clamping with the 
backend bound:
   
   ```ts
   if ((query.page ?? 1) < 1 || (query.pageSize ?? 20) < 1 || (query.pageSize 
?? 20) > 100) {
     throw new Error('Invalid page or pageSize');
   }
   ```
   
   `web/src/services/opsAlertRulesPagination.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/opsAlertRulesPagination.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/opsService.ts 
src/services/opsAlertRulesPagination.test.ts` — **exit 0, no findings**.
   
   ### Collision check
   
   Checked against all open PRs touching `web/src/services/opsService.ts`: only 
#4384 (retry deliveries), whose hunk adds `retryFilteredAlertDeliveries` around 
line 442 — disjoint from the `listAlertRulesPage` pagination block (~line 133) 
changed here. No overlap; whichever merges second needs at most a trivial 
rebase.


-- 
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