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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6677
   
   ### Brief Description
   
   The alert rule editor's 窗口聚合 select printed the API codes `LAST` / `MAX` / 
`MIN` / `AVG` / `SUM` as its
   visible option labels, while every other field of the same form is named 
(规则名称, RocketMQ 实例, 监控指标,
   持续时间, 重提醒间隔, 窗口秒数, 连续采样次数, 通知渠道). `LAST` in particular does not say what it 
aggregates —
   the newest sample in the window — so the operator had to guess what the rule 
would evaluate.
   
   - `web/src/pages/ops/alerts.tsx` keeps the five values the backend accepts 
in one map
     (`aggregationLabelKeys`, documented against `AlertRuleRequestDTO`, which 
rejects anything else) and
     renders the option list through the dictionary. A value without a label 
would still be printed
     unchanged rather than hidden.
   - New dictionary entries, Chinese and English: 
`alerts.aggregation.{LAST,MAX,MIN,AVG,SUM}`
     (最近一次/最大值/最小值/平均值/总和; Latest/Maximum/Minimum/Average/Sum).
   - The payload sent to `POST /api/cluster-alert-rules/create` is unchanged — 
the option *values* stay
     `LAST | MAX | MIN | AVG | SUM`, only what the operator reads changed.
   
   ### How Did You Test This Change?
   
   Red first, on the current `rocketmq-studio` tip (e2f815fb), with the added 
test in place and only the
   source reverted:
   
   ```
   $ cd web && npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx 
--maxWorkers=1
    × names the window aggregations instead of printing the API codes
      TestingLibraryElementError: Unable to find an element with the text: 最近一次.
    Test Files  1 failed (1)
         Tests  1 failed | 33 passed (34)
   ```
   
   Green with the change:
   
   ```
   $ cd web && npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx 
src/i18n/__tests__/translations.test.ts --maxWorkers=1
    Test Files  2 passed (2)
         Tests  36 passed (36)
   $ npx tsc -b
     (clean)
   $ npx eslint src/pages/ops/alerts.tsx 
src/pages/ops/__tests__/AlertsPage.test.tsx
     (0 errors; the 5 warnings are the pre-existing ones on these two files — a 
baseline run prints the same 5)
   $ npx prettier --check src/pages/ops/alerts.tsx 
src/pages/ops/__tests__/AlertsPage.test.tsx src/i18n/translations.ts
    All matched files use Prettier code style!
   ```
   
   Against a running stack (this commit + MySQL + a 5.3.2 broker), opening 新建规则:
   
   | before | after |
   | --- | --- |
   | the field reads 窗口聚合 `LAST`; the dropdown lists `LAST, MAX, MIN, AVG, SUM` 
| the field reads 窗口聚合 最近一次; the dropdown lists 最近一次, 最大值, 最小值, 平均值, 总和 |
   
   One note for anyone extending this test: antd renders a hidden aria mirror 
next to the visible list
   (`role="option"` whose text is the raw value and whose `aria-label` is the 
label), so the case asserts
   the `.ant-select-item-option-content` list instead of `queryByText('LAST')`, 
which the mirror would
   satisfy even when the visible labels are correct.
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`fix(web): ...`)
   - [x] Tests added or updated for non-trivial changes — the added case pins 
the default selection and
         the five visible option labels
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/`
   - [x] Architecture constraints stay green — no Java/backend change, so the 
ArchUnit checks are untouched
   - [x] New source files carry the ASF license header — no new files
   - [x] Documentation touched where behaviour changed — not applicable; the 
same values are sent, only
         their labels changed
   
   Disclosed rather than left to be discovered on merge, because these open PRs 
touch the same file:
   
   - #6297 (invalidate the alert-rule test result when the criteria change) and 
#6670 (render legacy ratio
     thresholds without floating-point residue) both edit 
`pages/ops/alerts.tsx`, as does my #6348 (the
     instance-list failure state). This change touches only the aggregation 
`Form.Item` in the rule
     editor, so whichever merges second may need a small rebase.
   
   AI assistance: the analysis, the change and the tests were produced with AI 
assistance (an agent working
   in this repository) and reviewed by me before submission; the verification 
output above is from the
   actual runs.
   


-- 
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