Commit 128aaba1 authored by Dheeraj Joshi's avatar Dheeraj Joshi

Add feature specs for DAST Scanner Profile

This adds feature specs to cover related to DAST
Scanner Profile Form
parent 2d6d8702
...@@ -278,6 +278,7 @@ export default { ...@@ -278,6 +278,7 @@ export default {
<gl-form-group :label="s__('DastProfiles|Profile name')"> <gl-form-group :label="s__('DastProfiles|Profile name')">
<gl-form-input <gl-form-input
v-model="form.profileName.value" v-model="form.profileName.value"
name="profile_name"
class="mw-460" class="mw-460"
data-testid="profile-name-input" data-testid="profile-name-input"
type="text" type="text"
...@@ -311,6 +312,7 @@ export default { ...@@ -311,6 +312,7 @@ export default {
</template> </template>
<gl-form-input-group <gl-form-input-group
v-model.number="form.spiderTimeout.value" v-model.number="form.spiderTimeout.value"
name="spider_timeout"
class="mw-460" class="mw-460"
data-testid="spider-timeout-input" data-testid="spider-timeout-input"
type="number" type="number"
...@@ -338,6 +340,7 @@ export default { ...@@ -338,6 +340,7 @@ export default {
</template> </template>
<gl-form-input-group <gl-form-input-group
v-model.number="form.targetTimeout.value" v-model.number="form.targetTimeout.value"
name="target_timeout"
class="mw-460" class="mw-460"
data-testid="target-timeout-input" data-testid="target-timeout-input"
type="number" type="number"
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User sees Scanner profile' do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository) }
let(:profile_form_path) {new_project_security_configuration_dast_scans_dast_scanner_profile_path(project)}
let(:profile_library_path) { project_security_configuration_dast_scans_path(project) }
before_all do
project.add_developer(user)
end
before do
sign_in(user)
end
context 'when feature is available' do
before do
stub_licensed_features(security_on_demand_scans: true)
visit(profile_form_path)
end
it 'shows the form' do
expect(page).to have_gitlab_http_status(:ok)
expect(page).to have_content("New scanner profile")
end
it 'on submit', :js do
fill_in_profile_form
expect(current_path).to eq(profile_library_path)
end
it 'on cancel', :js do
click_button 'Cancel'
expect(current_path).to eq(profile_library_path)
end
end
context 'when feature is not available' do
before do
visit(profile_form_path)
end
it 'renders a 404' do
expect(page).to have_gitlab_http_status(:not_found)
end
end
def fill_in_profile_form
fill_in 'profile_name', with: "hello"
fill_in 'spider_timeout', with: "1"
fill_in 'target_timeout', with: "2"
click_button 'Save profile'
wait_for_requests
end
end
import { screen, within } from '@testing-library/dom';
import initBundler from 'ee/security_configuration/dast_scanner_profiles/dast_scanner_profiles_bundle';
import { waitForText } from 'helpers/wait_for_text';
import { mockIssueLink } from '../test_helpers/mock_data/vulnerabilities_mock_data';
// import { mockVulnerability } from './mock_data';
describe('Scanner Profile', () => {
let vm;
let container;
const createComponent = () => {
setFixtures('<div class="js-dast-scanner-profile-form"></div>');
const el = document.querySelector('.js-dast-scanner-profile-form');
const elDataSet = {
profilesLibraryPath: 'group/project',
projectFullPath: '/security/configuration/a',
onDemandScansPath: '/security/configuration/b',
};
Object.assign(el.dataset, {
...elDataSet,
});
container.appendChild(el);
return initBundler(el);
};
beforeEach(() => {
vm = createComponent();
});
afterEach(() => {
vm.$destroy();
vm = null;
container = null;
});
it("displays the vulnerability's status", () => {
const headerBody = screen.getByTestId('vulnerability-detail-body');
expect(within(headerBody).getByText(mockVulnerability.state)).toBeInstanceOf(HTMLElement);
});
it("displays the vulnerability's severity", () => {
const severitySection = screen.getByTestId('severity');
const severityValue = within(severitySection).getByTestId('value');
expect(severityValue.textContent.toLowerCase()).toContain(
mockVulnerability.severity.toLowerCase(),
);
});
it("displays a heading containing the vulnerability's title", () => {
expect(screen.getByRole('heading', { name: mockVulnerability.title })).toBeInstanceOf(
HTMLElement,
);
});
it("displays the vulnerability's description", () => {
expect(screen.getByText(mockVulnerability.description)).toBeInstanceOf(HTMLElement);
});
it('displays related issues', async () => {
const relatedIssueTitle = await waitForText(mockIssueLink.title);
expect(relatedIssueTitle).toBeInstanceOf(HTMLElement);
});
});
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