-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(frontend) Support LIST, STRUCT type in RuntimeConfig parameters #7991
Merged
google-oss-prow
merged 20 commits into
kubeflow:master
from
jlyaoyuli:support-List-Struct-Param
Jul 8, 2022
Merged
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f6a4169
Convert string-type user input to real-type pararmeter. (Currently su…
jlyaoyuli 643b23e
Delete unnecessary console.log
jlyaoyuli e5d0d68
Change incorrect type.
jlyaoyuli a5a8fc0
Format.
jlyaoyuli 5e91dff
Move inputConverter out from function component.
jlyaoyuli 2faedf8
Merge branch 'master' of https://github.com/kubeflow/pipelines into s…
jlyaoyuli ca71e50
Change inputConverter from if-else to switch.
jlyaoyuli b53aa87
1. Change paramTypeIdx to ParameterTypeEnum.
jlyaoyuli de688f5
Format
jlyaoyuli 91a8f77
Support LIST and STRUCT type.
jlyaoyuli 4a4225e
1. Fixed default value bugs.
jlyaoyuli d7628d8
Added type into param.
jlyaoyuli 91fc887
Merge branch 'master' of https://github.com/kubeflow/pipelines into s…
jlyaoyuli 29b452e
Added comment.
jlyaoyuli aeec427
Merge branch 'master' of https://github.com/kubeflow/pipelines into s…
jlyaoyuli 65a8c80
Added unit test for invalid JSON form input.
jlyaoyuli 1375a73
Removed incorrect merge conflicts.
jlyaoyuli 3edc791
Support double type.
jlyaoyuli d8412a8
Clean unnecessary expect() in the unit tests.
jlyaoyuli f61293e
Added additional tests to check for the existence of display value 4.56
jlyaoyuli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -48,14 +48,14 @@ describe('NewRunParametersV2', () => { | |
</CommonTestWrapper>, | ||
); | ||
|
||
expect(screen.getByText('Run parameters')); | ||
expect(screen.getByText('Specify parameters required by the pipeline')); | ||
expect(screen.getByText('strParam - STRING')); | ||
expect(screen.getByDisplayValue('string value')); | ||
expect(screen.getByText('boolParam - BOOLEAN')); | ||
expect(screen.getByDisplayValue('true')); | ||
expect(screen.getByText('intParam - NUMBER_INTEGER')); | ||
expect(screen.getByDisplayValue('123')); | ||
screen.getByText('Run parameters'); | ||
screen.getByText('Specify parameters required by the pipeline'); | ||
screen.getByText('strParam - STRING'); | ||
screen.getByDisplayValue('string value'); | ||
screen.getByText('boolParam - BOOLEAN'); | ||
screen.getByDisplayValue('true'); | ||
screen.getByText('intParam - NUMBER_INTEGER'); | ||
screen.getByDisplayValue('123'); | ||
}); | ||
|
||
it('edits parameters', () => { | ||
|
@@ -131,7 +131,7 @@ describe('NewRunParametersV2', () => { | |
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props}></NewRunParametersV2>); | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const strParam = screen.getByLabelText('strParam - STRING'); | ||
fireEvent.change(strParam, { target: { value: 'new string' } }); | ||
|
@@ -155,7 +155,7 @@ describe('NewRunParametersV2', () => { | |
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props}></NewRunParametersV2>); | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const boolParam = screen.getByDisplayValue('true'); | ||
fireEvent.change(boolParam, { target: { value: 'false' } }); | ||
|
@@ -178,7 +178,7 @@ describe('NewRunParametersV2', () => { | |
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props}></NewRunParametersV2>); | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const boolParam = screen.getByLabelText('boolParam - BOOLEAN'); | ||
fireEvent.change(boolParam, { target: { value: 'true' } }); | ||
|
@@ -201,7 +201,7 @@ describe('NewRunParametersV2', () => { | |
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props}></NewRunParametersV2>); | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const boolParam = screen.getByLabelText('boolParam - BOOLEAN'); | ||
fireEvent.change(boolParam, { target: { value: 'True' } }); | ||
|
@@ -225,7 +225,7 @@ describe('NewRunParametersV2', () => { | |
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props}></NewRunParametersV2>); | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const intParam = screen.getByDisplayValue('123'); | ||
fireEvent.change(intParam, { target: { value: '456' } }); | ||
|
@@ -248,7 +248,7 @@ describe('NewRunParametersV2', () => { | |
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props}></NewRunParametersV2>); | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const intParam = screen.getByLabelText('intParam - NUMBER_INTEGER'); | ||
fireEvent.change(intParam, { target: { value: '789' } }); | ||
|
@@ -271,7 +271,7 @@ describe('NewRunParametersV2', () => { | |
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props}></NewRunParametersV2>); | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const intParam = screen.getByLabelText('intParam - NUMBER_INTEGER'); | ||
fireEvent.change(intParam, { target: { value: '7.89' } }); | ||
|
@@ -281,6 +281,197 @@ describe('NewRunParametersV2', () => { | |
}); | ||
}); | ||
|
||
it('test convertInput function for double type with default value', () => { | ||
const handleParameterChangeSpy = jest.fn(); | ||
const props = { | ||
titleMessage: 'default Title', | ||
pipelineRoot: 'defalut pipelineRoot', | ||
specParameters: { | ||
doubleParam: { | ||
parameterType: ParameterType_ParameterTypeEnum.NUMBER_DOUBLE, | ||
defaultValue: 1.23, | ||
}, | ||
}, | ||
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const doubleParam = screen.getByDisplayValue('1.23'); | ||
fireEvent.change(doubleParam, { target: { value: '4.56' } }); | ||
expect(handleParameterChangeSpy).toHaveBeenCalledTimes(1); | ||
expect(handleParameterChangeSpy).toHaveBeenLastCalledWith({ | ||
doubleParam: 4.56, | ||
}); | ||
}); | ||
|
||
it('test convertInput function for double type without default value', () => { | ||
const handleParameterChangeSpy = jest.fn(); | ||
const props = { | ||
titleMessage: 'default Title', | ||
pipelineRoot: 'defalut pipelineRoot', | ||
specParameters: { | ||
doubleParam: { | ||
parameterType: ParameterType_ParameterTypeEnum.NUMBER_DOUBLE, | ||
}, | ||
}, | ||
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const doubleParam = screen.getByLabelText('doubleParam - NUMBER_DOUBLE'); | ||
fireEvent.change(doubleParam, { target: { value: '7.89' } }); | ||
expect(handleParameterChangeSpy).toHaveBeenCalledTimes(1); | ||
expect(handleParameterChangeSpy).toHaveBeenLastCalledWith({ | ||
doubleParam: 7.89, | ||
}); | ||
}); | ||
|
||
it('test convertInput function for LIST type with default value', () => { | ||
const handleParameterChangeSpy = jest.fn(); | ||
const props = { | ||
titleMessage: 'default Title', | ||
pipelineRoot: 'defalut pipelineRoot', | ||
specParameters: { | ||
listParam: { | ||
parameterType: ParameterType_ParameterTypeEnum.LIST, | ||
defaultValue: [1, 2, 3], | ||
}, | ||
}, | ||
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const listParam = screen.getByDisplayValue('[1,2,3]'); | ||
fireEvent.change(listParam, { target: { value: '[4,5,6]' } }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we check the screen now has [4,5,6]?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for all cases below. |
||
expect(handleParameterChangeSpy).toHaveBeenCalledTimes(1); | ||
expect(handleParameterChangeSpy).toHaveBeenLastCalledWith({ | ||
listParam: [4, 5, 6], | ||
}); | ||
screen.getByDisplayValue('[4,5,6]'); | ||
}); | ||
|
||
it('test convertInput function for LIST type without default value', () => { | ||
const handleParameterChangeSpy = jest.fn(); | ||
const props = { | ||
titleMessage: 'default Title', | ||
pipelineRoot: 'defalut pipelineRoot', | ||
specParameters: { | ||
listParam: { | ||
parameterType: ParameterType_ParameterTypeEnum.LIST, | ||
}, | ||
}, | ||
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const listParam = screen.getByLabelText('listParam - LIST'); | ||
fireEvent.change(listParam, { target: { value: '[4,5,6]' } }); | ||
zijianjoy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expect(handleParameterChangeSpy).toHaveBeenCalledTimes(1); | ||
expect(handleParameterChangeSpy).toHaveBeenLastCalledWith({ | ||
listParam: [4, 5, 6], | ||
}); | ||
screen.getByDisplayValue('[4,5,6]'); | ||
}); | ||
|
||
it('test convertInput function for LIST type with invalid input (invalid JSON form)', () => { | ||
const handleParameterChangeSpy = jest.fn(); | ||
const props = { | ||
titleMessage: 'default Title', | ||
pipelineRoot: 'defalut pipelineRoot', | ||
specParameters: { | ||
listParam: { | ||
parameterType: ParameterType_ParameterTypeEnum.LIST, | ||
}, | ||
}, | ||
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const listParam = screen.getByLabelText('listParam - LIST'); | ||
fireEvent.change(listParam, { target: { value: '[4,5,6' } }); | ||
expect(handleParameterChangeSpy).toHaveBeenCalledTimes(1); | ||
expect(handleParameterChangeSpy).toHaveBeenLastCalledWith({ | ||
listParam: null, | ||
}); | ||
}); | ||
|
||
it('test convertInput function for STRUCT type with default value', () => { | ||
const handleParameterChangeSpy = jest.fn(); | ||
const props = { | ||
titleMessage: 'default Title', | ||
pipelineRoot: 'defalut pipelineRoot', | ||
specParameters: { | ||
structParam: { | ||
parameterType: ParameterType_ParameterTypeEnum.STRUCT, | ||
defaultValue: { A: 1, B: 2 }, | ||
}, | ||
}, | ||
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const structParam = screen.getByDisplayValue('{"A":1,"B":2}'); | ||
fireEvent.change(structParam, { target: { value: '{"C":3,"D":4}' } }); | ||
expect(handleParameterChangeSpy).toHaveBeenCalledTimes(1); | ||
expect(handleParameterChangeSpy).toHaveBeenLastCalledWith({ | ||
structParam: { C: 3, D: 4 }, | ||
}); | ||
screen.getByDisplayValue('{"C":3,"D":4}'); | ||
}); | ||
|
||
it('test convertInput function for STRUCT type without default value', () => { | ||
const handleParameterChangeSpy = jest.fn(); | ||
const props = { | ||
titleMessage: 'default Title', | ||
pipelineRoot: 'defalut pipelineRoot', | ||
specParameters: { | ||
structParam: { | ||
parameterType: ParameterType_ParameterTypeEnum.STRUCT, | ||
}, | ||
}, | ||
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const structParam = screen.getByLabelText('structParam - STRUCT'); | ||
fireEvent.change(structParam, { target: { value: '{"A":1,"B":2}' } }); | ||
expect(handleParameterChangeSpy).toHaveBeenCalledTimes(1); | ||
expect(handleParameterChangeSpy).toHaveBeenLastCalledWith({ | ||
structParam: { A: 1, B: 2 }, | ||
}); | ||
screen.getByDisplayValue('{"A":1,"B":2}'); | ||
}); | ||
|
||
it('test convertInput function for STRUCT type with invalid input (invalid JSON form)', () => { | ||
const handleParameterChangeSpy = jest.fn(); | ||
const props = { | ||
titleMessage: 'default Title', | ||
pipelineRoot: 'defalut pipelineRoot', | ||
specParameters: { | ||
structParam: { | ||
parameterType: ParameterType_ParameterTypeEnum.STRUCT, | ||
}, | ||
}, | ||
handlePipelineRootChange: jest.fn(), | ||
handleParameterChange: handleParameterChangeSpy, | ||
}; | ||
render(<NewRunParametersV2 {...props} />); | ||
|
||
const structParam = screen.getByLabelText('structParam - STRUCT'); | ||
fireEvent.change(structParam, { target: { value: '"A":1,"B":2' } }); | ||
expect(handleParameterChangeSpy).toHaveBeenCalledTimes(1); | ||
expect(handleParameterChangeSpy).toHaveBeenLastCalledWith({ | ||
structParam: null, | ||
}); | ||
}); | ||
|
||
it('does not display any text fields if there are no parameters', () => { | ||
const { container } = render( | ||
<CommonTestWrapper> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For new tests: Please also check for the existence of display value 4.56. Just like we mentioned in https://github.com/kubeflow/pipelines/pull/7991/files#r916159217