-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added UT for validation API related components (opensearch-project#252)
Signed-off-by: Amit Galitzky <[email protected]>
- Loading branch information
1 parent
96a0ab2
commit f95f52b
Showing
40 changed files
with
6,365 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default () => { | ||
process.env.TZ = 'UTC'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
public/components/CodeModal/__tests__/__snapshots__/CodeModal.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
public/pages/Dashboard/Components/__tests__/AnomaliesLiveCharts.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { render, waitFor } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { AnomaliesLiveChart } from '../AnomaliesLiveChart'; | ||
import { selectedDetectors } from '../../../../pages/utils/__tests__/constants'; | ||
import { Provider } from 'react-redux'; | ||
import { coreServicesMock } from '../../../../../test/mocks'; | ||
import { CoreServicesContext } from '../../../../components/CoreServices/CoreServices'; | ||
import { mockedStore } from '../../../../redux/utils/testUtils'; | ||
const anomalyResponse = [ | ||
{ | ||
ok: true, | ||
response: { | ||
anomaly_grade: 0.10949221682655441, | ||
data_start_time: 1651817250642, | ||
data_end_time: 1651817310642, | ||
detector_id: 'gtU2l4ABuV34PY9ITTdm', | ||
name: 'test2', | ||
}, | ||
}, | ||
]; | ||
const anomalyResultQuery = [ | ||
{ | ||
anomaly_grade: 0.10949221682655441, | ||
data_start_time: 1651817250642, | ||
data_end_time: 1651817310642, | ||
detector_id: 'gtU2l4ABuV34PY9ITTdm', | ||
}, | ||
]; | ||
|
||
jest.mock('../../utils/utils', () => ({ | ||
getLatestAnomalyResultsForDetectorsByTimeRange: jest.fn( | ||
() => anomalyResponse | ||
), | ||
getFloorPlotTime: jest.fn(() => 1651817250642), | ||
getLatestAnomalyResultsByTimeRange: jest.fn(() => anomalyResultQuery), | ||
visualizeAnomalyResultForXYChart: jest.fn(), | ||
})); | ||
describe('<AnomaliesLiveChart /> spec', () => { | ||
test('AnomaliesLiveChart with Sample anomaly data', async () => { | ||
const { container, getByTestId, getAllByText, getByText } = render( | ||
<Provider store={mockedStore()}> | ||
<CoreServicesContext.Provider value={coreServicesMock}> | ||
<AnomaliesLiveChart {...selectedDetectors} /> | ||
</CoreServicesContext.Provider> | ||
</Provider> | ||
); | ||
//mock current last update to a specific date so doesn't produce new snapshot each minute | ||
Date.now = jest.fn().mockReturnValue(new Date('2021-06-06T12:33:37.000Z')); | ||
await waitFor(() => { | ||
expect( | ||
getByTestId('dashboardFullScreenButton').innerHTML.includes( | ||
'euiIcon-isssLoaded' | ||
) | ||
); | ||
}); | ||
await waitFor(() => {}); | ||
expect(container).toMatchSnapshot(); | ||
getAllByText('Detector with the most recent anomaly'); | ||
}); | ||
}); |
Oops, something went wrong.