2020-10-12 14:08:31 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Incident Management index', :js do
|
|
|
|
let_it_be(:project) { create(:project) }
|
2021-11-09 16:10:00 -05:00
|
|
|
let_it_be(:reporter) { create(:user) }
|
2020-10-20 05:08:43 -04:00
|
|
|
let_it_be(:guest) { create(:user) }
|
2020-10-12 14:08:31 -04:00
|
|
|
let_it_be(:incident) { create(:incident, project: project) }
|
|
|
|
|
|
|
|
before_all do
|
2021-11-09 16:10:00 -05:00
|
|
|
project.add_reporter(reporter)
|
2020-10-20 05:08:43 -04:00
|
|
|
project.add_guest(guest)
|
2020-10-12 14:08:31 -04:00
|
|
|
end
|
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
2020-10-12 14:08:31 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
visit project_incidents_path(project)
|
|
|
|
wait_for_all_requests
|
|
|
|
end
|
2020-10-12 14:08:31 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
describe 'incident list is visited' do
|
|
|
|
context 'by reporter' do
|
|
|
|
let(:user) { reporter }
|
2020-10-12 14:08:31 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
it 'shows the create new incident button' do
|
|
|
|
expect(page).to have_selector('.create-incident-button')
|
2020-10-12 14:08:31 -04:00
|
|
|
end
|
2020-10-20 05:08:43 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
it 'when clicked shows the create issue page with the Incident type pre-selected' do
|
|
|
|
find('.create-incident-button').click
|
|
|
|
wait_for_all_requests
|
2020-10-20 05:08:43 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
expect(page).to have_selector('.dropdown-menu-toggle')
|
|
|
|
expect(page).to have_selector('.js-issuable-type-filter-dropdown-wrap')
|
2020-10-20 05:08:43 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
page.within('.js-issuable-type-filter-dropdown-wrap') do
|
|
|
|
expect(page).to have_content('Incident')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-10-20 05:08:43 -04:00
|
|
|
end
|
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
context 'by guest' do
|
|
|
|
let(:user) { guest }
|
2020-10-20 05:08:43 -04:00
|
|
|
|
2021-11-09 16:10:00 -05:00
|
|
|
it 'does not show new incident button' do
|
|
|
|
expect(page).not_to have_selector('.create-incident-button')
|
2020-10-20 05:08:43 -04:00
|
|
|
end
|
|
|
|
end
|
2020-10-12 14:08:31 -04:00
|
|
|
end
|