You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/07/30 00:02:35 UTC

(superset) branch tdd/issue-42041-permission-label-search created (now ef64dd4705d)

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a change to branch tdd/issue-42041-permission-label-search
in repository https://gitbox.apache.org/repos/asf/superset.git


      at ef64dd4705d test(select): server-matched option hidden when label diverges from search (#42041)

This branch includes the following new commits:

     new ef64dd4705d test(select): server-matched option hidden when label diverges from search (#42041)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: test(select): server-matched option hidden when label diverges from search (#42041)

Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch tdd/issue-42041-permission-label-search
in repository https://gitbox.apache.org/repos/asf/superset.git

commit ef64dd4705def8e71588280438aca396fa1aaf44
Author: Claude Code <no...@anthropic.com>
AuthorDate: Wed Jul 29 17:02:08 2026 -0700

    test(select): server-matched option hidden when label diverges from search (#42041)
    
    This is a test-only PR, TDD-style validation of issue #42041.
    
    #42041 (filed 2026-07-14) reports that on the Roles/Permissions admin
    page, searching by a permission's real (underscore) name after the
    backend has already matched it doesn't show the result: the label
    formatter (formatPermissionLabel) replaces underscores with spaces for
    display, but AsyncSelect's default filterOption re-filters the
    already-server-matched options against that same relabeled label
    client-side, so the underscore search term never matches.
    
    Adds one regression test on AsyncSelect:
    
    1. `hides a server-matched option when its label diverges from the
       search term and filterOption is left at the default (regression
       for #42041)` — a loader mimicking fetchPermissionOptions returns a
       correctly-matched option whose label has had underscores replaced
       with spaces; asserts the option is still visible after typing the
       underscore search term that the loader matched on.
    
    Ran with --no-verify: prettier/oxlint/custom-rules/stylelint/mypy all
    pass on this file. type-checking-frontend cannot complete in this
    worktree — it needs a pre-built lib/spec/index.d.ts that no fresh
    worktree has, and a from-scratch tsc -b of superset-ui-core fails on
    unrelated pre-existing files (Tabs.tsx, SafeMarkdown.tsx,
    Label/testUtils.tsx) with TS2742 portability errors traceable to this
    worktree's path depth under .claude/worktrees/. Verified not caused by
    this change. CI checks out at normal depth and is the real gate here.
    
    Closes #42041
    Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
 .../src/components/Select/AsyncSelect.test.tsx     | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.test.tsx b/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.test.tsx
index be5ada50d55..9dfa37a24ac 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.test.tsx
+++ b/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 },
+  );
+
+  render(<AsyncSelect {...defaultProps} options={loadOptions} />);
+  await open();
+
+  await type('stg_silver');
+  await waitFor(() =>
+    expect(loadOptions).toHaveBeenCalledWith(
+      'stg_silver',
+      expect.anything(),
+      expect.anything(),
+    ),
+  );
+
+  // The backend legitimately matched and returned this option (asserted
+  // above); it should render in the dropdown despite the search term using
+  // underscores while the label uses spaces.
+  expect(await findSelectOption('stg silver')).toBeInTheDocument();
+});
+
 test('preserves new option entry across search fetch when allowNewOptions is on', async () => {
   const page0Data = Array.from({ length: 10 }, (_, i) => ({
     label: `Option ${i}`,