hainenber commented on code in PR #41772:
URL: https://github.com/apache/superset/pull/41772#discussion_r3524362224
##########
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:
@durgaprasadml preferably, [new tests to be inline and not
nested](https://superset.apache.org/developer-docs/testing/testing-guidelines#avoid-nesting-when-youre-testing).
Can you help taking a look?
--
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]