codeant-ai-for-open-source[bot] commented on code in PR #41772:
URL: https://github.com/apache/superset/pull/41772#discussion_r3523650842
##########
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:** Replace this newly introduced grouping block with standalone
`test()` cases (or flatten into existing tests) so the added component test
logic does not introduce a new `describe()` wrapper. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The added block is new component test code and it introduces a nested
describe() wrapper around only three related test cases. This matches the rule
against using describe() when standalone test() cases would suffice.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0c2b5e83640d4600b06f0fe9eb2b3554&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=0c2b5e83640d4600b06f0fe9eb2b3554&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:** 2387:2454
**Comment:**
*Custom Rule: Replace this newly introduced grouping block with
standalone `test()` cases (or flatten into existing tests) so the added
component test logic does not introduce a new `describe()` wrapper.
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=f4523a6242c073259b857eb67538b2941f964daf27ce7e66eba042e49c442824&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41772&comment_hash=f4523a6242c073259b857eb67538b2941f964daf27ce7e66eba042e49c442824&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]