Skip to content
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

fix(frontend): fix test creation with curl command #2463

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,26 +20,16 @@ const ImportCommand = () => {
[onNext]
);

const onRefreshData = useCallback(async () => {
useEffect(() => {
const {command} = draftTest as ICurlValues;
form.setFieldsValue({command});

try {
form.validateFields();
onIsFormValid(true);
} catch (err) {
onIsFormValid(false);
}
onIsFormValid(CurlService.getIsValidCommand(command));
}, [draftTest, form, onIsFormValid]);

useEffect(() => {
onRefreshData();
}, [onRefreshData]);

return (
<Step.Step>
<Step.FormContainer>
<Step.Title>Paste the CURL command</Step.Title>
<Step.Title>CURL command</Step.Title>
<Form<ICurlValues>
id={ComponentNames.ImportCommand}
autoComplete="off"
Expand Down
Expand Up @@ -10,14 +10,17 @@ const ImportCommandForm = () => {
return (
<S.InputContainer>
<Form.Item
label="Paste the CURL command"
name="command"
rules={[
{required: true, message: 'Please enter a command'},
{
validator: (_, command) => {
if (!CurlService.getIsValidCommand(command)) throw new Error('Invalid command');
if (!CurlService.getIsValidCommand(command)) {
return Promise.reject(new Error('Invalid CURL command'));
}

return Promise.resolve(true);
return Promise.resolve();
},
message: 'Invalid CURL command',
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Editor/CurlCommand/CurlCommand.tsx
Expand Up @@ -12,7 +12,7 @@ const CurlCommand = ({value, onChange}: IEditorProps) => {
basicSetup={{lineNumbers: true, indentOnInput: true}}
extensions={[StreamLanguage.define(shell)]}
spellCheck={false}
placeholder="Enter a curl command"
placeholder="curl -X POST http://site.com"
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion web/src/services/Triggers/Curl.service.ts
Expand Up @@ -18,7 +18,7 @@ const CurlTriggerService = (): ICurlTriggerService => ({

async validateDraft(draft) {
const {url, method} = draft as ICurlValues;
return Validator.required(url) && Validator.required(method) && Validator.url(url);
return Validator.required(url) && Validator.required(method);
},

getRequestFromCommand(command) {
Expand Down