Frun1na opened a new pull request, #6516:
URL: https://github.com/apache/rocketmq-dashboard/pull/6516
### Which Issue(s) This PR Fixes
- Fixes #6515
### Brief Description
The demo data source's `acknowledgeAlert` returned without a word when the
id was not in
`mockSystemAlerts` (`web/src/services/opsService.ts:408-415`), so it
reported success for an alert the
backend does not have; the endpoint answers 404 —
`AlertService.acknowledgeAlert` throws
`BusinessException(404, "System alert not found: " + id)` when
`findAlertById` is empty. Since the call
resolved, `SystemAlertsPage.handleAck` marked the row acknowledged locally
and toasted
`sysAlerts.acknowledged`, where the real data source takes the page's
existing
`sysAlerts.acknowledgeFailed` branch.
The lookup now throws the endpoint's message for a missing id, which is the
shape the ACL, certificate,
topic, consumer-group, name-server and proxy mock mutations already use. The
delete family in the same
service is deliberately left to the separate change that covers it (#6351),
and the delivery retries
have no inventory to look up in the demo source.
User-visible change: in the demo data source, acknowledging an alert that
the inventory does not hold
now reports a failure instead of claiming the acknowledgement. No copy is
added.
### How Did You Test This Change?
```
$ cd web && npx eslint src/services/opsService.test.ts
src/services/opsService.ts
# clean
$ cd web && npx prettier --check src/services/opsService.test.ts
src/services/opsService.ts
# clean
$ cd web && npx vitest run src/services/opsService.test.ts --maxWorkers=1
--fileParallelism=false
✓ src/services/opsService.test.ts (16 tests) 29ms
✓ rejects acknowledging an alert the mock inventory does not have
✓ still acknowledges an alert the mock inventory has
Test Files 1 passed (1)
Tests 16 passed (16)
$ cd web && npx tsc -b
# clean
```
The new test fails without the fix (this is the mutation check: the lookup
is restored without the
throw, the test is kept):
```
$ cd web && npx vitest run src/services/opsService.test.ts --maxWorkers=1
--fileParallelism=false
FAIL src/services/opsService.test.ts > ops service mock data > rejects
acknowledging an alert the mock inventory does not have
AssertionError: promise resolved "undefined" instead of rejecting
Test Files 1 failed (1)
Tests 1 failed | 15 passed (16)
```
The assertion is the 404 text the endpoint returns for the same id and the
promise rejecting, so it
can only pass once the mock lookup throws; `still acknowledges an alert the
mock inventory has` is the
control that fails if the guard is widened past the missing id, and the
fourteen neighbouring cases pin
the rest of the service.
### 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`
- [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
- [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [ ] New source files carry the ASF license header
- [ ] Documentation touched where behaviour changed (README / `docs` /
in-app help)
--
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]