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

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

102 lines
2.8 KiB
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Incident timeline events', :js, feature_category: :incident_management do
2022-08-13 15:12:31 +05:30
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
let_it_be(:incident) { create(:incident, project: project) }
before_all do
project.add_developer(developer)
end
before do
sign_in(developer)
visit project_issues_incident_path(project, incident)
wait_for_requests
2022-10-11 01:57:18 +05:30
click_link s_('Incident|Timeline')
2022-08-13 15:12:31 +05:30
end
context 'when add event is clicked' do
it 'submits event data when save is clicked' do
2022-10-11 01:57:18 +05:30
click_button s_('Incident|Add new timeline event')
2022-08-13 15:12:31 +05:30
expect(page).to have_selector('.common-note-form')
2022-10-11 01:57:18 +05:30
fill_in _('Description'), with: 'Event note goes here'
2022-08-13 15:12:31 +05:30
fill_in 'timeline-input-hours', with: '07'
fill_in 'timeline-input-minutes', with: '25'
2022-10-11 01:57:18 +05:30
click_button _('Save')
2022-08-13 15:12:31 +05:30
expect(page).to have_selector('.incident-timeline-events')
page.within '.timeline-event-note' do
expect(page).to have_content('Event note goes here')
expect(page).to have_content('07:25')
end
end
end
2022-10-11 01:57:18 +05:30
context 'when edit is clicked' do
2022-08-13 15:12:31 +05:30
before do
click_button 'Add new timeline event'
2022-10-11 01:57:18 +05:30
fill_in 'Description', with: 'Event note to edit'
click_button _('Save')
end
it 'shows the confirmation modal and edits the event' do
click_button _('More actions')
2023-03-04 22:38:38 +05:30
page.within '.gl-dropdown-contents' do
2022-10-11 01:57:18 +05:30
expect(page).to have_content(_('Edit'))
2023-03-04 22:38:38 +05:30
page.find('.gl-dropdown-item-text-primary', text: _('Edit')).click
2022-10-11 01:57:18 +05:30
end
expect(page).to have_selector('.common-note-form')
fill_in _('Description'), with: 'Event note goes here'
fill_in 'timeline-input-hours', with: '07'
fill_in 'timeline-input-minutes', with: '25'
click_button _('Save')
wait_for_requests
page.within '.timeline-event-note' do
expect(page).to have_content('Event note goes here')
expect(page).to have_content('07:25')
end
end
end
context 'when delete is clicked' do
before do
click_button s_('Incident|Add new timeline event')
fill_in _('Description'), with: 'Event note to delete'
click_button _('Save')
2022-08-13 15:12:31 +05:30
end
it 'shows the confirmation modal and deletes the event' do
2022-10-11 01:57:18 +05:30
click_button _('More actions')
2022-08-13 15:12:31 +05:30
2023-03-04 22:38:38 +05:30
page.within '.gl-dropdown-contents' do
2022-10-11 01:57:18 +05:30
expect(page).to have_content(_('Delete'))
2023-03-04 22:38:38 +05:30
page.find('.gl-dropdown-item-text-primary', text: 'Delete').click
2022-08-13 15:12:31 +05:30
end
page.within '.modal' do
2022-10-11 01:57:18 +05:30
expect(page).to have_content(s_('Incident|Delete event'))
2022-08-13 15:12:31 +05:30
end
2022-10-11 01:57:18 +05:30
click_button s_('Incident|Delete event')
2022-08-13 15:12:31 +05:30
wait_for_requests
2022-10-11 01:57:18 +05:30
expect(page).to have_content(s_('Incident|No timeline items have been added yet.'))
2022-08-13 15:12:31 +05:30
end
end
end