diff --git a/public/components/ContentPanel/ContentPanel.tsx b/public/components/ContentPanel/ContentPanel.tsx index 690ee45f..d3d89c04 100644 --- a/public/components/ContentPanel/ContentPanel.tsx +++ b/public/components/ContentPanel/ContentPanel.tsx @@ -49,7 +49,7 @@ const ContentPanel = (props: ContentPanelProps) => { ); return ( { margin="s" className={props.horizontalRuleClassName} /> -
- {props.children} -
+
{props.children}
) : null}
diff --git a/public/pages/ConfigureModel/containers/__tests__/ConfigureModel.test.tsx b/public/pages/ConfigureModel/containers/__tests__/ConfigureModel.test.tsx index 9dbb0c03..77a9e370 100644 --- a/public/pages/ConfigureModel/containers/__tests__/ConfigureModel.test.tsx +++ b/public/pages/ConfigureModel/containers/__tests__/ConfigureModel.test.tsx @@ -64,7 +64,7 @@ describe(' spec', () => { test('validate all required fields', async () => { const { getByText } = renderWithRouter(); fireEvent.click(getByText('Next')); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('You must enter a feature name'); getByText('You must select a field'); }); diff --git a/public/pages/DefineDetector/containers/__tests__/DefineDetector.test.tsx b/public/pages/DefineDetector/containers/__tests__/DefineDetector.test.tsx index cb6e5e59..fb1ea5a2 100644 --- a/public/pages/DefineDetector/containers/__tests__/DefineDetector.test.tsx +++ b/public/pages/DefineDetector/containers/__tests__/DefineDetector.test.tsx @@ -71,7 +71,7 @@ describe(' spec', () => { }); const { getByText } = renderWithRouter(); fireEvent.click(getByText('Next')); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('Detector name cannot be empty'); getByText('Must specify an index'); getByText('Required'); diff --git a/public/pages/DetectorDetail/containers/DetectorDetail.tsx b/public/pages/DetectorDetail/containers/DetectorDetail.tsx index 14c10a7a..20f7344f 100644 --- a/public/pages/DetectorDetail/containers/DetectorDetail.tsx +++ b/public/pages/DetectorDetail/containers/DetectorDetail.tsx @@ -161,7 +161,10 @@ export const DetectorDetail = (props: DetectorDetailProps) => { core.notifications.toasts.addDanger('Error getting all indices'); }); }; - getInitialIndices(); + // only need to check if indices exist after detector finishes loading + if (!isLoadingDetector) { + getInitialIndices(); + } }, [detector]); useEffect(() => { @@ -188,7 +191,7 @@ export const DetectorDetail = (props: DetectorDetailProps) => { // If the detector state was changed after opening the stop detector modal, // re-check if any jobs are running, and close the modal if it's not needed anymore useEffect(() => { - if (!isRTJobRunning && !isHistoricalJobRunning) { + if (!isRTJobRunning && !isHistoricalJobRunning && !isEmpty(detector)) { hideStopDetectorModal(); } }, [detector]); diff --git a/public/pages/DetectorsList/components/ListActions/__tests__/ListActions.test.tsx b/public/pages/DetectorsList/components/ListActions/__tests__/ListActions.test.tsx index 2f69fd63..eaf650f7 100644 --- a/public/pages/DetectorsList/components/ListActions/__tests__/ListActions.test.tsx +++ b/public/pages/DetectorsList/components/ListActions/__tests__/ListActions.test.tsx @@ -36,7 +36,7 @@ describe(' spec', () => { expect(queryByText('Stop')).toBeNull(); expect(queryByText('Delete')).toBeNull(); fireEvent.click(getByTestId('listActionsButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(queryByText('Start')).toBeNull(); expect(queryByText('Stop')).toBeNull(); expect(queryByText('Delete')).toBeNull(); @@ -50,7 +50,7 @@ describe(' spec', () => { expect(queryByText('Stop')).toBeNull(); expect(queryByText('Delete')).toBeNull(); fireEvent.click(getByTestId('listActionsButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(queryByText('Start real-time detectors')).not.toBeNull(); expect(queryByText('Stop real-time detectors')).not.toBeNull(); expect(queryByText('Delete detectors')).not.toBeNull(); @@ -60,7 +60,7 @@ describe(' spec', () => { ); fireEvent.click(getByTestId('listActionsButton')); - await waitFor(()=>{}); + await waitFor(() => {}); fireEvent.click(getByTestId('startDetectors')); expect(defaultProps.onStartDetectors).toHaveBeenCalled(); }); @@ -69,7 +69,7 @@ describe(' spec', () => { ); fireEvent.click(getByTestId('listActionsButton')); - await waitFor(()=>{}); + await waitFor(() => {}); fireEvent.click(getByTestId('stopDetectors')); expect(defaultProps.onStopDetectors).toHaveBeenCalled(); }); @@ -78,7 +78,7 @@ describe(' spec', () => { ); fireEvent.click(getByTestId('listActionsButton')); - await waitFor(()=>{}); + await waitFor(() => {}); fireEvent.click(getByTestId('deleteDetectors')); expect(defaultProps.onDeleteDetectors).toHaveBeenCalled(); }); diff --git a/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmDeleteDetectorsModal.test.tsx b/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmDeleteDetectorsModal.test.tsx index 4386d6a6..fa9987e4 100644 --- a/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmDeleteDetectorsModal.test.tsx +++ b/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmDeleteDetectorsModal.test.tsx @@ -74,11 +74,11 @@ describe(' spec', () => { const { getByTestId, getByPlaceholderText } = render( ); - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.type(getByPlaceholderText('delete'), 'foo'); - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.click(getByTestId('confirmButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(defaultDeleteProps.onStopDetectors).not.toHaveBeenCalled(); expect(defaultDeleteProps.onDeleteDetectors).not.toHaveBeenCalled(); expect(defaultDeleteProps.onConfirm).not.toHaveBeenCalled(); @@ -87,11 +87,11 @@ describe(' spec', () => { const { getByTestId, getByPlaceholderText } = render( ); - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.type(getByPlaceholderText('delete'), 'delete'); - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.click(getByTestId('confirmButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(defaultDeleteProps.onConfirm).toHaveBeenCalled(); }, 10000); test('should not show callout if no detectors are running', async () => { @@ -126,7 +126,7 @@ describe(' spec', () => { } /> ); - await waitFor(()=>{}); + await waitFor(() => {}); expect( queryByText('Some of the selected detectors are currently running.') ).not.toBeNull(); @@ -135,9 +135,9 @@ describe(' spec', () => { const { getByTestId } = render( ); - await waitFor(()=>{}); + await waitFor(() => {}); fireEvent.click(getByTestId('cancelButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(defaultDeleteProps.onHide).toHaveBeenCalled(); }); test('should call onStopDetectors when deleting running detectors', async () => { @@ -156,14 +156,14 @@ describe(' spec', () => { /> ); // Try clicking before 'delete' has been typed - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.click(getByTestId('confirmButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(defaultDeleteProps.onStopDetectors).not.toHaveBeenCalled(); userEvent.type(getByPlaceholderText('delete'), 'delete'); - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.click(getByTestId('confirmButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(defaultDeleteProps.onStopDetectors).toHaveBeenCalled(); }); }); diff --git a/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmStartDetectorsModal.test.tsx b/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmStartDetectorsModal.test.tsx index bd2b34b2..b920878b 100644 --- a/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmStartDetectorsModal.test.tsx +++ b/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmStartDetectorsModal.test.tsx @@ -59,7 +59,7 @@ describe(' spec', () => { ); fireEvent.click(getByTestId('confirmButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(defaultStartProps.onStartDetectors).toHaveBeenCalled(); expect(defaultStartProps.onConfirm).toHaveBeenCalled(); }); @@ -68,7 +68,7 @@ describe(' spec', () => { ); fireEvent.click(getByTestId('cancelButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(defaultStartProps.onHide).toHaveBeenCalled(); }); }); diff --git a/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmStopDetectorsModal.test.tsx b/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmStopDetectorsModal.test.tsx index d4654b08..49716c9a 100644 --- a/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmStopDetectorsModal.test.tsx +++ b/public/pages/DetectorsList/containers/ConfirmActionModals/__tests__/ConfirmStopDetectorsModal.test.tsx @@ -72,7 +72,7 @@ describe(' spec', () => { ); fireEvent.click(getByTestId('confirmButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(defaultStopProps.onStopDetectors).toHaveBeenCalled(); }); test('should call onHide() when closing', async () => { @@ -80,7 +80,7 @@ describe(' spec', () => { ); fireEvent.click(getByTestId('cancelButton')); - await waitFor(()=>{}); + await waitFor(() => {}); expect(defaultStopProps.onHide).toHaveBeenCalled(); }); }); diff --git a/public/pages/DetectorsList/containers/List/__tests__/List.test.tsx b/public/pages/DetectorsList/containers/List/__tests__/List.test.tsx index 4118e890..de908fb5 100644 --- a/public/pages/DetectorsList/containers/List/__tests__/List.test.tsx +++ b/public/pages/DetectorsList/containers/List/__tests__/List.test.tsx @@ -79,7 +79,7 @@ describe(' spec', () => { ...initialDetectorsState, requesting: true, }); - await waitFor(()=>{}); + await waitFor(() => {}); getByText( `A detector is an individual anomaly detection task. You can create multiple detectors, and all the detectors can run simultaneously, with each analyzing data from different sources. Create an anomaly detector to get started.` ); @@ -116,14 +116,18 @@ describe(' spec', () => { expect(queryByText('index_30')).toBeNull(); // Navigate to next page - await waitFor(() => userEvent.click(getAllByTestId('pagination-button-next')[0])); + await waitFor(() => + userEvent.click(getAllByTestId('pagination-button-next')[0]) + ); getByText('detector_name_30'); getByText('index_30'); expect(queryByText('detector_name_0')).toBeNull(); expect(queryByText('index_0')).toBeNull(); // Navigate to previous page - await waitFor(()=>userEvent.click(getAllByTestId('pagination-button-previous')[0])); + await waitFor(() => + userEvent.click(getAllByTestId('pagination-button-previous')[0]) + ); getByText('detector_name_0'); expect(queryByText('detector_name_30')).toBeNull(); }); @@ -161,23 +165,23 @@ describe(' spec', () => { requesting: true, }); // Default view 20 items per page - await waitFor(()=>{}); + await waitFor(() => {}); getByText('detector_name_0'); expect(queryByText('detector_name_30')).toBeNull(); // Sort by name (string sorting) userEvent.click(getAllByTestId('tableHeaderSortButton')[0]); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('detector_name_30'); expect(queryByText('detector_name_0')).toBeNull(); // Sort by indices (string sorting) userEvent.click(getAllByTestId('tableHeaderSortButton')[1]); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('index_0'); expect(queryByText('index_30')).toBeNull(); userEvent.click(getAllByTestId('tableHeaderSortButton')[1]); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('index_30'); expect(queryByText('index_0')).toBeNull(); @@ -185,21 +189,21 @@ describe(' spec', () => { // NOTE: this is assuming DETECTOR_STATE.RUNNING is higher alphabetically ('running') // than DETECTOR_STATE.DISABLED ('stopped') userEvent.click(getAllByTestId('tableHeaderSortButton')[2]); - await waitFor(()=>{}); + await waitFor(() => {}); expect(queryByText(DETECTOR_STATE.RUNNING)).not.toBeNull(); userEvent.click(getAllByTestId('tableHeaderSortButton')[2]); - await waitFor(()=>{}); + await waitFor(() => {}); expect(queryByText(DETECTOR_STATE.RUNNING)).toBeNull(); // Sort by totalAnomalies (numeric sorting) userEvent.click(getAllByTestId('tableHeaderSortButton')[3]); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('0'); getByText('19'); expect(queryByText('30')).toBeNull(); expect(queryByText('39')).toBeNull(); userEvent.click(getAllByTestId('tableHeaderSortButton')[3]); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('30'); getByText('39'); expect(queryByText('0')).toBeNull(); @@ -207,21 +211,21 @@ describe(' spec', () => { // Sort by last anomaly occurrence (date sorting) userEvent.click(getAllByTestId('tableHeaderSortButton')[4]); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('04/15/2020 9:00 AM'); expect(queryByText('04/15/2020 9:30 AM')).toBeNull(); userEvent.click(getAllByTestId('tableHeaderSortButton')[4]); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('04/15/2020 9:30 AM'); expect(queryByText('04/15/2020 9:00 AM')).toBeNull(); // Sort by last updated (date sorting) userEvent.click(getAllByTestId('tableHeaderSortButton')[5]); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('04/15/2020 7:00 AM'); expect(queryByText('04/15/2020 7:30 AM')).toBeNull(); userEvent.click(getAllByTestId('tableHeaderSortButton')[5]); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('04/15/2020 7:30 AM'); expect(queryByText('04/15/2020 7:00 AM')).toBeNull(); }, 20000); @@ -258,7 +262,7 @@ describe(' spec', () => { //Input search event userEvent.type(getByPlaceholderText('Search'), 'detector_name_38'); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('detector_name_38'); getByText('index_38'); expect(queryByText('detector_name_39')).toBeNull(); @@ -291,16 +295,16 @@ describe(' spec', () => { requesting: true, }); // Initial load, only first 20 items - await waitFor(()=>{}); + await waitFor(() => {}); getByText('detector_name_0'); // Go to next page userEvent.click(getAllByTestId('pagination-button-next')[0]); - await waitFor(()=>{}); + await waitFor(() => {}); // Search for detector which is on prev page userEvent.type(getByPlaceholderText('Search'), 'detector_name_0'); - await waitFor(()=>{}); + await waitFor(() => {}); getByText('detector_name_0'); expect(queryByText('detector_name_30')).toBeNull(); }); @@ -347,7 +351,7 @@ describe(' spec', () => { ...initialDetectorsState, requesting: true, }); - await waitFor(()=>{}); + await waitFor(() => {}); //Assert all visible text are available //Test1 Detector getByText(randomDetectors[0].name); @@ -385,7 +389,7 @@ describe(' spec', () => { }); const { getByText, getByTestId, getAllByRole, queryByText } = renderWithRouter(); - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.click(getAllByRole('checkbox')[0]); userEvent.click(getByTestId('listActionsButton')); userEvent.click(getByText('Start real-time detectors')); @@ -413,7 +417,7 @@ describe(' spec', () => { }, }); const { getByText, getByTestId, getAllByRole } = renderWithRouter(); - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.click(getAllByRole('checkbox')[0]); userEvent.click(getByTestId('listActionsButton')); userEvent.click(getByText('Start real-time detectors')); @@ -441,7 +445,7 @@ describe(' spec', () => { }); const { getByText, getByTestId, getAllByRole, queryByText } = renderWithRouter(); - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.click(getAllByRole('checkbox')[0]); userEvent.click(getByTestId('listActionsButton')); userEvent.click(getByText('Stop real-time detectors')); @@ -469,7 +473,7 @@ describe(' spec', () => { }, }); const { getByText, getByTestId, getAllByRole } = renderWithRouter(); - await waitFor(()=>{}); + await waitFor(() => {}); userEvent.click(getAllByRole('checkbox')[0]); userEvent.click(getByTestId('listActionsButton')); userEvent.click(getByText('Stop real-time detectors')); @@ -542,7 +546,7 @@ describe(' spec', () => { }, }); const { getByText, getByTestId, getAllByRole } = renderWithRouter(); - await waitFor(()=>{}); + await waitFor(() => {}); // Try to delete disabled detector userEvent.click(getAllByRole('checkbox')[1]); userEvent.click(getByTestId('listActionsButton')); diff --git a/public/pages/Overview/components/SampleDataBox/SampleDataBox.tsx b/public/pages/Overview/components/SampleDataBox/SampleDataBox.tsx index 367d0c8d..0f544d27 100644 --- a/public/pages/Overview/components/SampleDataBox/SampleDataBox.tsx +++ b/public/pages/Overview/components/SampleDataBox/SampleDataBox.tsx @@ -65,14 +65,10 @@ export const SampleDataBox = (props: SampleDataBoxProps) => { } titleSize="s" betaBadgeLabel={props.isDataLoaded ? 'INSTALLED' : undefined} - paddingSize='l' + paddingSize="l" > - - +

{ ); -}; \ No newline at end of file +}; diff --git a/public/pages/Overview/containers/__tests__/AnomalyDetectionOverview.test.tsx b/public/pages/Overview/containers/__tests__/AnomalyDetectionOverview.test.tsx index e57a750f..60536abc 100644 --- a/public/pages/Overview/containers/__tests__/AnomalyDetectionOverview.test.tsx +++ b/public/pages/Overview/containers/__tests__/AnomalyDetectionOverview.test.tsx @@ -90,7 +90,7 @@ describe(' spec', () => { }, }); const { container, getByText, getAllByText } = renderWithRouter(); - await waitFor(()=>{}); + await waitFor(() => {}); expect(container).toMatchSnapshot(); getByText('Anomaly detection'); getByText('Monitor HTTP responses'); @@ -117,7 +117,7 @@ describe(' spec', () => { }, }); const { container, getByText, queryByText } = renderWithRouter(); - await waitFor(()=>{}); + await waitFor(() => {}); expect(container).toMatchSnapshot(); getByText('Anomaly detection'); getByText('Monitor HTTP responses');