diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-10 00:10:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-10 00:10:00 +0300 |
commit | e1b5604609766f635f5029382ea018c612aa3186 (patch) | |
tree | fff466ae7fdf9edf47f84f539995292909ce8f94 /spec/features/incidents | |
parent | efcaec8a140e2b93d1f43d5afd7a5c35cdd4dad7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/incidents')
-rw-r--r-- | spec/features/incidents/user_creates_new_incident_spec.rb | 55 | ||||
-rw-r--r-- | spec/features/incidents/user_views_incident_spec.rb | 28 |
2 files changed, 49 insertions, 34 deletions
diff --git a/spec/features/incidents/user_creates_new_incident_spec.rb b/spec/features/incidents/user_creates_new_incident_spec.rb index 99a137b5852..685f6ab791a 100644 --- a/spec/features/incidents/user_creates_new_incident_spec.rb +++ b/spec/features/incidents/user_creates_new_incident_spec.rb @@ -4,52 +4,49 @@ require 'spec_helper' RSpec.describe 'Incident Management index', :js do let_it_be(:project) { create(:project) } - let_it_be(:developer) { create(:user) } + let_it_be(:reporter) { create(:user) } let_it_be(:guest) { create(:user) } let_it_be(:incident) { create(:incident, project: project) } before_all do - project.add_developer(developer) + project.add_reporter(reporter) project.add_guest(guest) end - shared_examples 'create incident form' do - it 'shows the create new issue button' do - expect(page).to have_selector('.create-incident-button') - end + before do + sign_in(user) - it 'when clicked shows the create issue page with the Incident type pre-selected' do - find('.create-incident-button').click - wait_for_all_requests + visit project_incidents_path(project) + wait_for_all_requests + end - expect(page).to have_selector('.dropdown-menu-toggle') - expect(page).to have_selector('.js-issuable-type-filter-dropdown-wrap') + describe 'incident list is visited' do + context 'by reporter' do + let(:user) { reporter } - page.within('.js-issuable-type-filter-dropdown-wrap') do - expect(page).to have_content('Incident') + it 'shows the create new incident button' do + expect(page).to have_selector('.create-incident-button') end - end - end - context 'when a developer displays the incident list' do - before do - sign_in(developer) + it 'when clicked shows the create issue page with the Incident type pre-selected' do + find('.create-incident-button').click + wait_for_all_requests - visit project_incidents_path(project) - wait_for_all_requests - end + expect(page).to have_selector('.dropdown-menu-toggle') + expect(page).to have_selector('.js-issuable-type-filter-dropdown-wrap') - it_behaves_like 'create incident form' + page.within('.js-issuable-type-filter-dropdown-wrap') do + expect(page).to have_content('Incident') + end + end + end end - context 'when a guest displays the incident list' do - before do - sign_in(guest) + context 'by guest' do + let(:user) { guest } - visit project_incidents_path(project) - wait_for_all_requests + it 'does not show new incident button' do + expect(page).not_to have_selector('.create-incident-button') end - - it_behaves_like 'create incident form' end end diff --git a/spec/features/incidents/user_views_incident_spec.rb b/spec/features/incidents/user_views_incident_spec.rb index 244b66f7a9a..fe54f7708c9 100644 --- a/spec/features/incidents/user_views_incident_spec.rb +++ b/spec/features/incidents/user_views_incident_spec.rb @@ -22,12 +22,30 @@ RSpec.describe "User views incident" do it_behaves_like 'page meta description', ' Description header Lorem ipsum dolor sit amet' - it 'shows the merge request and incident actions', :js, :aggregate_failures do - click_button 'Incident actions' + describe 'user actions' do + it 'shows the merge request and incident actions', :js, :aggregate_failures do + click_button 'Incident actions' - expect(page).to have_link('New incident', href: new_project_issue_path(project, { issuable_template: 'incident', issue: { issue_type: 'incident', description: "Related to \##{incident.iid}.\n\n" } })) - expect(page).to have_button('Create merge request') - expect(page).to have_button('Close incident') + expect(page).to have_link('New incident', href: new_project_issue_path(project, { issuable_template: 'incident', issue: { issue_type: 'incident', description: "Related to \##{incident.iid}.\n\n" } })) + expect(page).to have_button('Create merge request') + expect(page).to have_button('Close incident') + end + + context 'when user is a guest' do + before do + project.add_guest(user) + + login_as(user) + + visit(project_issues_incident_path(project, incident)) + end + + it 'does not show the incident action', :js, :aggregate_failures do + click_button 'Incident actions' + + expect(page).not_to have_link('New incident') + end + end end context 'when the project is archived' do |