-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cases] Update io-ts types as strict (#156813)
## Summary This PR fixes #156156 It uses` io-ts strict` type to remove unnecessary attributes. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Jonathan Buttner <jonathan.buttner@elastic.co> Co-authored-by: Christos Nasikas <christos.nasikas@elastic.co>
- Loading branch information
1 parent
5fa2226
commit bc3e312
Showing
123 changed files
with
5,614 additions
and
817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { AlertResponseRt } from './alerts'; | ||
|
||
describe('Alerts', () => { | ||
describe('AlertResponseRt', () => { | ||
it('has expected attributes in request', () => { | ||
const defaultRequest = [{ id: '1', index: '2', attached_at: '3' }]; | ||
|
||
const query = AlertResponseRt.decode(defaultRequest); | ||
|
||
expect(query).toStrictEqual({ | ||
_tag: 'Right', | ||
right: defaultRequest, | ||
}); | ||
}); | ||
|
||
it('multiple attributes in request', () => { | ||
const defaultRequest = [ | ||
{ id: '1', index: '2', attached_at: '3' }, | ||
{ id: '2', index: '3', attached_at: '4' }, | ||
]; | ||
const query = AlertResponseRt.decode(defaultRequest); | ||
|
||
expect(query).toStrictEqual({ | ||
_tag: 'Right', | ||
right: defaultRequest, | ||
}); | ||
}); | ||
|
||
it('removes foo:bar attributes from request', () => { | ||
const defaultRequest = [{ id: '1', index: '2', attached_at: '3' }]; | ||
const query = AlertResponseRt.decode([{ ...defaultRequest[0], foo: 'bar' }]); | ||
|
||
expect(query).toStrictEqual({ | ||
_tag: 'Right', | ||
right: defaultRequest, | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { CaseAssigneesRt } from './assignee'; | ||
|
||
describe('Assignee', () => { | ||
describe('CaseAssigneesRt', () => { | ||
const defaultRequest = [{ uid: '1' }, { uid: '2' }]; | ||
|
||
it('has expected attributes in request', () => { | ||
const query = CaseAssigneesRt.decode(defaultRequest); | ||
|
||
expect(query).toStrictEqual({ | ||
_tag: 'Right', | ||
right: defaultRequest, | ||
}); | ||
}); | ||
|
||
it('removes foo:bar attributes from request', () => { | ||
const query = CaseAssigneesRt.decode([{ ...defaultRequest[0], foo: 'bar' }]); | ||
|
||
expect(query).toStrictEqual({ | ||
_tag: 'Right', | ||
right: [defaultRequest[0]], | ||
}); | ||
}); | ||
|
||
it('removes foo:bar attributes from assignees', () => { | ||
const query = CaseAssigneesRt.decode([{ uid: '1', foo: 'bar' }, { uid: '2' }]); | ||
|
||
expect(query).toStrictEqual({ | ||
_tag: 'Right', | ||
right: [{ uid: '1' }, { uid: '2' }], | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.