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

   ## Summary
   
   - `components/InstanceSelect.tsx`: extract the instance-selector 
`filterOption` into an exported `matchesInstanceOption` helper that coerces 
**both** the search string and the option label with `String(...) ?? ''` before 
lower-casing.
   - `pages/settings/AiAssistantTab.tsx`: extract the two AutoComplete 
`filterOption`s (model selector + API-base preset selector) into one exported 
`matchesAiOption` helper with the same double-sided coercion; the old API-base 
filter additionally called `.toLowerCase()` on `option.value` without any 
`String()` guard, and all three old expressions called `input.toLowerCase()` 
unguarded.
   - Add regression suites for both helpers (case-insensitive match, empty 
input, nullish/non-string options and input).
   
   ## Why
   
   These dropdown filters compared user input against option fields without 
normalizing either side: a missing search string (`input.toLowerCase()` on 
`undefined`) or a non-string option value (`(option?.value ?? 
'').toLowerCase()` on a number/null payload) would throw inside antd's filter 
path and break the whole dropdown. This is the same class of gap already fixed 
for the studio producer-group selector (`matchesProducerGroupOption`) and the 
component already used the one-sided `String(option?.label ?? '')` pattern 
while leaving `input` unguarded.
   
   ## Testing
   
   - `cd web && ./node_modules/.bin/vitest run 
src/pages/settings/__tests__/aiAssistantOptionFilter.test.ts 
src/components/__tests__/instanceSelectFilter.test.ts` — 2 files, 10 new tests 
passed.
   - `cd web && ./node_modules/.bin/vitest run 
src/pages/settings/__tests__/AiAssistantTab.test.tsx` — 5 pre-existing tests 
still pass.
   - `cd web && ./node_modules/.bin/vitest run src/components` — 8 files, 58 
tests passed (no regressions in the shared component domain).
   - `cd web && ./node_modules/.bin/tsc --noEmit` — clean.
   - `cd web && ./node_modules/.bin/eslint 
src/pages/settings/AiAssistantTab.tsx src/components/InstanceSelect.tsx 
src/pages/settings/__tests__/aiAssistantOptionFilter.test.ts 
src/components/__tests__/instanceSelectFilter.test.ts` — 0 errors (2 
react-refresh warnings for the exported helpers, same precedent as other helper 
exports).
   


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