yyqdbngt opened a new pull request, #4678:
URL: https://github.com/apache/rocketmq-dashboard/pull/4678
<!-- Base branch: `rocketmq-studio`, the RocketMQ Studio trunk. -->
### Which Issue(s) This PR Fixes
- No open issue tracks this defect. #3556 and #4641 describe the related but
different
alerts-page counter scope; the ACL subtitle is a separate claim about the
two ACL inventories.
### Brief Description
`web/src/pages/instance/acl.tsx:1075` renders the page subtitle from the
rows of the currently
loaded server page:
```tsx
subtitle={t('acl.subtitle', { rules: rules.length, users: users.length })}
```
but the wording of `acl.subtitle` is a statement about the inventories - `共
{rules} 条规则、{users}
个用户` / `{rules} rules, {users} users` - and the ACL rule and user tables are
paginated
server-side (`ruleTotal` from `listAclRules`, `userTotal` from
`pageAclUsers`, both already loaded
for the pagination footers at lines 1198 and 1256). With the default page
size of 20, an installation
holding 45 rules and 37 users describes itself as `共 20 条规则、20 个用户`.
The subtitle now uses the backend totals, so the header describes the same
result set as the
pagination footer right below it.
### How Did You Test This Change?
New case in `web/src/pages/instance/__tests__/AclPage.test.tsx`:
`listAclRules` reports 20 rules of
45 and `pageAclUsers` reports 20 users of 37, and the subtitle must read the
totals while the table
still shows only the loaded page.
Red - on the unmodified base (new test copied in, `acl.tsx` untouched):
```
$ cd web && npx vitest run src/pages/instance/__tests__/AclPage.test.tsx
❯ src/pages/instance/__tests__/AclPage.test.tsx (24 tests | 1 failed)
32999ms
× reports the whole result set in the header subtitle instead of the
loaded page 646ms
FAIL src/pages/instance/__tests__/AclPage.test.tsx > ACL page > reports
the whole result set in the header subtitle instead of the loaded page
AssertionError: expected '访问控制规则与用户权限管理,共 20 条规则、20 个用户' to be
'访问控制规则与用户权限管理,共 45 条规则、37 个用户' // Object.is equality
Expected: "访问控制规则与用户权限管理,共 45 条规则、37 个用户"
Received: "访问控制规则与用户权限管理,共 20 条规则、20 个用户"
Test Files 1 failed (1)
Tests 1 failed | 23 passed (24)
```
The failure also pins that the assertion is not tautological: the pagination
footer in the same
render already prints `共 45 条规则` from the backend total, so only the header
disagreed.
Green - with the fix:
```
$ cd web && npx vitest run src/pages/instance/__tests__/AclPage.test.tsx
Test Files 1 passed (1)
Tests 24 passed (24)
Duration 51.65s
```
```
$ cd web && npx tsc -b # exit 0, no output
$ cd web && npx eslint src/pages/instance/acl.tsx
src/pages/instance/__tests__/AclPage.test.tsx
# exit 0, no output
```
The other 23 cases of the file (including the out-of-range page clamp and
the two partial-failure
cases) are unchanged and still pass.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
(no UI text is added; the existing `acl.subtitle` key is reused with its
declared placeholders)
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks); no server file is touched, so the Java suite is not affected
- [x] New source files carry the ASF license header (no new source file)
- [x] Documentation touched where behaviour changed (no README / `docs/`
page documents this subtitle)
--
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]