debian-mirror-gitlab/spec/features/incidents/user_views_incident_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

107 lines
3.2 KiB
Ruby
Raw Permalink Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
require "spec_helper"
2023-03-04 22:38:38 +05:30
RSpec.describe "User views incident", feature_category: :incident_management do
2021-01-29 00:20:46 +05:30
let_it_be(:project) { create(:project_empty_repo, :public) }
2023-01-13 00:05:48 +05:30
let_it_be(:guest) { create(:user) }
let_it_be(:developer) { create(:user) }
let_it_be(:user) { developer }
let(:author) { developer }
let(:description) { "# Description header\n\n**Lorem** _ipsum_ dolor sit [amet](https://example.com)" }
let(:incident) { create(:incident, project: project, description: description, author: author) }
2021-01-29 00:20:46 +05:30
before_all do
2023-01-13 00:05:48 +05:30
project.add_developer(developer)
project.add_guest(guest)
2021-01-29 00:20:46 +05:30
end
before do
sign_in(user)
2023-04-23 21:23:45 +05:30
visit(incident_project_issues_path(project, incident))
2021-01-29 00:20:46 +05:30
end
2023-01-13 00:05:48 +05:30
specify do
expect(page).to have_header_with_correct_id_and_link(1, 'Description header', 'description-header')
end
2021-01-29 00:20:46 +05:30
it_behaves_like 'page meta description', ' Description header Lorem ipsum dolor sit amet'
2021-12-11 22:18:48 +05:30
describe 'user actions' do
it 'shows the merge request and incident actions', :js, :aggregate_failures do
2023-01-13 00:05:48 +05:30
expected_href = new_project_issue_path(project,
issuable_template: 'incident',
issue: { issue_type: 'incident' },
add_related_issue: incident.iid)
2021-12-11 22:18:48 +05:30
click_button 'Incident actions'
2021-02-22 17:27:13 +05:30
2023-01-13 00:05:48 +05:30
expect(page).to have_link('New related incident', href: expected_href)
2021-12-11 22:18:48 +05:30
expect(page).to have_button('Create merge request')
expect(page).to have_button('Close incident')
end
2023-01-13 00:05:48 +05:30
context 'when user is guest' do
let(:user) { guest }
2021-12-11 22:18:48 +05:30
2023-01-13 00:05:48 +05:30
context 'and author' do
let(:author) { guest }
2021-12-11 22:18:48 +05:30
2023-01-13 00:05:48 +05:30
it 'does not show the incident actions', :js do
expect(page).not_to have_button('Incident actions')
end
2021-12-11 22:18:48 +05:30
end
2023-01-13 00:05:48 +05:30
context 'and not author' do
it 'shows incident actions', :js do
click_button 'Incident actions'
2023-03-17 16:20:25 +05:30
expect(page).to have_button 'Report abuse to administrator'
2023-01-13 00:05:48 +05:30
end
2021-12-11 22:18:48 +05:30
end
end
2021-01-29 00:20:46 +05:30
end
context 'when the project is archived' do
2023-01-13 00:05:48 +05:30
before_all do
2021-01-29 00:20:46 +05:30
project.update!(archived: true)
end
2023-01-13 00:05:48 +05:30
it 'does not show the incident actions', :js do
expect(page).not_to have_button('Incident actions')
2021-01-29 00:20:46 +05:30
end
end
describe 'user status' do
context 'when showing status of the author of the incident' do
2023-04-23 21:23:45 +05:30
subject { visit(incident_project_issues_path(project, incident)) }
2021-01-29 00:20:46 +05:30
it_behaves_like 'showing user status' do
let(:user_with_status) { user }
end
end
context 'when status message has an emoji', :js do
let_it_be(:message) { 'My status with an emoji' }
let_it_be(:message_emoji) { 'basketball' }
let_it_be(:status) { create(:user_status, user: user, emoji: 'smirk', message: "#{message} :#{message_emoji}:") }
it 'correctly renders the emoji' do
wait_for_requests
tooltip_span = page.first(".user-status-emoji[title^='#{message}']")
tooltip_span.hover
wait_for_requests
tooltip = page.find('.tooltip .tooltip-inner')
page.within(tooltip) do
expect(page).to have_emoji(message_emoji)
end
end
end
end
end