Skip to content

Commit

Permalink
Trim pipeline upload url before sending to backend (#2630)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobgy authored and k8s-ci-robot committed Nov 20, 2019
1 parent 0a873a9 commit 1b8daf7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions frontend/src/components/UploadPipelineDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ describe('UploadPipelineDialog', () => {
expect(spy).toHaveBeenLastCalledWith(true, 'test name', null, '', ImportMethod.LOCAL, '');
});

it('calls close callback with trimmed file url and pipeline name when confirmed', () => {
const spy = jest.fn();
tree = shallow(<UploadPipelineDialog open={false} onClose={spy} />);
// Click 'Import by URL'
tree.find('#uploadFromUrlBtn').simulate('change');
(tree.instance() as UploadPipelineDialog).handleChange('fileUrl')({
target: { value: '\n https://www.google.com/test-file.txt ' },
});
(tree.instance() as UploadPipelineDialog).handleChange('uploadPipelineName')({
target: { value: 'test name' },
});
tree.find('#confirmUploadBtn').simulate('click');
expect(spy).toHaveBeenLastCalledWith(
true,
'test name',
null,
'https://www.google.com/test-file.txt',
ImportMethod.URL,
'',
);
});

it('trims file extension for pipeline name suggestion', () => {
tree = shallow(<UploadPipelineDialog open={false} onClose={jest.fn()} />);
const file = { name: 'test_upload_file.tar.gz' };
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/UploadPipelineDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class UploadPipelineDialog extends React.Component<
confirmed,
this.state.uploadPipelineName,
this.state.file,
this.state.fileUrl,
this.state.fileUrl.trim(),
this.state.importMethod,
this.state.uploadPipelineDescription,
);
Expand Down

0 comments on commit 1b8daf7

Please sign in to comment.