Commit d08508b9 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'add_test_cases_for_first_class_vulnerabilities_ff' into 'master'

Add test case for `first_class_vulnerabilities` feature flag

Closes #213802

See merge request gitlab-org/gitlab!29278
parents 4340fc4c d464f9e2
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
require 'spec_helper' require 'spec_helper'
describe 'Group overview', :js do describe 'Group overview', :js, :aggregate_failures do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:empty_project) { create(:project, namespace: group) } let(:empty_project) { create(:project, namespace: group) }
subject(:visit_page) { visit group_path(group) }
before do before do
stub_feature_flags(first_class_vulnerabilities: false) stub_feature_flags(first_class_vulnerabilities: false)
group.add_owner(user) group.add_owner(user)
...@@ -15,7 +17,7 @@ describe 'Group overview', :js do ...@@ -15,7 +17,7 @@ describe 'Group overview', :js do
context 'when the default value of "Group Overview content" preference is used' do context 'when the default value of "Group Overview content" preference is used' do
it 'displays the Details view' do it 'displays the Details view' do
visit group_path(group) visit_page
page.within(find('.content')) do page.within(find('.content')) do
expect(page).to have_content 'Subgroups and projects' expect(page).to have_content 'Subgroups and projects'
...@@ -35,19 +37,45 @@ describe 'Group overview', :js do ...@@ -35,19 +37,45 @@ describe 'Group overview', :js do
context 'and Security Dashboard feature is available for a group' do context 'and Security Dashboard feature is available for a group' do
let(:group) { create(:group_with_plan, plan: :gold_plan) } let(:group) { create(:group_with_plan, plan: :gold_plan) }
let(:project) { create(:project, :public, namespace: group) }
before do
create(:vulnerability, :with_findings, project: project)
end
context 'when the "first_class_vulnerabilities" feature flag is not enabled' do
it 'displays the Security Dashboard view' do
visit_page
expect(page).to have_selector('.js-security-dashboard-table')
it 'displays the Security Dashboard view' do page.within(find('aside')) do
visit group_path(group) expect(page).to have_content 'Vulnerabilities over time'
expect(page).to have_selector('.js-vulnerabilities-chart-time-info')
expect(page).to have_selector('.js-vulnerabilities-chart-severity-level-breakdown')
expect(page).to have_selector('.js-security-dashboard-table') expect(page).to have_content 'Project security status'
expect(page).to have_selector('.js-projects-security-status')
end
page.within(all('div.row')[1]) do
expect(page).not_to have_content 'Detected'
end
end
end
context 'when the "first_class_vulnerabilities" feature flag is enabled' do
before do
stub_feature_flags(first_class_vulnerabilities: true)
end
page.within(find('aside')) do it 'loads the first class group security dashboard' do
expect(page).to have_content 'Vulnerabilities over time' visit_page
expect(page).to have_selector('.js-vulnerabilities-chart-time-info')
expect(page).to have_selector('.js-vulnerabilities-chart-severity-level-breakdown')
expect(page).to have_content 'Project security status' page.within(all('div.row')[1]) do
expect(page).to have_selector('.js-projects-security-status') expect(page).to have_content 'Detected'
expect(page).to have_content 'Severity'
end
end end
end end
end end
...@@ -56,7 +84,7 @@ describe 'Group overview', :js do ...@@ -56,7 +84,7 @@ describe 'Group overview', :js do
let(:group) { create(:group_with_plan, plan: :bronze_plan) } let(:group) { create(:group_with_plan, plan: :bronze_plan) }
it 'displays the "Security Dashboard unavailable" empty state' do it 'displays the "Security Dashboard unavailable" empty state' do
visit group_path(group) visit_page
page.within(find('.content')) do page.within(find('.content')) do
expect(page).to have_content "Either you don't have permission to view this dashboard or "\ expect(page).to have_content "Either you don't have permission to view this dashboard or "\
......
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