Set proper runAfter variable in edit mode

Ensures that the dastProfileUpdate mutation is sent with the correct
variable. It should be runAfterUpdate as opposed to runAfterCreate for
the dastProfileCreate mutation.
parent 42d0e21e
......@@ -255,7 +255,7 @@ export default {
: this.selectedScannerProfileId;
},
methods: {
onSubmit({ runAfterCreate = true, button = this.$options.saveAndRunScanBtnId } = {}) {
onSubmit({ runAfter = true, button = this.$options.saveAndRunScanBtnId } = {}) {
if (this.glFeatures.dastSavedScans) {
this.form.showValidation = true;
if (!this.form.state) {
......@@ -279,7 +279,7 @@ export default {
...input,
...(this.isEdit ? { id: this.dastScan.id } : {}),
...serializeFormObject(this.form.fields),
runAfterCreate,
[this.isEdit ? 'runAfterUpdate' : 'runAfterCreate']: runAfter,
};
}
......@@ -296,7 +296,7 @@ export default {
if (errors?.length) {
this.showErrors(ERROR_RUN_SCAN, errors);
this.loading = false;
} else if (this.glFeatures.dastSavedScans && !runAfterCreate) {
} else if (this.glFeatures.dastSavedScans && !runAfter) {
redirectTo(response.dastProfile.editPath);
this.clearStorage = true;
} else {
......@@ -565,7 +565,7 @@ export default {
data-testid="on-demand-scan-save-button"
:disabled="isSaveButtonDisabled"
:loading="loading === $options.saveScanBtnId"
@click="onSubmit({ runAfterCreate: false, button: $options.saveScanBtnId })"
@click="onSubmit({ runAfter: false, button: $options.saveScanBtnId })"
>
{{ s__('OnDemandScans|Save scan') }}
</gl-button>
......
......@@ -283,18 +283,12 @@ describe('OnDemandScansForm', () => {
describe('submission', () => {
describe.each`
action | actionFunction | submitButtonLoading | saveButtonLoading | runAfterCreate | redirectPath
${'submit'} | ${submitForm} | ${true} | ${false} | ${true} | ${pipelineUrl}
${'save'} | ${saveScan} | ${false} | ${true} | ${false} | ${editPath}
action | actionFunction | submitButtonLoading | saveButtonLoading | runAfter | redirectPath
${'submit'} | ${submitForm} | ${true} | ${false} | ${true} | ${pipelineUrl}
${'save'} | ${saveScan} | ${false} | ${true} | ${false} | ${editPath}
`(
'on $action',
({
actionFunction,
submitButtonLoading,
saveButtonLoading,
runAfterCreate,
redirectPath,
}) => {
({ actionFunction, submitButtonLoading, saveButtonLoading, runAfter, redirectPath }) => {
describe('with valid form data', () => {
beforeEach(async () => {
mountShallowSubject();
......@@ -311,7 +305,7 @@ describe('OnDemandScansForm', () => {
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({
mutation: dastProfileCreateMutation,
variables: {
......@@ -320,7 +314,7 @@ describe('OnDemandScansForm', () => {
dastScannerProfileId: passiveScannerProfile.id,
dastSiteProfileId: nonValidatedSiteProfile.id,
fullPath: projectPath,
runAfterCreate,
runAfterCreate: runAfter,
},
},
});
......@@ -350,7 +344,7 @@ describe('OnDemandScansForm', () => {
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({
mutation: dastProfileUpdateMutation,
variables: {
......@@ -361,7 +355,7 @@ describe('OnDemandScansForm', () => {
dastScannerProfileId: passiveScannerProfile.id,
dastSiteProfileId: nonValidatedSiteProfile.id,
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