Skip to content

Commit b753f80

Browse files
anwesha-palit-redhatvikram-raj
authored andcommitted
fix : removed required from task param in pipeline builder
1 parent 4d6a557 commit b753f80

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

src/components/pipeline-builder/__tests__/validation-utils.spec.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,86 @@ describe('Pipeline Build validation schema', () => {
434434
.catch(shouldHavePassed);
435435
});
436436

437+
it('should pass if the task params is string and empty', async () => {
438+
await withFormData({
439+
...initialPipelineFormData,
440+
tasks: [
441+
{
442+
name: 'test-task',
443+
taskSpec: embeddedTaskSpec,
444+
params: [{ name: 'test_param', value: '' }],
445+
},
446+
],
447+
})
448+
.then(hasResults)
449+
.catch(shouldHavePassed);
450+
});
451+
452+
it('should pass if the task params is array and empty', async () => {
453+
await withFormData({
454+
...initialPipelineFormData,
455+
tasks: [
456+
{
457+
name: 'test-task',
458+
taskSpec: embeddedTaskSpec,
459+
params: [{ name: 'test_param', value: [] }],
460+
},
461+
],
462+
})
463+
.then(hasResults)
464+
.catch(shouldHavePassed);
465+
});
466+
467+
it('should pass if the task params is array and has empty string as value', async () => {
468+
await withFormData({
469+
...initialPipelineFormData,
470+
tasks: [
471+
{
472+
name: 'test-task',
473+
taskSpec: embeddedTaskSpec,
474+
params: [{ name: 'test_param', value: [''] }],
475+
},
476+
],
477+
})
478+
.then(hasResults)
479+
.catch(shouldHavePassed);
480+
});
481+
482+
it('should pass if the task params is string and has a value', async () => {
483+
await withFormData({
484+
...initialPipelineFormData,
485+
tasks: [
486+
{
487+
name: 'test-task',
488+
taskSpec: embeddedTaskSpec,
489+
params: [{ name: 'test_param', value: 'some value' }],
490+
},
491+
],
492+
})
493+
.then(hasResults)
494+
.catch(shouldHavePassed);
495+
});
496+
497+
it('should pass if the task params is array and has values', async () => {
498+
await withFormData({
499+
...initialPipelineFormData,
500+
tasks: [
501+
{
502+
name: 'test-task',
503+
taskSpec: embeddedTaskSpec,
504+
params: [
505+
{
506+
name: 'test_param',
507+
value: ['some value arg1', 'some value arg2'],
508+
},
509+
],
510+
},
511+
],
512+
})
513+
.then(hasResults)
514+
.catch(shouldHavePassed);
515+
});
516+
437517
it('should fail if the taskSpec params are required and not provided', async () => {
438518
const taskSpecWithParam = merge({}, embeddedTaskSpec, {
439519
params: [{ name: 'name', description: 'Your name to echo out' }],

src/components/pipeline-builder/validation-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ const taskValidation = (
223223
name: yup.string().required(t('Required')),
224224
value: yup.lazy((value) => {
225225
if (Array.isArray(value)) {
226-
return yup.array().of(yup.string().required(t('Required')));
226+
return yup.array().of(yup.string());
227227
}
228228
return yup.string();
229229
}),
230+
type: yup.string().oneOf(['string', 'array']),
230231
}),
231232
)
232233
.test(

0 commit comments

Comments
 (0)