From 6ec95a8daf52fe4890b98ab44c1fd8b13aa59e0a Mon Sep 17 00:00:00 2001 From: Jorge Padilla Date: Thu, 23 Feb 2023 09:47:51 -0500 Subject: [PATCH] fix(frontend): fix postman trigger validation (#2025) --- .../UploadCollection/UploadCollection.tsx | 13 +-- .../UploadCollection/UploadCollectionForm.tsx | 92 +++++++++---------- .../fields/CollectionFileField.tsx | 2 +- .../fields/SelectTestFromCollection.tsx | 2 +- web/src/services/Triggers/Postman.service.tsx | 4 +- 5 files changed, 50 insertions(+), 63 deletions(-) diff --git a/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/UploadCollection.tsx b/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/UploadCollection.tsx index 489818d653..bf712033dd 100644 --- a/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/UploadCollection.tsx +++ b/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/UploadCollection.tsx @@ -37,18 +37,9 @@ const UploadCollection = () => { onRefreshData(); }, [onRefreshData]); - const onValidateUrlChange = useCallback(async () => { - try { - await form.validateFields(); - onIsFormValid(true); - } catch (err) { - onIsFormValid(false); - } - }, [form, onIsFormValid]); - useEffect(() => { - onValidateUrlChange(); - }, [currentUrl, onValidateUrlChange]); + onValidate(null, form.getFieldsValue()); + }, [currentUrl, form, onValidate]); return ( diff --git a/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/UploadCollectionForm.tsx b/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/UploadCollectionForm.tsx index 06a9adb6fe..f3ef38873c 100644 --- a/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/UploadCollectionForm.tsx +++ b/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/UploadCollectionForm.tsx @@ -13,52 +13,50 @@ interface IProps { form: TDraftTestForm; } -const UploadCollectionForm = ({form}: IProps) => { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - form.setFieldsValue({body})} /> - - - - ); -}; +const UploadCollectionForm = ({form}: IProps) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + form.setFieldsValue({body})} /> + + + +); export default UploadCollectionForm; diff --git a/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/fields/CollectionFileField.tsx b/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/fields/CollectionFileField.tsx index efc50a49b6..325717e064 100644 --- a/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/fields/CollectionFileField.tsx +++ b/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/fields/CollectionFileField.tsx @@ -10,7 +10,7 @@ interface IProps { export const CollectionFileField = ({form}: IProps): React.ReactElement => ( diff --git a/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/fields/SelectTestFromCollection.tsx b/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/fields/SelectTestFromCollection.tsx index 90a93186af..676352e75a 100644 --- a/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/fields/SelectTestFromCollection.tsx +++ b/web/src/components/CreateTestPlugins/Postman/steps/UploadCollection/fields/SelectTestFromCollection.tsx @@ -13,7 +13,7 @@ export const SelectTestFromCollection = ({form}: IProps) => { const variables = useWatch('variables'); return ( diff --git a/web/src/services/Triggers/Postman.service.tsx b/web/src/services/Triggers/Postman.service.tsx index 5f8d0e7926..2733c8d1ea 100644 --- a/web/src/services/Triggers/Postman.service.tsx +++ b/web/src/services/Triggers/Postman.service.tsx @@ -40,9 +40,7 @@ const Postman = (): IPostmanTriggerService => ({ async validateDraft(draft) { const {collectionTest} = draft as IPostmanValues; - const isValid = Validator.required(collectionTest) && Validator.required(collectionTest); - - return isValid && HttpService.validateDraft(draft); + return Validator.required(collectionTest) && HttpService.validateDraft(draft); }, valuesFromRequest(requests, variables, identifier) { const request = requests.find(({id}) => identifier === id);