Fix broken specs

Previous changes broke some specs because of a scoped slot becoming a
simple named slot, and the v-model now expecting a profile's ID rather
than the full profile object.
parent b9ba8cea
......@@ -52,8 +52,8 @@ describe('OnDemandScansForm', () => {
const findSubmitButton = () => findByTestId('on-demand-scan-submit-button');
const setValidFormData = () => {
subject.find(ScannerProfileSelector).vm.$emit('input', passiveScannerProfile);
subject.find(SiteProfileSelector).vm.$emit('input', nonValidatedSiteProfile);
subject.find(ScannerProfileSelector).vm.$emit('input', passiveScannerProfile.id);
subject.find(SiteProfileSelector).vm.$emit('input', nonValidatedSiteProfile.id);
return subject.vm.$nextTick();
};
const submitForm = () => findForm().vm.$emit('submit', { preventDefault: () => {} });
......@@ -243,8 +243,8 @@ describe('OnDemandScansForm', () => {
'profiles conflict prevention',
({ description, selectedScannerProfile, selectedSiteProfile, hasConflict }) => {
const setFormData = () => {
subject.find(ScannerProfileSelector).vm.$emit('input', selectedScannerProfile);
subject.find(SiteProfileSelector).vm.$emit('input', selectedSiteProfile);
subject.find(ScannerProfileSelector).vm.$emit('input', selectedScannerProfile.id);
subject.find(SiteProfileSelector).vm.$emit('input', selectedSiteProfile.id);
return subject.vm.$nextTick();
};
......@@ -253,7 +253,12 @@ describe('OnDemandScansForm', () => {
? `warns about conflicting profiles when user selects ${description}`
: `does not report any conflict when user selects ${description}`,
async () => {
mountShallowSubject();
mountShallowSubject({
data: {
scannerProfiles,
siteProfiles,
},
});
await setFormData();
expect(findProfilesConflictAlert().exists()).toBe(hasConflict);
......@@ -269,6 +274,10 @@ describe('OnDemandScansForm', () => {
securityOnDemandScansSiteValidation: false,
},
},
data: {
scannerProfiles,
siteProfiles,
},
});
return setFormData();
});
......
......@@ -4,7 +4,7 @@ exports[`OnDemandScansScannerProfileSelector renders properly with profiles 1`]
<div
class="gl-card"
data-foo="bar"
value="[object Object]"
value="gid://gitlab/DastScannerProfile/1"
>
<div
class="gl-card-header"
......
......@@ -4,7 +4,7 @@ exports[`OnDemandScansSiteProfileSelector renders properly with profiles 1`] = `
<div
class="gl-card"
data-foo="bar"
value="[object Object]"
value="gid://gitlab/DastSiteProfile/1"
>
<div
class="gl-card-header"
......
......@@ -41,12 +41,10 @@ describe('OnDemandScansProfileSelector', () => {
slots: {
title: 'Section title',
label: 'Use existing scanner profile',
summary: `<div>Profile's summary</div>`,
'no-profiles': 'No profile yet',
'new-profile': 'Create a new profile',
},
scopedSlots: {
summary: "<div>{{ props.profile.profileName }}'s summary</div>",
},
},
options,
),
......@@ -105,7 +103,7 @@ describe('OnDemandScansProfileSelector', () => {
it('when a profile is selected, input event is emitted', async () => {
await selectFirstProfile();
expect(wrapper.emitted('input')).toEqual([[scannerProfiles[0]]]);
expect(wrapper.emitted('input')).toEqual([[scannerProfiles[0].id]]);
});
it('shows dropdown items for each profile', () => {
......@@ -130,7 +128,7 @@ describe('OnDemandScansProfileSelector', () => {
createFullComponent({
propsData: {
profiles: scannerProfiles,
value: selectedProfile,
value: selectedProfile.id,
},
});
});
......@@ -139,7 +137,7 @@ describe('OnDemandScansProfileSelector', () => {
const summary = findSelectedProfileSummary();
expect(summary.exists()).toBe(true);
expect(summary.text()).toContain(`${scannerProfiles[0].profileName}'s summary`);
expect(summary.text()).toContain(`Profile's summary`);
});
it('displays item as checked', () => {
......
......@@ -31,8 +31,8 @@ describe('OnDemandScansScannerProfileSelector', () => {
newScannerProfilePath: TEST_NEW_PATH,
glFeatures: { securityOnDemandScansSiteValidation: true },
},
scopedSlots: {
summary: '<div slot-scope="{ profile }">{{ profile.profileName }}\'s summary</div>',
slots: {
summary: `<div>${profiles[0].profileName}'s summary</div>`,
},
},
options,
......@@ -50,7 +50,7 @@ describe('OnDemandScansScannerProfileSelector', () => {
it('renders properly with profiles', () => {
createFullComponent({
propsData: { profiles, value: profiles[0] },
propsData: { profiles, value: profiles[0].id },
});
expect(wrapper.element).toMatchSnapshot();
......
......@@ -34,8 +34,8 @@ describe('OnDemandScansSiteProfileSelector', () => {
newSiteProfilePath: TEST_NEW_PATH,
glFeatures: { securityOnDemandScansSiteValidation: true },
},
scopedSlots: {
summary: '<div slot-scope="{ profile }">{{ profile.profileName }}\'s summary</div>',
slots: {
summary: `<div>${profiles[0].profileName}'s summary</div>`,
},
},
options,
......@@ -53,7 +53,7 @@ describe('OnDemandScansSiteProfileSelector', () => {
it('renders properly with profiles', () => {
createFullComponent({
propsData: { profiles, value: profiles[0] },
propsData: { profiles, value: profiles[0].id },
});
expect(wrapper.element).toMatchSnapshot();
......
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