Commit 1e8e7efc authored by Brandon Labuschagne's avatar Brandon Labuschagne

Merge branch 'fix-dast-profile-update-variable' into 'master'

Set proper runAfter variable in edit mode

See merge request gitlab-org/gitlab!54039
parents 826cae5f 29e096af
...@@ -255,7 +255,7 @@ export default { ...@@ -255,7 +255,7 @@ export default {
: this.selectedScannerProfileId; : this.selectedScannerProfileId;
}, },
methods: { methods: {
onSubmit({ runAfterCreate = true, button = this.$options.saveAndRunScanBtnId } = {}) { onSubmit({ runAfter = true, button = this.$options.saveAndRunScanBtnId } = {}) {
if (this.glFeatures.dastSavedScans) { if (this.glFeatures.dastSavedScans) {
this.form.showValidation = true; this.form.showValidation = true;
if (!this.form.state) { if (!this.form.state) {
...@@ -279,7 +279,7 @@ export default { ...@@ -279,7 +279,7 @@ export default {
...input, ...input,
...(this.isEdit ? { id: this.dastScan.id } : {}), ...(this.isEdit ? { id: this.dastScan.id } : {}),
...serializeFormObject(this.form.fields), ...serializeFormObject(this.form.fields),
runAfterCreate, [this.isEdit ? 'runAfterUpdate' : 'runAfterCreate']: runAfter,
}; };
} }
...@@ -296,7 +296,7 @@ export default { ...@@ -296,7 +296,7 @@ export default {
if (errors?.length) { if (errors?.length) {
this.showErrors(ERROR_RUN_SCAN, errors); this.showErrors(ERROR_RUN_SCAN, errors);
this.loading = false; this.loading = false;
} else if (this.glFeatures.dastSavedScans && !runAfterCreate) { } else if (this.glFeatures.dastSavedScans && !runAfter) {
redirectTo(response.dastProfile.editPath); redirectTo(response.dastProfile.editPath);
this.clearStorage = true; this.clearStorage = true;
} else { } else {
...@@ -565,7 +565,7 @@ export default { ...@@ -565,7 +565,7 @@ export default {
data-testid="on-demand-scan-save-button" data-testid="on-demand-scan-save-button"
:disabled="isSaveButtonDisabled" :disabled="isSaveButtonDisabled"
:loading="loading === $options.saveScanBtnId" :loading="loading === $options.saveScanBtnId"
@click="onSubmit({ runAfterCreate: false, button: $options.saveScanBtnId })" @click="onSubmit({ runAfter: false, button: $options.saveScanBtnId })"
> >
{{ s__('OnDemandScans|Save scan') }} {{ s__('OnDemandScans|Save scan') }}
</gl-button> </gl-button>
......
...@@ -283,18 +283,12 @@ describe('OnDemandScansForm', () => { ...@@ -283,18 +283,12 @@ describe('OnDemandScansForm', () => {
describe('submission', () => { describe('submission', () => {
describe.each` describe.each`
action | actionFunction | submitButtonLoading | saveButtonLoading | runAfterCreate | redirectPath action | actionFunction | submitButtonLoading | saveButtonLoading | runAfter | redirectPath
${'submit'} | ${submitForm} | ${true} | ${false} | ${true} | ${pipelineUrl} ${'submit'} | ${submitForm} | ${true} | ${false} | ${true} | ${pipelineUrl}
${'save'} | ${saveScan} | ${false} | ${true} | ${false} | ${editPath} ${'save'} | ${saveScan} | ${false} | ${true} | ${false} | ${editPath}
`( `(
'on $action', 'on $action',
({ ({ actionFunction, submitButtonLoading, saveButtonLoading, runAfter, redirectPath }) => {
actionFunction,
submitButtonLoading,
saveButtonLoading,
runAfterCreate,
redirectPath,
}) => {
describe('with valid form data', () => { describe('with valid form data', () => {
beforeEach(async () => { beforeEach(async () => {
mountShallowSubject(); mountShallowSubject();
...@@ -311,7 +305,7 @@ describe('OnDemandScansForm', () => { ...@@ -311,7 +305,7 @@ describe('OnDemandScansForm', () => {
expect(saveButton.props('disabled')).toBe(!saveButtonLoading); expect(saveButton.props('disabled')).toBe(!saveButtonLoading);
}); });
it(`triggers dastProfileCreateMutation mutation with runAfterCreate set to ${runAfterCreate}`, () => { it(`triggers dastProfileCreateMutation mutation with runAfterCreate set to ${runAfter}`, () => {
expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({ expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({
mutation: dastProfileCreateMutation, mutation: dastProfileCreateMutation,
variables: { variables: {
...@@ -320,7 +314,7 @@ describe('OnDemandScansForm', () => { ...@@ -320,7 +314,7 @@ describe('OnDemandScansForm', () => {
dastScannerProfileId: passiveScannerProfile.id, dastScannerProfileId: passiveScannerProfile.id,
dastSiteProfileId: nonValidatedSiteProfile.id, dastSiteProfileId: nonValidatedSiteProfile.id,
fullPath: projectPath, fullPath: projectPath,
runAfterCreate, runAfterCreate: runAfter,
}, },
}, },
}); });
...@@ -350,7 +344,7 @@ describe('OnDemandScansForm', () => { ...@@ -350,7 +344,7 @@ describe('OnDemandScansForm', () => {
actionFunction(); actionFunction();
}); });
it(`triggers dastProfileUpdateMutation mutation with runAfterCreate set to ${runAfterCreate}`, async () => { it(`triggers dastProfileUpdateMutation mutation with runAfterUpdate set to ${runAfter}`, async () => {
expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({ expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({
mutation: dastProfileUpdateMutation, mutation: dastProfileUpdateMutation,
variables: { variables: {
...@@ -361,7 +355,7 @@ describe('OnDemandScansForm', () => { ...@@ -361,7 +355,7 @@ describe('OnDemandScansForm', () => {
dastScannerProfileId: passiveScannerProfile.id, dastScannerProfileId: passiveScannerProfile.id,
dastSiteProfileId: nonValidatedSiteProfile.id, dastSiteProfileId: nonValidatedSiteProfile.id,
fullPath: projectPath, fullPath: projectPath,
runAfterCreate, runAfterUpdate: runAfter,
}, },
}, },
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment