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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #5263
   
   ### Brief Description
   
   This PR fixes the `mock/consumers.ts` divergence from issue #5263: the mock 
pinned
   `SubscriptionEntry.filterMode` to display labels the backend never sends.
   
   `SubscriptionFilterModes.fromExpressionType`
   
(`server/src/main/java/org/apache/rocketmq/studio/common/util/SubscriptionFilterModes.java`)
 is the
   only producer of `SubscriptionEntryVO.filterMode` and it emits `TAG`, `SQL` 
(normalized from
   `SQL92`) or `CLASS_FILTER`. Both providers use it 
(`RocketMQMetadataProvider.java:763`,
   `AliyunConverters.java:234`), and `CLASS_FILTER` appears nowhere in 
`web/src`, so the frontend only
   ever receives those three codes.
   
   `web/src/mock/consumers.ts` instead carried `'全量' | 'Tag 过滤' | 'SQL92 过滤'` 
in its interface and
   in all 23 `mockSubscriptions` rows. Because mock mode feeds the same rows to
   `web/src/pages/instance/consumer.tsx`, the subscription table in mock mode 
showed a vocabulary that
   can never appear against a real backend, which is exactly how the 
filter-mode rendering gap stayed
   invisible (the page colors the column with a map keyed on those labels).
   
   The mock data and its interface now use the codes the API emits (`'TAG' | 
'SQL' | 'CLASS_FILTER'`).
   `web/src/mock/consumers.test.ts` pins the vocabulary so the next fixture 
edit that drifts from the
   backend turns the suite red.
   
   The page-side label mapping in `web/src/pages/instance/consumer.tsx` is not 
touched here: it is
   outside the scope of this issue's fixtures and is a separate, user-visible 
defect.
   
   ### How Did You Test This Change?
   
   ```sh
   $ cd web && npx vitest run src/mock/consumers.test.ts      # before the fix
    FAIL  src/mock/consumers.test.ts > consumer subscription mock contract > 
pins filterMode to the values SubscriptionFilterModes emits
   AssertionError: expected [ '全量', 'Tag 过滤', 'SQL92 过滤' ] to deeply equal []
   
   - Expected
   + Received
   
   - []
   + [
   +   "全量",
   +   "Tag 过滤",
   +   "SQL92 过滤",
   + ]
   
    ❯ src/mock/consumers.test.ts:33:72
   
    Test Files  1 failed (1)
         Tests  1 failed (1)
   ```
   
   ```sh
   $ cd web && npx vitest run src/mock/consumers.test.ts 
src/services/consumerService.test.ts
    ✓ src/mock/consumers.test.ts (1 test) 8ms
    ✓ src/services/consumerService.test.ts (17 tests) 60ms
   
    Test Files  2 passed (2)
         Tests  18 passed (18)
   ```
   
   `npx tsc -b` and `npx eslint src/mock/consumers.test.ts 
src/mock/consumers.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
     text is added or changed; the mock now carries the codes the backend sends 
instead of labels
   - [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]

Reply via email to