codeant-ai-for-open-source[bot] commented on code in PR #41851:
URL: https://github.com/apache/superset/pull/41851#discussion_r3541405516
##########
superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx:
##########
@@ -2382,6 +2382,52 @@ describe('plugin-chart-table', () => {
expect(filters[0].col).toBe('name');
expect(filters[0].val).toEqual(['Michael']);
});
+
+ test('excludes UUID columns from Search By dropdown', async () => {
+ const props = transformProps({
+ ...testData.basic,
+ formData: {
+ ...testData.basic.formData,
+ server_pagination: true,
+ include_search: true,
+ },
+ datasource: {
+ ...testData.basic.datasource,
+ columns: [
+ { column_name: 'name', type: 'VARCHAR' },
+ { column_name: 'uuid_col', type: 'UUID' },
+ ],
+ },
+ queriesData: [
+ {
+ ...testData.basic.queriesData[0],
+ colnames: ['name', 'uuid_col'],
+ coltypes: [GenericDataType.String, GenericDataType.String],
+ data: [
+ {
+ name: 'Michael',
+ uuid_col: '123e4567-e89b-12d3-a456-426614174000',
+ },
+ ],
+ },
+ ],
+ });
+
+ render(
+ <ProviderWrapper>
+ <TableChart {...props} sticky={false} />
+ </ProviderWrapper>,
+ );
+
+ // Open the dropdown
+ const searchBySelect = screen.getByRole('combobox');
Review Comment:
**Suggestion:** The test uses an unscoped `getByRole('combobox')`, but this
render path includes both the page-size select and the Search By select, so the
query can throw due to multiple matches or open the wrong dropdown. Scope the
lookup to the Search By control (for example by accessible name/label or a
stable selector) before opening it. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ TableChart UUID search test breaks due to multiple comboboxes.
- ⚠️ Search By dropdown test becomes flaky over DOM changes.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Run the Jest test suite, focusing on `test('excludes UUID columns from
Search By
dropdown', ...)` in
`superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx`
around lines
2386–2430; this test calls `transformProps` with `server_pagination: true`
and
`include_search: true` and then renders `<TableChart {...props} />`.
2. Observe that `transformProps` in `src/transformProps.ts` (lines 519–598
and 760–839)
returns `includeSearch: true`, `serverPagination: true`, `rowCount > 0`, and
a positive
`pageSize` (derived from `server_page_length`), which `TableChart` passes
into `DataTable`
in `src/TableChart.tsx` (lines ~1629–1650) with `searchInput={includeSearch
&&
SearchInput}` and `selectPageSize={pageSize !== null && SelectPageSize}`.
3. Inside `DataTable` (`src/DataTable/DataTable.tsx`), the global controls
block (around
lines 560–595 from the grep output) renders both a page-size control and a
Search By
control when `hasPagination` is true and `searchInput` is truthy: it renders
`<SelectPageSize ... />` (page-size dropdown) and, when `serverPagination`
is true, wraps
a `SearchSelectDropdown` with the “Search by” label, so the DOM contains two
`RawAntdSelect` instances.
4. The page-size dropdown `RawAntdSelect` is created in
`src/DataTable/components/SelectPageSize.tsx` (lines 41–67) and exposed with
role
`combobox`, and the Search By dropdown `SearchSelectDropdown` uses
`RawAntdSelect` in
`src/DataTable/components/SearchSelectDropdown.tsx` (lines 39–48), also with
role
`combobox`; when the test line `const searchBySelect =
screen.getByRole('combobox');` at
`TableChart.test.tsx:2423` executes, React Testing Library finds multiple
elements with
role `combobox`, causing `getByRole` either to throw a “Found multiple
elements” error or
to bind to the page-size select instead of the Search By select, making the
test fail or
flaky when opening the wrong dropdown.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1253dfe404704cefab0421af13a91d5b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1253dfe404704cefab0421af13a91d5b&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/plugins/plugin-chart-table/test/TableChart.test.tsx
**Line:** 2423:2423
**Comment:**
*Logic Error: The test uses an unscoped `getByRole('combobox')`, but
this render path includes both the page-size select and the Search By select,
so the query can throw due to multiple matches or open the wrong dropdown.
Scope the lookup to the Search By control (for example by accessible name/label
or a stable selector) before opening it.
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%2F41851&comment_hash=69bf7a893b284a445b72cf04b3f4d9bfaaa438c4315b38972752c8496531d435&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41851&comment_hash=69bf7a893b284a445b72cf04b3f4d9bfaaa438c4315b38972752c8496531d435&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]