Skip to content

Commit

Permalink
fix test specs
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Aug 22, 2024
1 parent aa6462f commit 31cc493
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion superset-frontend/src/components/GridTable/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/
import type { Column, GridApi } from 'ag-grid-community';
import { act, fireEvent, render } from 'spec/helpers/testing-library';
import Header, { PIVOT_COL_ID } from './Header';
import Header from './Header';
import { PIVOT_COL_ID } from './constants';

jest.mock('src/components/Dropdown', () => ({
Dropdown: () => <div data-test="mock-dropdown" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jest.mock('src/components/Icons', () => ({
VerticalLeftOutlined: () => <div data-test="mock-VerticalLeftOutlined" />,
EyeInvisibleOutlined: () => <div data-test="mock-EyeInvisibleOutlined" />,
EyeOutlined: () => <div data-test="mock-EyeOutlined" />,
ColumnWidthOutlined: () => <div data-test="mock-column-width" />,
}));

jest.mock('src/components/Dropdown', () => ({
Expand Down Expand Up @@ -165,10 +166,7 @@ test('renders unhide when invisible column exists', async () => {

describe('for main menu', () => {
test('renders Copy to Clipboard', async () => {
const { getByText, queryByTestId } = render(
<HeaderMenu {...mockedProps} isMain />,
);
expect(queryByTestId('mock-Divider')).not.toBeInTheDocument();
const { getByText } = render(<HeaderMenu {...mockedProps} isMain />);
fireEvent.click(getByText('Copy the current data'));
await waitFor(() =>
expect(mockGridApi.getDataAsCsv).toHaveBeenCalledTimes(1),
Expand All @@ -192,14 +190,13 @@ describe('for main menu', () => {
});

test('renders all unhide all hidden columns when multiple invisible columns exist', async () => {
const { queryByTestId } = render(
render(
<HeaderMenu
{...mockedProps}
isMain
invisibleColumns={[mockInvisibleColumn, mockInvisibleColumn3]}
/>,
);
expect(queryByTestId('mock-Divider')).toBeInTheDocument();
const unhideColumnsButton = await screen.findByText(
`All ${2} hidden columns`,
);
Expand Down

0 comments on commit 31cc493

Please sign in to comment.