-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CCR] Improve remote clusters test coverage (#29487)
* Add Jest test for RemoteClusterForm validation state. * Extract validation functions out of RemoteClusterForm and add unit tests. - Return null instead of undefined from validators. * Add unit tests for different types of remote clusters in RemoteClusterTable. * Add unit test for RemoteClusterList empty prompt. * Add tests verifying behavior for row link, row delete button, and detail panel delete button. - Use getRouterLinkProps to assign onClick and href to edit buttons in row and detail panel.
- Loading branch information
Showing
22 changed files
with
1,101 additions
and
245 deletions.
There are no files selected for viewing
254 changes: 219 additions & 35 deletions
254
...ic/sections/components/remote_cluster_form/__snapshots__/remote_cluster_form.test.js.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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
161 changes: 161 additions & 0 deletions
161
...ctions/components/remote_cluster_form/validators/__snapshots__/validate_name.test.js.snap
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,161 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`validateName rejects empty input ' ' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name is required." | ||
id="xpack.remoteClusters.form.errors.nameMissing" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects empty input 'null' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name is required." | ||
id="xpack.remoteClusters.form.errors.nameMissing" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects empty input 'undefined' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name is required." | ||
id="xpack.remoteClusters.form.errors.nameMissing" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters ' ' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name is required." | ||
id="xpack.remoteClusters.form.errors.nameMissing" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '!' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '#' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '$' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '%' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '&' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '(' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters ')' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '*' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '+' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters ',' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '.' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '<' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '>' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '?' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '@' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; | ||
|
||
exports[`validateName rejects invalid characters '^' 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="Name contains invalid characters." | ||
id="xpack.remoteClusters.form.errors.illegalCharacters" | ||
values={Object {}} | ||
/> | ||
`; |
9 changes: 9 additions & 0 deletions
9
...tions/components/remote_cluster_form/validators/__snapshots__/validate_seeds.test.js.snap
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,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`validateSeeds rejects empty seeds when there's no input 1`] = ` | ||
<FormattedMessage | ||
defaultMessage="At least one seed node is required." | ||
id="xpack.remoteClusters.form.errors.seedMissing" | ||
values={Object {}} | ||
/> | ||
`; |
9 changes: 9 additions & 0 deletions
9
...lugins/remote_clusters/public/sections/components/remote_cluster_form/validators/index.js
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,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { validateName } from './validate_name'; | ||
export { validateSeed } from './validate_seed'; | ||
export { validateSeeds } from './validate_seeds'; |
Oops, something went wrong.