Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaweiWu committed Aug 15, 2023
1 parent c60361e commit cfcee29
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions x-pack/plugins/observability/public/pages/alerts/alerts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ const fetchActiveMaintenanceWindowsMock = fetchActiveMaintenanceWindows as jest.
jest.mock('../../hooks/use_time_buckets', () => ({
useTimeBuckets: jest.fn(),
}));

jest.mock('../../hooks/use_has_data', () => ({
useHasData: jest.fn(),
}));

const { useTimeBuckets } = jest.requireMock('../../hooks/use_time_buckets');
const { useHasData } = jest.requireMock('../../hooks/use_has_data');

const queryClient = new QueryClient({
defaultOptions: {
Expand Down Expand Up @@ -138,6 +144,20 @@ describe('AlertsPage with all capabilities', () => {

beforeAll(() => {
fetchActiveMaintenanceWindowsMock.mockResolvedValue([]);
useHasData.mockReturnValue({
hasDataMap: {
apm: { hasData: true, status: 'success' },
synthetics: { hasData: true, status: 'success' },
infra_logs: { hasData: undefined, status: 'success' },
infra_metrics: { hasData: true, status: 'success' },
ux: { hasData: undefined, status: 'success' },
alert: { hasData: false, status: 'success' },
},
hasAnyData: true,
isAllRequestsComplete: true,
onRefreshTimeRange: () => {},
forceUpdate: '',
});
});

beforeEach(() => {
Expand Down

0 comments on commit cfcee29

Please sign in to comment.