fix: add alert report timeout limits (#12926)

* prevent working timeout and grace period from being set to negative numbers

* add extra validation

* lint

* fix black

* fix isort

* add js tests

* fix lint + more python schema validation

* add report schema test for timeout limits

* add extra test for null grace period
This commit is contained in:
Moriah Kreeger
2021-02-22 11:12:10 -08:00
committed by GitHub
parent 741219e84d
commit fc180ab2a6
4 changed files with 155 additions and 8 deletions

View File

@@ -260,4 +260,39 @@ describe('AlertReportModal', () => {
expect(addWrapper.find('input[name="grace_period"]')).toExist();
expect(wrapper.find('input[name="grace_period"]')).toHaveLength(0);
});
it('only allows grace period values > 1', async () => {
const props = {
...mockedProps,
isReport: false,
};
const addWrapper = await mountAndWait(props);
const input = addWrapper.find('input[name="grace_period"]');
input.simulate('change', { target: { name: 'grace_period', value: 7 } });
expect(input.instance().value).toEqual('7');
input.simulate('change', { target: { name: 'grace_period', value: 0 } });
expect(input.instance().value).toEqual('');
input.simulate('change', { target: { name: 'grace_period', value: -1 } });
expect(input.instance().value).toEqual('1');
});
it('only allows working timeout values > 1', () => {
const input = wrapper.find('input[name="working_timeout"]');
input.simulate('change', { target: { name: 'working_timeout', value: 7 } });
expect(input.instance().value).toEqual('7');
input.simulate('change', { target: { name: 'working_timeout', value: 0 } });
expect(input.instance().value).toEqual('');
input.simulate('change', {
target: { name: 'working_timeout', value: -1 },
});
expect(input.instance().value).toEqual('1');
});
});