Commit 0d8887b2 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch '281833-remove-dast-ondemand-landing' into 'master'

Removed DAST On-demand landing page

See merge request gitlab-org/gitlab!47867
parents eb6eb2bc 25058602
<script>
import OnDemandScansForm from './on_demand_scans_form.vue';
import OnDemandScansEmptyState from './on_demand_scans_empty_state.vue';
export default {
name: 'OnDemandScansApp',
components: {
OnDemandScansForm,
OnDemandScansEmptyState,
},
props: {
helpPagePath: {
......@@ -36,19 +34,10 @@ export default {
<template>
<div>
<template v-if="showForm">
<on-demand-scans-form
:help-page-path="helpPagePath"
:project-path="projectPath"
:default-branch="defaultBranch"
@cancel="showForm = false"
/>
</template>
<on-demand-scans-empty-state
v-else
<on-demand-scans-form
:help-page-path="helpPagePath"
:empty-state-svg-path="emptyStateSvgPath"
@createNewScan="showForm = true"
:project-path="projectPath"
:default-branch="defaultBranch"
/>
</div>
</template>
<script>
import { GlButton, GlEmptyState, GlLink, GlSprintf } from '@gitlab/ui';
export default {
name: 'OnDemandScansEmptyState',
components: {
GlButton,
GlEmptyState,
GlLink,
GlSprintf,
},
props: {
helpPagePath: {
type: String,
required: true,
},
emptyStateSvgPath: {
type: String,
required: true,
},
},
};
</script>
<template>
<div>
<gl-empty-state :svg-path="emptyStateSvgPath" :title="s__('OnDemandScans|On-demand Scans')">
<template #description>
<gl-sprintf
:message="
s__(
'OnDemandScans|Schedule or run scans immediately against target sites. Currently available on-demand scan type: DAST. %{helpLinkStart}More information%{helpLinkEnd}',
)
"
>
<template #helpLink="{ content }">
<gl-link :href="helpPagePath">
{{ content }}
</gl-link>
</template>
</gl-sprintf>
</template>
<template #actions>
<gl-button data-testid="run-scan-button" variant="success" @click="$emit('createNewScan')">
{{ s__('OnDemandScans|Create new DAST scan') }}
</gl-button>
</template>
</gl-empty-state>
</div>
</template>
......@@ -230,9 +230,6 @@ export default {
>
{{ s__('OnDemandScans|Run scan') }}
</gl-button>
<gl-button data-testid="on-demand-scan-cancel-button" @click="$emit('cancel')">
{{ __('Cancel') }}
</gl-button>
</div>
</template>
</gl-form>
......
---
title: Removed On-demand landing page
merge_request: 47867
author:
type: changed
import { shallowMount } from '@vue/test-utils';
import { merge } from 'lodash';
import OnDemandScansApp from 'ee/on_demand_scans/components/on_demand_scans_app.vue';
import OnDemandScansEmptyState from 'ee/on_demand_scans/components/on_demand_scans_empty_state.vue';
import OnDemandScansForm from 'ee/on_demand_scans/components/on_demand_scans_form.vue';
import { TEST_HOST } from 'helpers/test_constants';
......@@ -14,17 +13,10 @@ const newSiteProfilePath = `${TEST_HOST}/${projectPath}/-/security/configuration
describe('OnDemandScansApp', () => {
let wrapper;
const findOnDemandScansEmptyState = () => wrapper.find(OnDemandScansEmptyState);
const findOnDemandScansForm = () => wrapper.find(OnDemandScansForm);
const expectEmptyState = () => {
expect(wrapper.find(OnDemandScansForm).exists()).toBe(false);
expect(wrapper.find(OnDemandScansEmptyState).exists()).toBe(true);
};
const expectForm = () => {
expect(wrapper.find(OnDemandScansForm).exists()).toBe(true);
expect(wrapper.find(OnDemandScansEmptyState).exists()).toBe(false);
};
const createComponent = options => {
......@@ -55,26 +47,8 @@ describe('OnDemandScansApp', () => {
wrapper = null;
});
describe('empty state', () => {
it('renders an empty state by default', () => {
expectEmptyState();
});
it('passes correct props to GlEmptyState', () => {
expect(findOnDemandScansEmptyState().props()).toMatchObject({
emptyStateSvgPath,
helpPagePath,
});
});
});
describe('form', () => {
beforeEach(async () => {
findOnDemandScansEmptyState().vm.$emit('createNewScan');
await wrapper.vm.$nextTick();
});
it('renders the form when clicking on the primary button', () => {
it('renders the form', () => {
expectForm();
});
......@@ -85,12 +59,5 @@ describe('OnDemandScansApp', () => {
defaultBranch,
});
});
it('shows the empty state on cancel', async () => {
findOnDemandScansForm().vm.$emit('cancel');
await wrapper.vm.$nextTick();
expectEmptyState();
});
});
});
......@@ -47,7 +47,6 @@ describe('OnDemandScansForm', () => {
const findByTestId = testId => subject.find(`[data-testid="${testId}"]`);
const findAlert = () => findByTestId('on-demand-scan-error');
const findSubmitButton = () => findByTestId('on-demand-scan-submit-button');
const findCancelButton = () => findByTestId('on-demand-scan-cancel-button');
const setFormData = () => {
subject.find(OnDemandScansScannerProfileSelector).vm.$emit('input', scannerProfiles[0].id);
......@@ -227,14 +226,4 @@ describe('OnDemandScansForm', () => {
});
});
});
describe('cancel', () => {
it('emits cancel event on click', () => {
mountShallowSubject();
jest.spyOn(subject.vm, '$emit');
findCancelButton().vm.$emit('click');
expect(subject.vm.$emit).toHaveBeenCalledWith('cancel');
});
});
});
import { GlEmptyState, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import OnDemandScansEmptyState from 'ee/on_demand_scans/components/on_demand_scans_empty_state.vue';
import { TEST_HOST } from 'helpers/test_constants';
const helpPagePath = `${TEST_HOST}/application_security/dast/index#on-demand-scans`;
const emptyStateSvgPath = `${TEST_HOST}/assets/illustrations/alert-management-empty-state.svg`;
const GlEmptyStateStub = {
props: GlEmptyState.props,
template: `
<div>
<slot name="description" />
<slot name="actions" />
</div>
`,
};
describe('OnDemandScansEmptyState', () => {
let wrapper;
const findEmptyState = () => wrapper.find(GlEmptyStateStub);
const findRunScanButton = () => wrapper.find('[data-testid="run-scan-button"]');
const createComponent = (props = {}) => {
wrapper = shallowMount(OnDemandScansEmptyState, {
propsData: {
helpPagePath,
emptyStateSvgPath,
...props,
},
stubs: {
GlEmptyState: GlEmptyStateStub,
GlSprintf,
GlButton: { template: '<button><slot /></button>' },
},
});
};
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('renders empty state', () => {
expect(wrapper.find(GlEmptyStateStub).exists()).toBe(true);
});
it('passes correct props to GlEmptyState', () => {
expect(findEmptyState().props()).toMatchObject({
svgPath: emptyStateSvgPath,
title: 'On-demand Scans',
});
});
it('renders the description', () => {
expect(wrapper.text()).toContain(
'Schedule or run scans immediately against target sites. Currently available on-demand scan type: DAST.',
);
expect(wrapper.text()).toContain('More information');
});
it('renders the run scan button', () => {
const button = findRunScanButton();
expect(button.exists()).toBe(true);
expect(button.text()).toBe('Create new DAST scan');
});
it('clicking on the run scan button emits createNewScan event', () => {
findRunScanButton().vm.$emit('click');
expect(wrapper.emitted().createNewScan).toBeTruthy();
});
});
......@@ -18913,9 +18913,6 @@ msgstr ""
msgid "OnDemandScans|Create a new site profile"
msgstr ""
msgid "OnDemandScans|Create new DAST scan"
msgstr ""
msgid "OnDemandScans|Manage profiles"
msgstr ""
......@@ -18940,9 +18937,6 @@ msgstr ""
msgid "OnDemandScans|Scanner profile"
msgstr ""
msgid "OnDemandScans|Schedule or run scans immediately against target sites. Currently available on-demand scan type: DAST. %{helpLinkStart}More information%{helpLinkEnd}"
msgstr ""
msgid "OnDemandScans|Select one of the existing profiles"
msgstr ""
......
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