-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when insert a yaml which provides data by an extension
Also show samples in YAMLEditorField only if the user creates a new resource
- Loading branch information
Showing
17 changed files
with
179 additions
and
25 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
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
83 changes: 83 additions & 0 deletions
83
frontend/packages/dev-console/src/components/buildconfig/__tests__/InputField.spec.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,83 @@ | ||
import * as React from 'react'; | ||
import { TextInput } from '@patternfly/react-core'; | ||
import { render } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { Formik } from 'formik'; | ||
import { InputField } from '@console/shared/src'; | ||
|
||
describe('Pure HTML', () => { | ||
it('should update formik state with userEvent.type', () => { | ||
const onSubmit = jest.fn(); | ||
|
||
const renderResult = render( | ||
<Formik initialValues={{ name: 'initial name value' }} onSubmit={onSubmit}> | ||
{(formikProps) => ( | ||
<form onSubmit={formikProps.handleSubmit}> | ||
<label> | ||
<input {...formikProps.getFieldProps('name')} /> | ||
</label> | ||
<input type="submit" value="Submit" /> | ||
</form> | ||
)} | ||
</Formik>, | ||
); | ||
|
||
const inputField = renderResult.getByRole('textbox'); | ||
const submitButton = renderResult.getByRole('button'); | ||
|
||
userEvent.type(inputField, 'changed value'); | ||
userEvent.click(submitButton); | ||
|
||
expect(onSubmit).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
|
||
describe('PatternFly TextInput', () => { | ||
it('should update formik state with userEvent.type', () => { | ||
const onSubmit = jest.fn(); | ||
|
||
const renderResult = render( | ||
<Formik initialValues={{ name: 'initial name value' }} onSubmit={onSubmit}> | ||
{(formikProps) => ( | ||
<form onSubmit={formikProps.handleSubmit}> | ||
<TextInput {...formikProps.getFieldProps('name')} /> | ||
<input type="submit" value="Submit" /> | ||
</form> | ||
)} | ||
</Formik>, | ||
); | ||
|
||
const inputField = renderResult.getByRole('textbox'); | ||
const submitButton = renderResult.getByRole('button'); | ||
|
||
userEvent.type(inputField, 'changed value'); | ||
userEvent.click(submitButton); | ||
|
||
expect(onSubmit).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
|
||
describe('InputField', () => { | ||
it('should update formik state with userEvent.type', () => { | ||
const onSubmit = jest.fn(); | ||
|
||
const renderResult = render( | ||
<Formik initialValues={{ name: 'initial name value' }} onSubmit={onSubmit}> | ||
{(formikProps) => ( | ||
<form onSubmit={formikProps.handleSubmit}> | ||
<InputField name="name" /> | ||
<input type="submit" value="Submit" /> | ||
</form> | ||
)} | ||
</Formik>, | ||
); | ||
|
||
const inputField = renderResult.getByRole('textbox'); | ||
const submitButton = renderResult.getByRole('button'); | ||
|
||
userEvent.type(inputField, 'changed value'); | ||
userEvent.click(submitButton); | ||
|
||
expect(onSubmit).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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
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
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.