zjncs opened a new pull request, #5881:
URL: https://github.com/apache/rocketmq-dashboard/pull/5881
### What (demo/mock-mode alignment, not a production fix)
`listAclRules` in mock mode clamped `page < 1` and any `pageSize` with
`Math.max`, so the demo answered requests the backend
`AclService.requireValidPage`/`requireValidPageSize` rejects with 400 — tests
built against the mock stayed green for inputs the real API refuses. The
sibling mock `pageAclUsers` already enforces the bound; this aligns
`listAclRules` with it.
Resubmission of #5498 with the review feedback applied: the unused
`aclRules` import and the no-op `beforeEach(vi.restoreAllMocks)` are dropped,
and real `tsc -b` / `eslint` output is included below.
### Change
`web/src/services/aclService.ts` — in the mock branch of `listAclRules`,
replace the `Math.max` 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 >= 1 and pageSize must be between 1 and
100');
}
```
`web/src/services/aclServicePagination.test.ts` — 4 tests pinning the
contract (2 discriminating + 2 controls).
### Verification
- New tests with the fix: **4/4 passed** (`vitest run
src/services/aclServicePagination.test.ts`).
- Mutation (fix reverted, tests kept): **2 failed / 2 passed** — exactly the
two discriminating tests redden; the controls stay green.
- Fix restored + regression: `vitest run src/services/` — **13 files / 111
tests passed**.
- `npx tsc -b` — **exit 0, no diagnostics** (this was the blocking issue on
#5498: the unused `aclRules` import made the build red under `noUnusedLocals`).
- `npx eslint src/services/aclService.ts
src/services/aclServicePagination.test.ts` — **exit 0, no findings**.
### Collision check
Checked against all open PRs on `apache/rocketmq-dashboard` — no other PR
touches `web/src/services/aclService.ts` or adds `aclServicePagination.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]