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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6804
   
   ### Brief Description
   
   The alert rules table's "运行态" column named only two of the five 
`AlertStateStatus` values. `FIRING` and `PENDING` render through their 
localized count labels, but everything else fell back to `states[0].status` and 
printed the raw English enum — and the other three are real: the state machine 
writes `RESOLVED` (`AlertStateMachine.java:92`) and `OK` (`:95`), the 
acknowledge flow stores `ACKED` (read back at 
`MybatisPlusAlertStateRepository.java:116`), and `toRuntime` (`:135`, comment 
at `:137`) documents that ACKED and RESOLVED rows carry `lastNotifiedAt`. A new 
`runtimeStateLabels` map (`alerts.tsx:108-112`) names `OK` (正常), `RESOLVED` 
(reusing the existing `sysAlerts.resolved`) and `ACKED` (已确认) and colours them, 
so the cell shows a state in the viewer's language; FIRING/PENDING keep their 
count labels and the "未采集" empty state is unchanged.
   
   ### How Did You Test This Change?
   
   ```
   $ ./wb test --tree worktrees/rocketmq-dashboard/alerts-runtime-state-names 
--filter src/pages/ops/__tests__/AlertsPage.test.tsx
   ✓ npx eslint src/i18n/translations.ts 
src/pages/ops/__tests__/AlertsPage.test.tsx src/pages/ops/alerts.tsx
   ✓ npx prettier --check …
   ✓ npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx
   ✓ npx tsc -b
   
    Test Files  1 passed (1)
         Tests  36 passed (36)
   
   $ npx vitest run src/i18n/__tests__/translations.test.ts     # the two new 
key pairs
    Test Files  1 passed (1)
         Tests  2 passed (2)
   ```
   
   (The change set includes `translations.ts`, so `vitest related` expands to 
every file that imports the dictionary and exceeds the 600s budget — the two 
focused runs above are the checks that actually ran, plus eslint/prettier/tsc 
over all three changed files.)
   
   The new test fails without the fix:
   
   ```
   $ npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx
     FAIL  src/pages/ops/__tests__/AlertsPage.test.tsx > AlertsPage > 
namesEveryRuleRuntimeStateInsteadOfPrintingTheEnumTest
     TestingLibraryElementError: Unable to find an element with the text: 已确认. 
This could be because the text is broken up by multiple elements.
      ❯ src/pages/ops/__tests__/AlertsPage.test.tsx:274:25   expect(await 
screen.findByText('已确认')).toBeInTheDocument();
    Test Files  1 failed (1)
         Tests  1 failed | 35 passed (36)
   ```
   
   The assertion looks for the localized label of the `ACKED` row; with the 
mapping reverted the cell renders the literal `ACKED`, so the label is absent 
and the query flips to red.
   
   ### 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/`
   - [ ] 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]

Reply via email to