yyqdbngt opened a new pull request, #5348:
URL: https://github.com/apache/rocketmq-dashboard/pull/5348
### Which Issue(s) This PR Fixes
- Fixes #5280
### Brief Description
`web/src/mock/audit.ts` pinned operations and resource types the backend
never records, and
`web/src/api/clusterContract.test.ts` pinned a status value the cluster API
never serializes.
Verified against the backend sources on `rocketmq-studio`:
- `RESTART_BROKER` has no producer at all — `grep -rn RESTART_BROKER
server/src` is empty, and
`ClusterService.restartBroker` throws `unsupportedOperation` without
calling the audit service.
- ACL changes are recorded as `CREATE_ACL_RULE` / `UPDATE_ACL_RULE` /
`DELETE_ACL_RULE` against
resource type `ACL_RULE`, with `String.valueOf(rule.getId())` as the
resource name
(`AclService.java:117,158,172`, `AclService.java:562`), not `UPDATE_ACL`
against `TOPIC`.
- `UPDATE_BROKER_CONFIG` is recorded against resource type `BROKER`
(`RocketMQBrokerConfigService.java:94`).
- `ClusterVO.status`, `ProxyVO.status` and `NameServerVO.status` serialize as
`ClusterStatus` = `healthy|warning|error|offline` and `BrokerVO.status` as
`BrokerStatus` =
`running|readonly|maintenance`, so the old `status: 'RUNNING'` fixture
could never have been
produced by the API.
The mock rows are fixed to the vocabulary that the producers actually emit
(`RESEND_DLQ`/`DLQ`,
`ADD_PROXY_ADDRESS`/`PROXY`, `REMOVE_PROXY_ADDRESS`/`PROXY`,
`CREATE_ACL_RULE`/`ACL_RULE`,
`UPDATE_ACL_RULE`/`ACL_RULE`, `UPDATE_BROKER_CONFIG`/`BROKER`), and the
cluster contract fixture
uses `healthy` / `running`. Mock mode derives the audit page filter options
from these rows, so it
no longer offers filters for operations nothing can produce.
`web/src/mock/audit.test.ts` pins both properties, and the contract test
pins the status
vocabulary, so a future fixture edit that drifts from the backend turns the
suite red.
### How Did You Test This Change?
```sh
$ cd web && npx vitest run src/mock/audit.test.ts
src/api/clusterContract.test.ts # before the fix
❯ src/mock/audit.test.ts (3 tests | 3 failed) 32ms
× records only operations the backend can produce 21ms
× pairs every operation with the resource type the backend uses 3ms
× names ACL rule rows by the rule id the backend records 1ms
❯ src/api/clusterContract.test.ts (2 tests | 1 failed) 45ms
✓ unwraps the backend ClusterVO shape for list and detail endpoints 22ms
× pins the status vocabulary the backend serializes 16ms
FAIL src/api/clusterContract.test.ts > cluster API contract > pins the
status vocabulary the backend serializes
AssertionError: expected [ 'healthy', 'warning', 'error', …(1) ] to include
'RUNNING'
FAIL src/mock/audit.test.ts > audit mock contract > records only
operations the backend can produce
AssertionError: expected [ 'UPDATE_ACL', 'RESTART_BROKER' ] to deeply equal
[]
FAIL src/mock/audit.test.ts > audit mock contract > pairs every operation
with the resource type the backend uses
AssertionError: expected [ 'UPDATE_ACL/TOPIC', …(6) ] to deeply equal []
FAIL src/mock/audit.test.ts > audit mock contract > names ACL rule rows by
the rule id the backend records
AssertionError: expected 0 to be greater than 0
Test Files 2 failed (2)
Tests 4 failed | 1 passed (5)
```
```sh
$ cd web && npx vitest run src/mock/audit.test.ts
src/api/clusterContract.test.ts # after the fix
✓ src/mock/audit.test.ts (3 tests) 12ms
✓ src/api/clusterContract.test.ts (2 tests) 26ms
Test Files 2 passed (2)
Tests 5 passed (5)
```
`npx tsc -b` and `npx eslint src/mock/audit.test.ts src/mock/audit.ts
src/api/clusterContract.test.ts`
both exit 0.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits
- [x] Tests added or updated for non-trivial changes
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
— not applicable, no
UI string is added or changed; only fixture values are aligned with the
values the backend
serializes
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks) — not applicable,
no Java source is touched
- [x] New source files carry the ASF license header
- [x] Documentation touched where behaviour changed (README / `docs/` /
in-app help) — not
applicable, no API or user-visible contract changes; the mock data now
matches the backend
--
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]