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

   ## Summary
   
   - Extract the client connection search matching in 
`pages/cluster/clients.tsx` into an exported, unit-testable 
`matchesClientSearch` helper.
   - Normalize the search input with `trim()` + `toLowerCase()` so 
whitespace-only input no longer empties the table (previously an untrimmed 
`""`/`"  "` search behaved inconsistently, and `toLowerCase()` alone left 
padding intact).
   - Guard `connection.clientId` (and `address`) against `null`/`undefined` 
payloads from the backend, which previously could throw `TypeError: Cannot read 
properties of undefined (reading 'toLowerCase')` and blank out the whole page.
   - Treat an empty / whitespace-only search as a full match, matching the 
behavior already used by the certs page search.
   
   ## Why
   
   The clients page search box fed raw user input directly into `toLowerCase()` 
and called `.toLowerCase()` unconditionally on backend-provided connection 
fields. In the same file `connection.address?.` is already defensively 
option-chained, showing the payload shape is not guaranteed to match the TS 
interface, yet `clientId` was not protected the same way.
   
   ## Testing
   
   - `cd web && ./node_modules/.bin/vitest run 
src/pages/cluster/__tests__/clientsSearch.test.ts 
src/pages/cluster/__tests__/ClientsPage.test.tsx` — 2 files, 20 tests passed (5 
new helper regression tests: case-insensitive id/address match, whitespace 
trimming, empty/undefined search, missing clientId/address fields).
   - `cd web && ./node_modules/.bin/tsc --noEmit` — clean.
   - `cd web && ./node_modules/.bin/eslint src/pages/cluster/clients.tsx 
src/pages/cluster/__tests__/clientsSearch.test.ts` — 0 errors (1 
pre-existing-style react-refresh warning for the exported helper, same 
precedent as `message.tsx`/`LiteTopic.tsx` page-level 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