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