From f5d814628b13dabf1806e32344b41d5a945bbb31 Mon Sep 17 00:00:00 2001 From: Lily Kuang Date: Tue, 28 Feb 2023 15:48:48 -0800 Subject: [PATCH] add test --- .../ControlPanelsContainer.test.tsx | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/superset-frontend/src/explore/components/ControlPanelsContainer.test.tsx b/superset-frontend/src/explore/components/ControlPanelsContainer.test.tsx index 2be8745fa1936..333d3ec799c22 100644 --- a/superset-frontend/src/explore/components/ControlPanelsContainer.test.tsx +++ b/superset-frontend/src/explore/components/ControlPanelsContainer.test.tsx @@ -17,6 +17,7 @@ * under the License. */ import React from 'react'; +import userEvent from '@testing-library/user-event'; import { render, screen } from 'spec/helpers/testing-library'; import { DatasourceType, @@ -104,5 +105,43 @@ describe('ControlPanelsContainer', () => { expect( await screen.findAllByTestId('collapsible-control-panel-header'), ).toHaveLength(4); + expect(screen.getByRole('tab', { name: /customize/i })).toBeInTheDocument(); + userEvent.click(screen.getByRole('tab', { name: /customize/i })); + expect( + await screen.findAllByTestId('collapsible-control-panel-header'), + ).toHaveLength(5); + }); + + test('renders ControlPanelSections no Customize Tab', async () => { + getChartControlPanelRegistry().registerValue('table', { + controlPanelSections: [ + { + label: t('GROUP BY'), + description: t( + 'Use this section if you want a query that aggregates', + ), + expanded: true, + controlSetRows: [ + ['groupby'], + ['metrics'], + ['percent_metrics'], + ['timeseries_limit_metric', 'row_limit'], + ['include_time', 'order_desc'], + ], + }, + { + label: t('Options'), + expanded: true, + controlSetRows: [], + }, + ], + }); + render(, { + useRedux: true, + }); + expect(screen.queryByText(/customize/i)).not.toBeInTheDocument(); + expect( + await screen.findAllByTestId('collapsible-control-panel-header'), + ).toHaveLength(2); }); });