2020-10-12 18:08:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Incident Management index', :js do
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:developer) { create(:user) }
|
2020-10-20 09:08:43 +00:00
|
|
|
let_it_be(:guest) { create(:user) }
|
2020-10-12 18:08:31 +00:00
|
|
|
let_it_be(:incident) { create(:incident, project: project) }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_developer(developer)
|
2020-10-20 09:08:43 +00:00
|
|
|
project.add_guest(guest)
|
2020-10-12 18:08:31 +00:00
|
|
|
end
|
|
|
|
|
2020-10-20 09:08:43 +00:00
|
|
|
shared_examples 'create incident form' do
|
2020-10-12 18:08:31 +00:00
|
|
|
it 'shows the create new issue button' do
|
|
|
|
expect(page).to have_selector('.create-incident-button')
|
|
|
|
end
|
|
|
|
|
2020-10-20 09:08:43 +00:00
|
|
|
it 'when clicked shows the create issue page with the Incident type pre-selected' do
|
2020-10-12 18:08:31 +00:00
|
|
|
find('.create-incident-button').click
|
2020-10-20 09:08:43 +00:00
|
|
|
wait_for_all_requests
|
2020-10-12 18:08:31 +00:00
|
|
|
|
2020-10-20 09:08:43 +00:00
|
|
|
expect(page).to have_selector('.dropdown-menu-toggle')
|
|
|
|
expect(page).to have_selector('.js-issuable-type-filter-dropdown-wrap')
|
2020-10-12 18:08:31 +00:00
|
|
|
|
|
|
|
page.within('.js-issuable-type-filter-dropdown-wrap') do
|
|
|
|
expect(page).to have_content('Incident')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-10-20 09:08:43 +00:00
|
|
|
|
|
|
|
context 'when a developer displays the incident list' do
|
|
|
|
before do
|
|
|
|
sign_in(developer)
|
|
|
|
|
|
|
|
visit project_incidents_path(project)
|
|
|
|
wait_for_all_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'create incident form'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a guest displays the incident list' do
|
|
|
|
before do
|
|
|
|
sign_in(guest)
|
|
|
|
|
|
|
|
visit project_incidents_path(project)
|
|
|
|
wait_for_all_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'create incident form'
|
|
|
|
end
|
2020-10-12 18:08:31 +00:00
|
|
|
end
|