mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Remove console logs, fix aggregate errors and add missing endpoint
This commit is contained in:
committed by
Tom Ratcliffe
parent
8c313add00
commit
820f4f0ef5
@@ -155,6 +155,7 @@ beforeAll(() => {
|
|||||||
|
|
||||||
describe('RuleList', () => {
|
describe('RuleList', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
alertingServer.listen({ onUnhandledRequest: 'error' });
|
||||||
grantUserPermissions([
|
grantUserPermissions([
|
||||||
AccessControlAction.AlertingRuleRead,
|
AccessControlAction.AlertingRuleRead,
|
||||||
AccessControlAction.AlertingRuleUpdate,
|
AccessControlAction.AlertingRuleUpdate,
|
||||||
@@ -178,10 +179,15 @@ describe('RuleList', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
alertingServer.resetHandlers();
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
setDataSourceSrv(undefined as unknown as DataSourceSrv);
|
setDataSourceSrv(undefined as unknown as DataSourceSrv);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
alertingServer.close();
|
||||||
|
});
|
||||||
|
|
||||||
it('load & show rule groups from multiple cloud data sources', async () => {
|
it('load & show rule groups from multiple cloud data sources', async () => {
|
||||||
mocks.getAllDataSourcesMock.mockReturnValue(Object.values(dataSources));
|
mocks.getAllDataSourcesMock.mockReturnValue(Object.values(dataSources));
|
||||||
|
|
||||||
@@ -571,7 +577,6 @@ describe('RuleList', () => {
|
|||||||
|
|
||||||
describe('pausing rules', () => {
|
describe('pausing rules', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
alertingServer.listen({ onUnhandledRequest: 'error' });
|
|
||||||
grantUserPermissions([
|
grantUserPermissions([
|
||||||
AccessControlAction.AlertingRuleRead,
|
AccessControlAction.AlertingRuleRead,
|
||||||
AccessControlAction.AlertingRuleUpdate,
|
AccessControlAction.AlertingRuleUpdate,
|
||||||
@@ -585,12 +590,6 @@ describe('RuleList', () => {
|
|||||||
Promise.resolve(sourceName === 'grafana' ? pausedPromRules('grafana') : [])
|
Promise.resolve(sourceName === 'grafana' ? pausedPromRules('grafana') : [])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
|
||||||
alertingServer.resetHandlers();
|
|
||||||
});
|
|
||||||
afterAll(() => {
|
|
||||||
alertingServer.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('resuming paused alert rule', async () => {
|
test('resuming paused alert rule', async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
@@ -602,8 +601,6 @@ describe('RuleList', () => {
|
|||||||
|
|
||||||
expect(await ui.stateTags.paused.find()).toBeInTheDocument();
|
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
|
// TODO: Migrate all testing logic to MSW and so we aren't manually tweaking the API response behaviour
|
||||||
mocks.api.fetchRulerRules.mockImplementationOnce(() => {
|
mocks.api.fetchRulerRules.mockImplementationOnce(() => {
|
||||||
return Promise.resolve(getPotentiallyPausedRulerRules(false));
|
return Promise.resolve(getPotentiallyPausedRulerRules(false));
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ const alertingServer = setupServer(
|
|||||||
http.get('/api/v1/ngalert', () => {
|
http.get('/api/v1/ngalert', () => {
|
||||||
return HttpResponse.json({ alertmanagersChoice: 'all', numExternalAlertmanagers: 1 });
|
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', () => {
|
http.get('/api/folders/:folderUid', () => {
|
||||||
return HttpResponse.json({
|
return HttpResponse.json({
|
||||||
@@ -30,9 +34,6 @@ const alertingServer = setupServer(
|
|||||||
return HttpResponse.json([]);
|
return HttpResponse.json([]);
|
||||||
}),
|
}),
|
||||||
http.post('/api/ruler/grafana/api/v1/rules/:namespaceUID/', async ({ request }) => {
|
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({
|
return HttpResponse.json({
|
||||||
message: 'rule group updated successfully',
|
message: 'rule group updated successfully',
|
||||||
updated: ['foo', 'bar', 'baz'],
|
updated: ['foo', 'bar', 'baz'],
|
||||||
|
|||||||
Reference in New Issue
Block a user