Commit 91f693bb authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch '326200-refactor-on-demand-scans-specs' into 'master'

Rename subject to wrapper

See merge request gitlab-org/gitlab!58817
parents b55d3881 ed88f22d
...@@ -60,7 +60,7 @@ const LOCAL_STORAGE_KEY = 'group/project/on-demand-scans-new-form'; ...@@ -60,7 +60,7 @@ const LOCAL_STORAGE_KEY = 'group/project/on-demand-scans-new-form';
describe('OnDemandScansForm', () => { describe('OnDemandScansForm', () => {
let localVue; let localVue;
let subject; let wrapper;
let requestHandlers; let requestHandlers;
const GlFormInputStub = stubComponent(GlFormInput, { const GlFormInputStub = stubComponent(GlFormInput, {
...@@ -70,13 +70,13 @@ describe('OnDemandScansForm', () => { ...@@ -70,13 +70,13 @@ describe('OnDemandScansForm', () => {
template: '<input />', template: '<input />',
}); });
const findForm = () => subject.find(GlForm); const findForm = () => wrapper.find(GlForm);
const findByTestId = (testId) => subject.find(`[data-testid="${testId}"]`); const findByTestId = (testId) => wrapper.find(`[data-testid="${testId}"]`);
const findNameInput = () => findByTestId('dast-scan-name-input'); const findNameInput = () => findByTestId('dast-scan-name-input');
const findBranchInput = () => findByTestId('dast-scan-branch-input'); const findBranchInput = () => findByTestId('dast-scan-branch-input');
const findDescriptionInput = () => findByTestId('dast-scan-description-input'); const findDescriptionInput = () => findByTestId('dast-scan-description-input');
const findScannerProfilesSelector = () => subject.find(ScannerProfileSelector); const findScannerProfilesSelector = () => wrapper.find(ScannerProfileSelector);
const findSiteProfilesSelector = () => subject.find(SiteProfileSelector); const findSiteProfilesSelector = () => wrapper.find(SiteProfileSelector);
const findAlert = () => findByTestId('on-demand-scan-error'); const findAlert = () => findByTestId('on-demand-scan-error');
const findProfilesConflictAlert = () => findByTestId('on-demand-scans-profiles-conflict-alert'); const findProfilesConflictAlert = () => findByTestId('on-demand-scans-profiles-conflict-alert');
const findSubmitButton = () => findByTestId('on-demand-scan-submit-button'); const findSubmitButton = () => findByTestId('on-demand-scan-submit-button');
...@@ -89,10 +89,10 @@ describe('OnDemandScansForm', () => { ...@@ -89,10 +89,10 @@ describe('OnDemandScansForm', () => {
findBranchInput().vm.$emit('input', 'some-other-branch'); findBranchInput().vm.$emit('input', 'some-other-branch');
findScannerProfilesSelector().vm.$emit('input', passiveScannerProfile.id); findScannerProfilesSelector().vm.$emit('input', passiveScannerProfile.id);
findSiteProfilesSelector().vm.$emit('input', nonValidatedSiteProfile.id); findSiteProfilesSelector().vm.$emit('input', nonValidatedSiteProfile.id);
return subject.vm.$nextTick(); return wrapper.vm.$nextTick();
}; };
const setupSuccess = ({ edit = false } = {}) => { const setupSuccess = ({ edit = false } = {}) => {
subject.vm.$apollo.mutate.mockResolvedValue({ wrapper.vm.$apollo.mutate.mockResolvedValue({
data: { data: {
[edit ? 'dastProfileUpdate' : 'dastProfileCreate']: { [edit ? 'dastProfileUpdate' : 'dastProfileCreate']: {
dastProfile: { editPath }, dastProfile: { editPath },
...@@ -104,8 +104,8 @@ describe('OnDemandScansForm', () => { ...@@ -104,8 +104,8 @@ describe('OnDemandScansForm', () => {
return setValidFormData(); return setValidFormData();
}; };
const selectProfile = (component) => async (profile) => { const selectProfile = (component) => async (profile) => {
subject.find(component).vm.$emit('input', profile.id); wrapper.find(component).vm.$emit('input', profile.id);
await subject.vm.$nextTick(); await wrapper.vm.$nextTick();
}; };
const selectScannerProfile = selectProfile(ScannerProfileSelector); const selectScannerProfile = selectProfile(ScannerProfileSelector);
const selectSiteProfile = selectProfile(SiteProfileSelector); const selectSiteProfile = selectProfile(SiteProfileSelector);
...@@ -127,7 +127,7 @@ describe('OnDemandScansForm', () => { ...@@ -127,7 +127,7 @@ describe('OnDemandScansForm', () => {
]); ]);
}; };
const subjectMounterFactory = (mountFn = shallowMount) => (options = {}, withHandlers) => { const createComponentFactory = (mountFn = shallowMount) => (options = {}, withHandlers) => {
localVue = createLocalVue(); localVue = createLocalVue();
let defaultMocks = { let defaultMocks = {
$apollo: { $apollo: {
...@@ -144,7 +144,7 @@ describe('OnDemandScansForm', () => { ...@@ -144,7 +144,7 @@ describe('OnDemandScansForm', () => {
apolloProvider = createMockApolloProvider(withHandlers); apolloProvider = createMockApolloProvider(withHandlers);
defaultMocks = {}; defaultMocks = {};
} }
subject = mountFn( wrapper = mountFn(
OnDemandScansForm, OnDemandScansForm,
merge( merge(
{}, {},
...@@ -180,8 +180,8 @@ describe('OnDemandScansForm', () => { ...@@ -180,8 +180,8 @@ describe('OnDemandScansForm', () => {
), ),
); );
}; };
const mountSubject = subjectMounterFactory(mount); const createComponent = createComponentFactory(mount);
const mountShallowSubject = subjectMounterFactory(); const createShallowComponent = createComponentFactory();
const itClearsLocalStorage = () => { const itClearsLocalStorage = () => {
it('clears local storage', () => { it('clears local storage', () => {
...@@ -190,20 +190,20 @@ describe('OnDemandScansForm', () => { ...@@ -190,20 +190,20 @@ describe('OnDemandScansForm', () => {
}; };
afterEach(() => { afterEach(() => {
subject.destroy(); wrapper.destroy();
subject = null; wrapper = null;
localStorage.clear(); localStorage.clear();
}); });
describe('when creating a new scan', () => { describe('when creating a new scan', () => {
it('renders properly', () => { it('renders properly', () => {
mountSubject(); createComponent();
expect(subject.text()).toContain('New on-demand DAST scan'); expect(wrapper.text()).toContain('New on-demand DAST scan');
}); });
it('populates the branch input with the default branch', () => { it('populates the branch input with the default branch', () => {
mountSubject(); createComponent();
expect(findBranchInput().props('value')).toBe(defaultBranch); expect(findBranchInput().props('value')).toBe(defaultBranch);
}); });
...@@ -217,7 +217,7 @@ describe('OnDemandScansForm', () => { ...@@ -217,7 +217,7 @@ describe('OnDemandScansForm', () => {
`( `(
'sets loading state to $isLoading if scanner profiles loading is $scannerProfilesLoading and site profiles loading is $siteProfilesLoading', 'sets loading state to $isLoading if scanner profiles loading is $scannerProfilesLoading and site profiles loading is $siteProfilesLoading',
({ scannerProfilesLoading, siteProfilesLoading, isLoading }) => { ({ scannerProfilesLoading, siteProfilesLoading, isLoading }) => {
mountShallowSubject({ createShallowComponent({
mocks: { mocks: {
$apollo: { $apollo: {
queries: { queries: {
...@@ -228,14 +228,14 @@ describe('OnDemandScansForm', () => { ...@@ -228,14 +228,14 @@ describe('OnDemandScansForm', () => {
}, },
}); });
expect(subject.find(GlSkeletonLoader).exists()).toBe(isLoading); expect(wrapper.find(GlSkeletonLoader).exists()).toBe(isLoading);
}, },
); );
}); });
describe('when editing an existing scan', () => { describe('when editing an existing scan', () => {
beforeEach(() => { beforeEach(() => {
mountShallowSubject({ createShallowComponent({
propsData: { propsData: {
dastScan, dastScan,
}, },
...@@ -243,7 +243,7 @@ describe('OnDemandScansForm', () => { ...@@ -243,7 +243,7 @@ describe('OnDemandScansForm', () => {
}); });
it('sets the title properly', () => { it('sets the title properly', () => {
expect(subject.text()).toContain('Edit on-demand DAST scan'); expect(wrapper.text()).toContain('Edit on-demand DAST scan');
}); });
it('populates the fields with passed values', () => { it('populates the fields with passed values', () => {
...@@ -257,7 +257,7 @@ describe('OnDemandScansForm', () => { ...@@ -257,7 +257,7 @@ describe('OnDemandScansForm', () => {
describe('local storage', () => { describe('local storage', () => {
it('get updated when form is modified', async () => { it('get updated when form is modified', async () => {
mountShallowSubject(); createShallowComponent();
await setValidFormData(); await setValidFormData();
...@@ -285,8 +285,8 @@ describe('OnDemandScansForm', () => { ...@@ -285,8 +285,8 @@ describe('OnDemandScansForm', () => {
}), }),
); );
mountShallowSubject(); createShallowComponent();
await subject.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(findNameInput().attributes('value')).toBe(dastScan.name); expect(findNameInput().attributes('value')).toBe(dastScan.name);
expect(findDescriptionInput().attributes('value')).toBe(dastScan.description); expect(findDescriptionInput().attributes('value')).toBe(dastScan.description);
...@@ -299,7 +299,7 @@ describe('OnDemandScansForm', () => { ...@@ -299,7 +299,7 @@ describe('OnDemandScansForm', () => {
let submitButton; let submitButton;
beforeEach(() => { beforeEach(() => {
mountShallowSubject(); createShallowComponent();
submitButton = findSubmitButton(); submitButton = findSubmitButton();
}); });
...@@ -324,7 +324,7 @@ describe('OnDemandScansForm', () => { ...@@ -324,7 +324,7 @@ describe('OnDemandScansForm', () => {
({ actionFunction, submitButtonLoading, saveButtonLoading, runAfter, redirectPath }) => { ({ actionFunction, submitButtonLoading, saveButtonLoading, runAfter, redirectPath }) => {
describe('with valid form data', () => { describe('with valid form data', () => {
beforeEach(async () => { beforeEach(async () => {
mountShallowSubject(); createShallowComponent();
await setupSuccess(); await setupSuccess();
actionFunction(); actionFunction();
}); });
...@@ -344,7 +344,7 @@ describe('OnDemandScansForm', () => { ...@@ -344,7 +344,7 @@ describe('OnDemandScansForm', () => {
}); });
it(`triggers dastProfileCreateMutation mutation with runAfterCreate set to ${runAfter}`, () => { it(`triggers dastProfileCreateMutation mutation with runAfterCreate set to ${runAfter}`, () => {
expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({ expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
mutation: dastProfileCreateMutation, mutation: dastProfileCreateMutation,
variables: { variables: {
input: { input: {
...@@ -372,7 +372,7 @@ describe('OnDemandScansForm', () => { ...@@ -372,7 +372,7 @@ describe('OnDemandScansForm', () => {
describe('when editing an existing scan', () => { describe('when editing an existing scan', () => {
beforeEach(async () => { beforeEach(async () => {
mountShallowSubject({ createShallowComponent({
propsData: { propsData: {
dastScan, dastScan,
}, },
...@@ -382,7 +382,7 @@ describe('OnDemandScansForm', () => { ...@@ -382,7 +382,7 @@ describe('OnDemandScansForm', () => {
}); });
it(`triggers dastProfileUpdateMutation mutation with runAfterUpdate set to ${runAfter}`, async () => { it(`triggers dastProfileUpdateMutation mutation with runAfterUpdate set to ${runAfter}`, async () => {
expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({ expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
mutation: dastProfileUpdateMutation, mutation: dastProfileUpdateMutation,
variables: { variables: {
input: { input: {
...@@ -401,26 +401,26 @@ describe('OnDemandScansForm', () => { ...@@ -401,26 +401,26 @@ describe('OnDemandScansForm', () => {
}); });
it('does not run any mutation if name is empty', () => { it('does not run any mutation if name is empty', () => {
mountShallowSubject(); createShallowComponent();
setValidFormData(); setValidFormData();
findNameInput().vm.$emit('input', ''); findNameInput().vm.$emit('input', '');
actionFunction(); actionFunction();
expect(subject.vm.$apollo.mutate).not.toHaveBeenCalled(); expect(wrapper.vm.$apollo.mutate).not.toHaveBeenCalled();
}); });
}, },
); );
describe('on top-level error', () => { describe('on top-level error', () => {
beforeEach(async () => { beforeEach(async () => {
mountShallowSubject(); createShallowComponent();
subject.vm.$apollo.mutate.mockRejectedValue(); wrapper.vm.$apollo.mutate.mockRejectedValue();
await setValidFormData(); await setValidFormData();
submitForm(); submitForm();
}); });
it('resets loading state', () => { it('resets loading state', () => {
expect(subject.vm.loading).toBe(false); expect(wrapper.vm.loading).toBe(false);
}); });
it('shows an alert', () => { it('shows an alert', () => {
...@@ -434,8 +434,8 @@ describe('OnDemandScansForm', () => { ...@@ -434,8 +434,8 @@ describe('OnDemandScansForm', () => {
const errors = ['error#1', 'error#2', 'error#3']; const errors = ['error#1', 'error#2', 'error#3'];
beforeEach(async () => { beforeEach(async () => {
mountShallowSubject(); createShallowComponent();
subject.vm.$apollo.mutate.mockResolvedValue({ wrapper.vm.$apollo.mutate.mockResolvedValue({
data: { dastProfileCreate: { pipelineUrl: null, errors } }, data: { dastProfileCreate: { pipelineUrl: null, errors } },
}); });
await setValidFormData(); await setValidFormData();
...@@ -443,7 +443,7 @@ describe('OnDemandScansForm', () => { ...@@ -443,7 +443,7 @@ describe('OnDemandScansForm', () => {
}); });
it('resets loading state', () => { it('resets loading state', () => {
expect(subject.vm.loading).toBe(false); expect(wrapper.vm.loading).toBe(false);
}); });
it('shows an alert with the returned errors', () => { it('shows an alert with the returned errors', () => {
...@@ -459,7 +459,7 @@ describe('OnDemandScansForm', () => { ...@@ -459,7 +459,7 @@ describe('OnDemandScansForm', () => {
describe('cancellation', () => { describe('cancellation', () => {
beforeEach(() => { beforeEach(() => {
mountShallowSubject(); createShallowComponent();
findCancelButton().vm.$emit('click'); findCancelButton().vm.$emit('click');
}); });
...@@ -480,9 +480,9 @@ describe('OnDemandScansForm', () => { ...@@ -480,9 +480,9 @@ describe('OnDemandScansForm', () => {
'profiles conflict prevention', 'profiles conflict prevention',
({ description, selectedScannerProfile, selectedSiteProfile, hasConflict }) => { ({ description, selectedScannerProfile, selectedSiteProfile, hasConflict }) => {
const setFormData = () => { const setFormData = () => {
subject.find(ScannerProfileSelector).vm.$emit('input', selectedScannerProfile.id); wrapper.find(ScannerProfileSelector).vm.$emit('input', selectedScannerProfile.id);
subject.find(SiteProfileSelector).vm.$emit('input', selectedSiteProfile.id); wrapper.find(SiteProfileSelector).vm.$emit('input', selectedSiteProfile.id);
return subject.vm.$nextTick(); return wrapper.vm.$nextTick();
}; };
it( it(
...@@ -490,7 +490,7 @@ describe('OnDemandScansForm', () => { ...@@ -490,7 +490,7 @@ describe('OnDemandScansForm', () => {
? `warns about conflicting profiles when user selects ${description}` ? `warns about conflicting profiles when user selects ${description}`
: `does not report any conflict when user selects ${description}`, : `does not report any conflict when user selects ${description}`,
async () => { async () => {
mountShallowSubject(); createShallowComponent();
await setFormData(); await setFormData();
expect(findProfilesConflictAlert().exists()).toBe(hasConflict); expect(findProfilesConflictAlert().exists()).toBe(hasConflict);
...@@ -508,7 +508,7 @@ describe('OnDemandScansForm', () => { ...@@ -508,7 +508,7 @@ describe('OnDemandScansForm', () => {
const [profile] = profiles; const [profile] = profiles;
beforeEach(async () => { beforeEach(async () => {
mountShallowSubject( createShallowComponent(
{}, {},
{ {
[query]: jest.fn().mockResolvedValue(responses[query]([profile])), [query]: jest.fn().mockResolvedValue(responses[query]([profile])),
...@@ -519,13 +519,13 @@ describe('OnDemandScansForm', () => { ...@@ -519,13 +519,13 @@ describe('OnDemandScansForm', () => {
}); });
it('automatically selects the only available profile', () => { it('automatically selects the only available profile', () => {
expect(subject.find(selector).attributes('value')).toBe(profile.id); expect(wrapper.find(selector).attributes('value')).toBe(profile.id);
}); });
}); });
describe('scanner profile summary', () => { describe('scanner profile summary', () => {
beforeEach(() => { beforeEach(() => {
mountSubject({ createComponent({
provide: { provide: {
glFeatures: { glFeatures: {
securityDastSiteProfilesAdditionalFields: true, securityDastSiteProfilesAdditionalFields: true,
...@@ -545,7 +545,7 @@ describe('OnDemandScansForm', () => { ...@@ -545,7 +545,7 @@ describe('OnDemandScansForm', () => {
const [authEnabledProfile] = siteProfiles; const [authEnabledProfile] = siteProfiles;
beforeEach(() => { beforeEach(() => {
mountSubject({ createComponent({
provide: { provide: {
glFeatures: { glFeatures: {
securityDastSiteProfilesAdditionalFields: true, securityDastSiteProfilesAdditionalFields: true,
...@@ -556,7 +556,7 @@ describe('OnDemandScansForm', () => { ...@@ -556,7 +556,7 @@ describe('OnDemandScansForm', () => {
it('renders all fields correctly', async () => { it('renders all fields correctly', async () => {
await selectSiteProfile(authEnabledProfile); await selectSiteProfile(authEnabledProfile);
const summary = subject.find(SiteProfileSelector).text(); const summary = wrapper.find(SiteProfileSelector).text();
const defaultPassword = '••••••••'; const defaultPassword = '••••••••';
const defaultRequestHeaders = '[Redacted]'; const defaultRequestHeaders = '[Redacted]';
...@@ -585,28 +585,28 @@ describe('OnDemandScansForm', () => { ...@@ -585,28 +585,28 @@ describe('OnDemandScansForm', () => {
global.jsdom.reconfigure({ global.jsdom.reconfigure({
url: setUrlParams({ scanner_profile_id: 1 }, URL_HOST), url: setUrlParams({ scanner_profile_id: 1 }, URL_HOST),
}); });
mountShallowSubject(); createShallowComponent();
expect(subject.find(ScannerProfileSelector).attributes('value')).toBe(scannerProfile.id); expect(wrapper.find(ScannerProfileSelector).attributes('value')).toBe(scannerProfile.id);
}); });
it('site profile', () => { it('site profile', () => {
global.jsdom.reconfigure({ global.jsdom.reconfigure({
url: setUrlParams({ site_profile_id: 1 }, URL_HOST), url: setUrlParams({ site_profile_id: 1 }, URL_HOST),
}); });
mountShallowSubject(); createShallowComponent();
expect(subject.find(SiteProfileSelector).attributes('value')).toBe(siteProfile.id); expect(wrapper.find(SiteProfileSelector).attributes('value')).toBe(siteProfile.id);
}); });
it('both scanner & site profile', () => { it('both scanner & site profile', () => {
global.jsdom.reconfigure({ global.jsdom.reconfigure({
url: setUrlParams({ site_profile_id: 1, scanner_profile_id: 1 }, URL_HOST), url: setUrlParams({ site_profile_id: 1, scanner_profile_id: 1 }, URL_HOST),
}); });
mountShallowSubject(); createShallowComponent();
expect(subject.find(SiteProfileSelector).attributes('value')).toBe(siteProfile.id); expect(wrapper.find(SiteProfileSelector).attributes('value')).toBe(siteProfile.id);
expect(subject.find(ScannerProfileSelector).attributes('value')).toBe(scannerProfile.id); expect(wrapper.find(ScannerProfileSelector).attributes('value')).toBe(scannerProfile.id);
}); });
it('when local storage data is available', async () => { it('when local storage data is available', async () => {
...@@ -622,8 +622,8 @@ describe('OnDemandScansForm', () => { ...@@ -622,8 +622,8 @@ describe('OnDemandScansForm', () => {
url: setUrlParams({ site_profile_id: 1, scanner_profile_id: 1 }, URL_HOST), url: setUrlParams({ site_profile_id: 1, scanner_profile_id: 1 }, URL_HOST),
}); });
mountShallowSubject(); createShallowComponent();
await subject.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(findScannerProfilesSelector().attributes('value')).toBe(scannerProfile.id); expect(findScannerProfilesSelector().attributes('value')).toBe(scannerProfile.id);
expect(findSiteProfilesSelector().attributes('value')).toBe(siteProfile.id); expect(findSiteProfilesSelector().attributes('value')).toBe(siteProfile.id);
...@@ -632,7 +632,7 @@ describe('OnDemandScansForm', () => { ...@@ -632,7 +632,7 @@ describe('OnDemandScansForm', () => {
describe('when no repository exists', () => { describe('when no repository exists', () => {
beforeEach(() => { beforeEach(() => {
mountShallowSubject({ createShallowComponent({
propsData: { propsData: {
/** /**
* The assumption here is that, if a default branch is not defined, then the project * The assumption here is that, if a default branch is not defined, then the project
...@@ -644,7 +644,7 @@ describe('OnDemandScansForm', () => { ...@@ -644,7 +644,7 @@ describe('OnDemandScansForm', () => {
}); });
it('shows an error message', () => { it('shows an error message', () => {
expect(subject.text()).toContain( expect(wrapper.text()).toContain(
'You must create a repository within your project to run an on-demand scan.', 'You must create a repository within your project to run an on-demand scan.',
); );
}); });
...@@ -658,14 +658,14 @@ describe('OnDemandScansForm', () => { ...@@ -658,14 +658,14 @@ describe('OnDemandScansForm', () => {
`('on $action', ({ actionFunction, runAfter }) => { `('on $action', ({ actionFunction, runAfter }) => {
describe('when creating a new scan', () => { describe('when creating a new scan', () => {
beforeEach(async () => { beforeEach(async () => {
mountShallowSubject({ createShallowComponent({
provide: { provide: {
glFeatures: { glFeatures: {
dastBranchSelection: false, dastBranchSelection: false,
}, },
}, },
}); });
subject.vm.$apollo.mutate.mockResolvedValue({ wrapper.vm.$apollo.mutate.mockResolvedValue({
data: { data: {
dastProfileCreate: { dastProfileCreate: {
dastProfile: { editPath }, dastProfile: { editPath },
...@@ -677,12 +677,12 @@ describe('OnDemandScansForm', () => { ...@@ -677,12 +677,12 @@ describe('OnDemandScansForm', () => {
findNameInput().vm.$emit('input', 'My daily scan'); findNameInput().vm.$emit('input', 'My daily scan');
findScannerProfilesSelector().vm.$emit('input', passiveScannerProfile.id); findScannerProfilesSelector().vm.$emit('input', passiveScannerProfile.id);
findSiteProfilesSelector().vm.$emit('input', nonValidatedSiteProfile.id); findSiteProfilesSelector().vm.$emit('input', nonValidatedSiteProfile.id);
await subject.vm.$nextTick(); await wrapper.vm.$nextTick();
actionFunction(); actionFunction();
}); });
it(`triggers dastProfileCreateMutation mutation without the branch name and runAfterCreate set to ${runAfter}`, async () => { it(`triggers dastProfileCreateMutation mutation without the branch name and runAfterCreate set to ${runAfter}`, async () => {
expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({ expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
mutation: dastProfileCreateMutation, mutation: dastProfileCreateMutation,
variables: { variables: {
input: { input: {
...@@ -699,7 +699,7 @@ describe('OnDemandScansForm', () => { ...@@ -699,7 +699,7 @@ describe('OnDemandScansForm', () => {
describe('when editing an existing scan', () => { describe('when editing an existing scan', () => {
beforeEach(async () => { beforeEach(async () => {
mountShallowSubject({ createShallowComponent({
propsData: { propsData: {
dastScan, dastScan,
}, },
...@@ -709,7 +709,7 @@ describe('OnDemandScansForm', () => { ...@@ -709,7 +709,7 @@ describe('OnDemandScansForm', () => {
}, },
}, },
}); });
subject.vm.$apollo.mutate.mockResolvedValue({ wrapper.vm.$apollo.mutate.mockResolvedValue({
data: { data: {
dastProfileUpdate: { dastProfileUpdate: {
dastProfile: { editPath }, dastProfile: { editPath },
...@@ -721,12 +721,12 @@ describe('OnDemandScansForm', () => { ...@@ -721,12 +721,12 @@ describe('OnDemandScansForm', () => {
findNameInput().vm.$emit('input', 'My daily scan'); findNameInput().vm.$emit('input', 'My daily scan');
findScannerProfilesSelector().vm.$emit('input', passiveScannerProfile.id); findScannerProfilesSelector().vm.$emit('input', passiveScannerProfile.id);
findSiteProfilesSelector().vm.$emit('input', nonValidatedSiteProfile.id); findSiteProfilesSelector().vm.$emit('input', nonValidatedSiteProfile.id);
await subject.vm.$nextTick(); await wrapper.vm.$nextTick();
actionFunction(); actionFunction();
}); });
it(`triggers dastProfileUpdateMutation mutation without the branch name and runAfterUpdate set to ${runAfter}`, async () => { it(`triggers dastProfileUpdateMutation mutation without the branch name and runAfterUpdate set to ${runAfter}`, async () => {
expect(subject.vm.$apollo.mutate).toHaveBeenCalledWith({ expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
mutation: dastProfileUpdateMutation, mutation: dastProfileUpdateMutation,
variables: { variables: {
input: { input: {
......
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