codeant-ai-for-open-source[bot] commented on code in PR #42592:
URL: https://github.com/apache/superset/pull/42592#discussion_r3678897302


##########
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 () 
=> {

Review Comment:
   **Suggestion:** The test name says the option is expected to be hidden, but 
the assertion requires it to be visible. This contradicts the behavior being 
protected and can mislead maintainers into changing the implementation back 
toward the regression; rename the test to describe showing or preserving the 
server-matched option. [comment mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Minor ๐Ÿงน</summary>
   
   ```mdx
   - โš ๏ธ Test title contradicts its visibility assertion.
   - โš ๏ธ Maintainers may misinterpret the intended regression behavior.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=2672b6971b23458597a9ad4ad34333bb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=2672b6971b23458597a9ad4ad34333bb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.test.tsx
   **Line:** 992:992
   **Comment:**
        *Comment Mismatch: The test name says the option is expected to be 
hidden, but the assertion requires it to be visible. This contradicts the 
behavior being protected and can mislead maintainers into changing the 
implementation back toward the regression; rename the test to describe showing 
or preserving the server-matched option.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42592&comment_hash=9057f22937ac36db286898a0428de0016e5a21336d3deebe5780a9e2040f28b7&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42592&comment_hash=9057f22937ac36db286898a0428de0016e5a21336d3deebe5780a9e2040f28b7&reaction=dislike'>๐Ÿ‘Ž</a>



##########
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:
   **Suggestion:** The mock returns `searchData` for every non-empty query, so 
it does not verify that the loader actually matched the raw 
underscore-containing value. A broken backend/query-to-result mapping could 
still satisfy this test as long as `AsyncSelect` is called with `stg_silver`; 
make the mock return the option only for the expected query, or add an explicit 
assertion that the returned data represents that server-side match. [possible 
bug]
   
   <details>
   <summary><b>Severity Level:</b> Major โš ๏ธ</summary>
   
   ```mdx
   - โš ๏ธ AsyncSelect regression test does not validate query-to-result mapping.
   - โš ๏ธ Backend matching regressions can remain hidden by the permissive 
fixture.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=230566e72e454fb19cc4b2ef0d252867&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=230566e72e454fb19cc4b2ef0d252867&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.test.tsx
   **Line:** 1004:1011
   **Comment:**
        *Possible Bug: The mock returns `searchData` for every non-empty query, 
so it does not verify that the loader actually matched the raw 
underscore-containing value. A broken backend/query-to-result mapping could 
still satisfy this test as long as `AsyncSelect` is called with `stg_silver`; 
make the mock return the option only for the expected query, or add an explicit 
assertion that the returned data represents that server-side match.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42592&comment_hash=b38a0326ea83e964ca0e34b9cd1016a59d30dd105349468a0b883ba44d1acbcf&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42592&comment_hash=b38a0326ea83e964ca0e34b9cd1016a59d30dd105349468a0b883ba44d1acbcf&reaction=dislike'>๐Ÿ‘Ž</a>



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

Reply via email to