From 820f4f0ef52ab0ee1fd684e1fec605477709c23e Mon Sep 17 00:00:00 2001 From: Tom Ratcliffe Date: Tue, 26 Mar 2024 08:47:16 +0000 Subject: [PATCH] Remove console logs, fix aggregate errors and add missing endpoint --- .../features/alerting/unified/RuleList.test.tsx | 15 ++++++--------- .../app/features/alerting/unified/mock-server.ts | 7 ++++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/public/app/features/alerting/unified/RuleList.test.tsx b/public/app/features/alerting/unified/RuleList.test.tsx index 4ecbbba996b..9bca2d6be6b 100644 --- a/public/app/features/alerting/unified/RuleList.test.tsx +++ b/public/app/features/alerting/unified/RuleList.test.tsx @@ -155,6 +155,7 @@ beforeAll(() => { describe('RuleList', () => { beforeEach(() => { + alertingServer.listen({ onUnhandledRequest: 'error' }); grantUserPermissions([ AccessControlAction.AlertingRuleRead, AccessControlAction.AlertingRuleUpdate, @@ -178,10 +179,15 @@ describe('RuleList', () => { }); afterEach(() => { + alertingServer.resetHandlers(); jest.resetAllMocks(); setDataSourceSrv(undefined as unknown as DataSourceSrv); }); + afterAll(() => { + alertingServer.close(); + }); + it('load & show rule groups from multiple cloud data sources', async () => { mocks.getAllDataSourcesMock.mockReturnValue(Object.values(dataSources)); @@ -571,7 +577,6 @@ describe('RuleList', () => { describe('pausing rules', () => { beforeEach(() => { - alertingServer.listen({ onUnhandledRequest: 'error' }); grantUserPermissions([ AccessControlAction.AlertingRuleRead, AccessControlAction.AlertingRuleUpdate, @@ -585,12 +590,6 @@ describe('RuleList', () => { Promise.resolve(sourceName === 'grafana' ? pausedPromRules('grafana') : []) ); }); - afterEach(() => { - alertingServer.resetHandlers(); - }); - afterAll(() => { - alertingServer.close(); - }); test('resuming paused alert rule', async () => { const user = userEvent.setup(); @@ -602,8 +601,6 @@ describe('RuleList', () => { expect(await ui.stateTags.paused.find()).toBeInTheDocument(); - console.log(JSON.stringify(getPotentiallyPausedRulerRules(false), null, 4)); - // TODO: Migrate all testing logic to MSW and so we aren't manually tweaking the API response behaviour mocks.api.fetchRulerRules.mockImplementationOnce(() => { return Promise.resolve(getPotentiallyPausedRulerRules(false)); diff --git a/public/app/features/alerting/unified/mock-server.ts b/public/app/features/alerting/unified/mock-server.ts index eeeb717933c..ea7e3fb650f 100644 --- a/public/app/features/alerting/unified/mock-server.ts +++ b/public/app/features/alerting/unified/mock-server.ts @@ -17,6 +17,10 @@ const alertingServer = setupServer( http.get('/api/v1/ngalert', () => { return HttpResponse.json({ alertmanagersChoice: 'all', numExternalAlertmanagers: 1 }); }), + // TODO: Scaffold out test behaviour/configuration for plugins / incident endpoint + http.get('/api/plugins/grafana-incident-app/settings', () => { + return new HttpResponse(null, { status: 200 }); + }), http.get('/api/folders/:folderUid', () => { return HttpResponse.json({ @@ -30,9 +34,6 @@ const alertingServer = setupServer( return HttpResponse.json([]); }), http.post('/api/ruler/grafana/api/v1/rules/:namespaceUID/', async ({ request }) => { - console.log('updaint'); - const body = await request.json(); - console.log(JSON.stringify(body, null, 2)); return HttpResponse.json({ message: 'rule group updated successfully', updated: ['foo', 'bar', 'baz'],