Alerting: increase timeout for silences tests (#41918)

This commit is contained in:
Nathan Rodman 2021-11-19 03:07:28 -08:00 committed by GitHub
parent 12e0a94316
commit 81155e2d55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,8 @@ import userEvent from '@testing-library/user-event';
jest.mock('./api/alertmanager');
const TEST_TIMEOUT = 60000;
const mocks = {
api: {
fetchSilences: typeAsJestMock(fetchSilences),
@ -99,7 +101,9 @@ describe('Silences', () => {
setDataSourceSrv(new MockDataSourceSrv(dataSources));
});
it('loads and shows silences', async () => {
it(
'loads and shows silences',
async () => {
renderSilences();
await waitFor(() => expect(mocks.api.fetchSilences).toHaveBeenCalled());
await waitFor(() => expect(mocks.api.fetchAlerts).toHaveBeenCalled());
@ -110,9 +114,13 @@ describe('Silences', () => {
expect(silences).toHaveLength(2);
expect(silences[0]).toHaveTextContent('foo=bar');
expect(silences[1]).toHaveTextContent('foo!=bar');
});
},
TEST_TIMEOUT
);
it('shows the correct number of silenced alerts', async () => {
it(
'shows the correct number of silenced alerts',
async () => {
mocks.api.fetchAlerts.mockImplementation(() => {
return Promise.resolve([
mockAlertmanagerAlert({
@ -134,9 +142,13 @@ describe('Silences', () => {
expect(silencedAlertRows).toHaveLength(2);
expect(silencedAlertRows[0]).toHaveTextContent('2');
expect(silencedAlertRows[1]).toHaveTextContent('0');
});
},
TEST_TIMEOUT
);
it('filters silences by matchers', async () => {
it(
'filters silences by matchers',
async () => {
renderSilences();
await waitFor(() => expect(mocks.api.fetchSilences).toHaveBeenCalled());
await waitFor(() => expect(mocks.api.fetchAlerts).toHaveBeenCalled());
@ -145,7 +157,9 @@ describe('Silences', () => {
userEvent.paste(queryBar, 'foo=bar');
await waitFor(() => expect(ui.silenceRow.getAll()).toHaveLength(1));
});
},
TEST_TIMEOUT
);
});
describe('Silence edit', () => {
@ -157,7 +171,9 @@ describe('Silence edit', () => {
setDataSourceSrv(new MockDataSourceSrv(dataSources));
});
it('prefills the matchers field with matchers params', async () => {
it(
'prefills the matchers field with matchers params',
async () => {
renderSilences(
`${baseUrlPath}?matchers=${encodeURIComponent('foo=bar,bar=~ba.+,hello!=world,cluster!~us-central.*')}`
);
@ -181,9 +197,13 @@ describe('Silence edit', () => {
expect(ui.editor.matcherName.query(matchers[3])).toHaveValue('cluster');
expect(ui.editor.matcherOperator(MatcherOperator.notRegex).query(matchers[3])).not.toBeNull();
expect(ui.editor.matcherValue.query(matchers[3])).toHaveValue('us-central.*');
});
},
TEST_TIMEOUT
);
it('creates a new silence', async () => {
it(
'creates a new silence',
async () => {
renderSilences(baseUrlPath);
await waitFor(() => expect(ui.editor.durationField.query()).not.toBeNull());
@ -246,5 +266,7 @@ describe('Silence edit', () => {
})
)
);
});
},
TEST_TIMEOUT
);
});