Commit be19cd2c authored by Dheeraj Joshi's avatar Dheeraj Joshi Committed by Kushal Pandya

Fix DAST profile summary for an edge case

This handles the case when profile id are
not present in received profiles
parent a844a63a
...@@ -116,7 +116,7 @@ export default { ...@@ -116,7 +116,7 @@ export default {
</gl-dropdown> </gl-dropdown>
<div <div
v-if="value && $scopedSlots.summary" v-if="selectedProfile && $scopedSlots.summary"
data-testid="selected-profile-summary" data-testid="selected-profile-summary"
class="gl-mt-6 gl-pt-6 gl-border-t-solid gl-border-gray-100 gl-border-t-1" class="gl-mt-6 gl-pt-6 gl-border-t-solid gl-border-gray-100 gl-border-t-1"
> >
......
---
title: Fix DAST profiles summary for invalid profile ids
merge_request: 56753
author:
type: fixed
...@@ -82,6 +82,7 @@ describe('OnDemandScansForm', () => { ...@@ -82,6 +82,7 @@ describe('OnDemandScansForm', () => {
const findSubmitButton = () => findByTestId('on-demand-scan-submit-button'); const findSubmitButton = () => findByTestId('on-demand-scan-submit-button');
const findSaveButton = () => findByTestId('on-demand-scan-save-button'); const findSaveButton = () => findByTestId('on-demand-scan-save-button');
const findCancelButton = () => findByTestId('on-demand-scan-cancel-button'); const findCancelButton = () => findByTestId('on-demand-scan-cancel-button');
const findProfileSummary = () => findByTestId('selected-profile-summary');
const setValidFormData = () => { const setValidFormData = () => {
findNameInput().vm.$emit('input', 'My daily scan'); findNameInput().vm.$emit('input', 'My daily scan');
...@@ -102,6 +103,12 @@ describe('OnDemandScansForm', () => { ...@@ -102,6 +103,12 @@ describe('OnDemandScansForm', () => {
}); });
return setValidFormData(); return setValidFormData();
}; };
const selectProfile = (component) => async (profile) => {
subject.find(component).vm.$emit('input', profile.id);
await subject.vm.$nextTick();
};
const selectScannerProfile = selectProfile(ScannerProfileSelector);
const selectSiteProfile = selectProfile(SiteProfileSelector);
const submitForm = () => findForm().vm.$emit('submit', { preventDefault: () => {} }); const submitForm = () => findForm().vm.$emit('submit', { preventDefault: () => {} });
const saveScan = () => findSaveButton().vm.$emit('click'); const saveScan = () => findSaveButton().vm.$emit('click');
...@@ -515,14 +522,27 @@ describe('OnDemandScansForm', () => { ...@@ -515,14 +522,27 @@ describe('OnDemandScansForm', () => {
}); });
}); });
describe('scanner profile summary', () => {
beforeEach(() => {
mountSubject({
provide: {
glFeatures: {
securityDastSiteProfilesAdditionalFields: true,
},
},
});
});
it('does not render the summary provided an invalid profile ID', async () => {
await selectScannerProfile({ id: 'gid://gitlab/DastScannerProfile/123' });
expect(findProfileSummary().exists()).toBe(false);
});
});
describe('site profile summary', () => { describe('site profile summary', () => {
const [authEnabledProfile] = siteProfiles; const [authEnabledProfile] = siteProfiles;
const selectSiteProfile = async (profile) => {
subject.find(SiteProfileSelector).vm.$emit('input', profile.id);
await subject.vm.$nextTick();
};
beforeEach(() => { beforeEach(() => {
mountSubject({ mountSubject({
provide: { provide: {
...@@ -548,6 +568,12 @@ describe('OnDemandScansForm', () => { ...@@ -548,6 +568,12 @@ describe('OnDemandScansForm', () => {
expect(summary).toMatch(defaultPassword); expect(summary).toMatch(defaultPassword);
expect(summary).toMatch(defaultRequestHeaders); expect(summary).toMatch(defaultRequestHeaders);
}); });
it('does not render the summary provided an invalid profile ID', async () => {
await selectSiteProfile({ id: 'gid://gitlab/DastSiteProfile/123' });
expect(findProfileSummary().exists()).toBe(false);
});
}); });
describe('populate profiles from query params', () => { describe('populate profiles from query params', () => {
......
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