codeant-ai-for-open-source[bot] commented on code in PR #42592:
URL: https://github.com/apache/superset/pull/42592#discussion_r3693991911
##########
superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.test.tsx:
##########
@@ -989,6 +989,45 @@ test('shows all options when filterOption is false', async
() => {
expect(options[0]).toHaveTextContent('Server 0');
});
+test('hides a server-matched option when its label diverges from the search
term and filterOption is left at the default (regression for #42041)', async ()
=> {
+ // Mirrors the real permissions-search bug: the remote fetch legitimately
+ // matches the raw, underscore-containing value (e.g. a schema name like
+ // "stg_silver"), but the returned option's displayed label has had
+ // underscores replaced with spaces (see formatPermissionLabel in
+ // features/roles/utils.ts). filterOption defaults to true, so AsyncSelect
+ // re-filters the already-matched options against the raw search term
+ // client-side. Since the underscore-typed search never appears as a
+ // substring of the space-formatted label, the legitimately fetched
+ // option gets hidden. Contrast with the `filterOption={false}` test
+ // above, which is the only way today's callers can avoid this.
+ const searchData = [{ label: 'stg silver', value: 100 }];
+ const loadOptions = jest.fn(async (search: string) =>
+ // totalCount must exceed the empty initial page here, otherwise
+ // AsyncSelect marks allValuesLoaded and short-circuits every later
+ // fetch, including the search request this test depends on.
+ search === ''
+ ? { data: [], totalCount: 1 }
+ : { data: searchData, totalCount: 1 },
+ );
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> In AsyncSelect rendering-focused tests, do not require validating backend
query-to-result mapping when the fixture already supplies a matched option;
cover query-to-result mapping in separate tests.
**Applied to:**
- `**/test/**`
- `**/tests/**`
- `**/*test*.tsx`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
##########
superset-frontend/src/features/roles/RoleFormItems.tsx:
##########
@@ -60,6 +60,13 @@ export const PermissionsField = ({
placeholder={t('Select permissions')}
options={options}
loading={loading}
+ // fetchPermissionOptions already filters server-side against the raw
+ // permission/view_menu names. AsyncSelect's default client-side
+ // re-filter checks the search term against the rendered label, but
+ // that label has had underscores replaced with spaces
+ // (formatPermissionLabel), so a raw-name search term never matches
+ // it and the correctly-fetched option gets hidden. See #42041.
+ filterOption={false}
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> In the permissions selector, preserve server-side filtering with
filterOption={false} so raw permission-name searches are not hidden by
relabeled options; accept that cached options may remain unfiltered after all
values load.
**Applied to:**
- `superset-frontend/src/features/roles/RoleFormItems.tsx`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]