Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lily Kuang committed Mar 29, 2023
1 parent 85ac0e9 commit f651879
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,25 @@
import React, { useState } from 'react';
import userEvent from '@testing-library/user-event';
import { render, screen } from 'spec/helpers/testing-library';
import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
import mockState from 'spec/fixtures/mockState';
import DrillByModal from './DrillByModal';

const { id: chartId, form_data: formData } = chartQueries[sliceId];
const { form_data: formData } = chartQueries[sliceId];
const { slice_name: chartName } = formData;

const renderModal = async () => {
const store = getMockStoreWithNativeFilters();
const drillByModalState = {
...mockState,
dashboardLayout: {
CHART_ID: {
id: 'CHART_ID',
meta: {
chartId: formData.slice_id,
sliceName: chartName,
},
},
},
};
const renderModal = async (state?: object) => {
const DrillByModalWrapper = () => {
const [showModal, setShowModal] = useState(false);
return (
Expand All @@ -37,9 +47,8 @@ const renderModal = async () => {
Show modal
</button>
<DrillByModal
chartId={chartId}
formData={formData}
initialFilters={[]}
filters={[]}
showModal={showModal}
onHideModal={() => setShowModal(false)}
/>
Expand All @@ -48,17 +57,18 @@ const renderModal = async () => {
};

render(<DrillByModalWrapper />, {
useRouter: true,
useDnd: true,
useRedux: true,
store,
useRouter: true,
initialState: state,
});

userEvent.click(screen.getByRole('button', { name: 'Show modal' }));
await screen.findByRole('dialog', { name: `Drill by: ${chartName}` });
};

test('should render the title', async () => {
await renderModal();
await renderModal(drillByModalState);
expect(screen.getByText(`Drill by: ${chartName}`)).toBeInTheDocument();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ export default function DrillByModal({
onHideModal,
showModal,
}: DrillByModalProps) {
console.log(column);
console.log(formData);
console.log(filters);
const theme = useTheme();
const dashboardLayout = useSelector<RootState, DashboardLayout>(
state => state.dashboardLayout.present,
Expand All @@ -80,6 +77,7 @@ export default function DrillByModal({
chartLayoutItem?.meta.sliceName || chartLayoutItem?.meta.sliceNameOverride;
const exploreChart = () => {};

console.log(column, filters);
return (
<Modal
css={css`
Expand Down

0 comments on commit f651879

Please sign in to comment.