-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Uptime] Switch from
EuiFieldNumber
to EuiFieldText
on settings p…
…age (#66425) (#68044) * Switch from `EuiFieldNumber` to `EuiFieldText` on settings page. * Add unit tests for cert form fields. * Improve validation. * Add additional server-side settings check with tests. * Only create number object for validation when value is string. * Clean up validation function. Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
884c162
commit 0883783
Showing
8 changed files
with
260 additions
and
20 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
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
35 changes: 35 additions & 0 deletions
35
x-pack/plugins/uptime/public/pages/__tests__/settings.test.tsx
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,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { isValidCertVal } from '../settings'; | ||
|
||
describe('settings', () => { | ||
describe('isValidCertVal', () => { | ||
it('handles NaN values', () => { | ||
expect(isValidCertVal(NaN)).toMatchInlineSnapshot(`"Must be a number."`); | ||
}); | ||
|
||
it('handles undefined', () => { | ||
expect(isValidCertVal(undefined)).toMatchInlineSnapshot(`"Must be a number."`); | ||
}); | ||
|
||
it('handles non-integer numbers', () => { | ||
expect(isValidCertVal(23.5)).toMatchInlineSnapshot(`"Value must be an integer."`); | ||
}); | ||
|
||
it('handles values less than 0', () => { | ||
expect(isValidCertVal(-1)).toMatchInlineSnapshot(`"Value must be greater than 0."`); | ||
}); | ||
|
||
it('handles 0', () => { | ||
expect(isValidCertVal(0)).toMatchInlineSnapshot(`"Value must be greater than 0."`); | ||
}); | ||
|
||
it('allows valid integer numbers', () => { | ||
expect(isValidCertVal(67)).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
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
77 changes: 77 additions & 0 deletions
77
x-pack/plugins/uptime/server/rest_api/__tests__/dynamic_settings.test.ts
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,77 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { validateCertsValues } from '../dynamic_settings'; | ||
|
||
describe('dynamic settings', () => { | ||
describe('validateCertValues', () => { | ||
it(`doesn't allow age threshold values less than 0`, () => { | ||
expect( | ||
validateCertsValues({ | ||
certAgeThreshold: -1, | ||
certExpirationThreshold: 2, | ||
heartbeatIndices: 'foo', | ||
}) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"certAgeThreshold": "Value must be greater than 0.", | ||
} | ||
`); | ||
}); | ||
|
||
it(`doesn't allow non-integer age threshold values`, () => { | ||
expect( | ||
validateCertsValues({ | ||
certAgeThreshold: 10.2, | ||
certExpirationThreshold: 2, | ||
heartbeatIndices: 'foo', | ||
}) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"certAgeThreshold": "Value must be an integer.", | ||
} | ||
`); | ||
}); | ||
|
||
it(`doesn't allow expiration threshold values less than 0`, () => { | ||
expect( | ||
validateCertsValues({ | ||
certAgeThreshold: 2, | ||
certExpirationThreshold: -1, | ||
heartbeatIndices: 'foo', | ||
}) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"certExpirationThreshold": "Value must be greater than 0.", | ||
} | ||
`); | ||
}); | ||
|
||
it(`doesn't allow non-integer expiration threshold values`, () => { | ||
expect( | ||
validateCertsValues({ | ||
certAgeThreshold: 2, | ||
certExpirationThreshold: 1.23, | ||
heartbeatIndices: 'foo', | ||
}) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"certExpirationThreshold": "Value must be an integer.", | ||
} | ||
`); | ||
}); | ||
|
||
it('allows valid values', () => { | ||
expect( | ||
validateCertsValues({ | ||
certAgeThreshold: 2, | ||
certExpirationThreshold: 13, | ||
heartbeatIndices: 'foo', | ||
}) | ||
).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
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