codeant-ai-for-open-source[bot] commented on code in PR #41772:
URL: https://github.com/apache/superset/pull/41772#discussion_r3523655154
##########
superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx:
##########
@@ -2383,6 +2383,75 @@ describe('plugin-chart-table', () => {
expect(filters[0].val).toEqual(['Michael']);
});
});
+
+ describe('Search Select Dropdown conditionally rendering', () => {
+ it('does not render "Search by" if include_search is false (server
pagination enabled)', () => {
+ const props = transformProps({
+ ...testData.raw,
+ rawFormData: {
+ ...testData.raw.rawFormData,
+ server_pagination: true,
+ include_search: false,
+ },
+ });
+ render(
+ ProviderWrapper({
+ children: <TableChart {...props} sticky={false} />,
+ }),
+ );
+ expect(screen.queryByText('Search by:')).not.toBeInTheDocument();
+ });
+
+ it('does not render "Search by" if there are no search options (server
pagination enabled)', () => {
+ const props = transformProps({
+ ...testData.raw,
+ rawFormData: {
+ ...testData.raw.rawFormData,
+ server_pagination: true,
+ include_search: true,
+ },
+ queriesData: [
+ {
+ ...testData.raw.queriesData[0],
+ colnames: ['num'],
+ coltypes: [GenericDataType.Numeric],
+ data: [{ num: 1 }, { num: 2 }],
+ },
+ ],
+ });
+ render(
+ ProviderWrapper({
+ children: <TableChart {...props} sticky={false} />,
+ }),
+ );
+ expect(screen.queryByText('Search by:')).not.toBeInTheDocument();
+ });
+
+ it('renders "Search by" if include_search is true and there are search
options (server pagination enabled)', () => {
+ const props = transformProps({
+ ...testData.raw,
+ rawFormData: {
+ ...testData.raw.rawFormData,
+ server_pagination: true,
+ include_search: true,
+ },
+ queriesData: [
+ {
+ ...testData.raw.queriesData[0],
+ colnames: ['name'],
+ coltypes: [GenericDataType.String],
+ data: [{ name: 'Michael' }, { name: 'John' }],
+ },
+ ],
+ });
+ render(
+ ProviderWrapper({
+ children: <TableChart {...props} sticky={false} />,
+ }),
+ );
+ expect(screen.queryByText('Search by:')).toBeInTheDocument();
Review Comment:
**Suggestion:** The new assertions look for `Search by:` (with a colon), but
this table component renders `Search by` (without a colon). That makes the
positive test fail and allows the negative tests to pass even when the dropdown
is actually present. Update the queried text to match the rendered label so the
regression tests validate the real behavior. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Search dropdown visibility test fails despite correct behavior.
- ⚠️ Regression tests misvalidate label text and visibility.
- ⚠️ Future UI regressions may pass unnoticed by these tests.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open
`superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx` and
locate the search dropdown rendering block at lines 585-591, where the label
is rendered
as `t('Search by')` without any colon.
2. Open
`superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx` and
inspect the "Search Select Dropdown conditionally rendering" tests at lines
2388-2452,
which all use `screen.queryByText('Search by:')` (with a colon) in their
assertions.
3. Run the frontend Jest tests (e.g. `TableChart.test.tsx` via the project's
test runner);
the positive test `"renders "Search by" if include_search is true and there
are search
options (server pagination enabled)"` at lines 2430-2453 will fail because
no element with
exact text `Search by:` exists, even though the dropdown label `Search by`
is correctly
rendered.
4. Note that the two negative tests at lines 2388-2428 will still pass even
if a dropdown
with label `Search by` is accidentally rendered, because they query `Search
by:`
specifically; this mismatch between rendered text and asserted text means
the regression
tests do not accurately validate the real UI behavior.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=20cdafb91b7f4e008807a75788272f9f&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=20cdafb91b7f4e008807a75788272f9f&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:** 2402:2452
**Comment:**
*Logic Error: The new assertions look for `Search by:` (with a colon),
but this table component renders `Search by` (without a colon). That makes the
positive test fail and allows the negative tests to pass even when the dropdown
is actually present. Update the queried text to match the rendered label so the
regression tests validate the real behavior.
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%2F41772&comment_hash=a0a38b9b2ce2ccb9816153595ac81ca4049e86a82e0f3bf621f485e71c10690c&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41772&comment_hash=a0a38b9b2ce2ccb9816153595ac81ca4049e86a82e0f3bf621f485e71c10690c&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]