-
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.
[Synthetics] Monitor Add/Edit - Fix form error states (#156626)
- Connects form validation states with react-hoom-form's state (which was the reason of the reported bug that the error state was only reflected in euiForm and not the react-hook-form) - Changes `reValidateMode` from `onChange` to `onSubmit` and manually invalidates the form when fields change so that dependent validations can be executed reactively e.g. fixes the following state: <img width="703" alt="Screenshot 2023-05-04 at 00 10 03" src="https://user-images.githubusercontent.com/2748376/236061192-a9417915-1eca-4cff-b871-b680955ec15a.png"> - Extracts validation and dependencies logic into a hook to simplify state management - Fixes the following error where "Response body max bytes" field appear despite "Index response body" flag being unchecked. <img width="1205" alt="Screenshot 2023-05-05 at 19 35 27" src="https://user-images.githubusercontent.com/2748376/236527581-ff62550a-2679-431e-8571-da02a89c0a32.png"> - Fixes a case where updated values from for nested fields (such as "Response body contains JSON") weren't being passed to monitor inspect component ("Inspect configuration" flyout on monitor Add/Edit).
- Loading branch information
Showing
22 changed files
with
990 additions
and
328 deletions.
There are no files selected for viewing
447 changes: 447 additions & 0 deletions
447
x-pack/plugins/synthetics/e2e/synthetics/journeys/monitor_form_validation.journey.ts
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
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/synthetics/e2e/synthetics/page_objects/utils.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,43 @@ | ||
/* | ||
* 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 { expect, Page } from '@elastic/synthetics'; | ||
|
||
export async function isEuiFormFieldInValid(locator: ReturnType<Page['locator']>) { | ||
const elementHandle = await locator.elementHandle(); | ||
expect(elementHandle).toBeTruthy(); | ||
|
||
const classAttribute = (await elementHandle!.asElement().getAttribute('class')) ?? ''; | ||
const isAriaInvalid = (await elementHandle!.asElement().getAttribute('aria-invalid')) ?? 'false'; | ||
|
||
return classAttribute.indexOf('-isInvalid') > -1 || isAriaInvalid === 'true'; | ||
} | ||
|
||
export async function clearAndType(locator: ReturnType<Page['locator']>, value: string) { | ||
await locator.fill(''); | ||
await locator.type(value); | ||
} | ||
|
||
export async function typeViaKeyboard(locator: ReturnType<Page['locator']>, value: string) { | ||
await locator.click(); | ||
await locator.page().keyboard.type(value); | ||
} | ||
|
||
export async function blur(locator: ReturnType<Page['locator']>) { | ||
await locator.evaluate((e) => { | ||
e.blur(); | ||
}); | ||
} | ||
|
||
export async function clickAndBlur(locator: ReturnType<Page['locator']>) { | ||
await locator.click(); | ||
await blur(locator); | ||
} | ||
|
||
export async function assertShouldNotExist(locator: ReturnType<Page['locator']>) { | ||
await locator.waitFor({ state: 'detached' }); | ||
} |
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
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
Oops, something went wrong.