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.

100 lines
2.9 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
2023-04-23 21:23:45 +05:30
include ListboxHelpers
2022-08-13 15:12:31 +05:30
let_it_be(:project) { create(:project) }
2023-04-23 21:23:45 +05:30
let_it_be(:user) { create(:user, developer_projects: [project]) }
2022-08-13 15:12:31 +05:30
let_it_be(:incident) { create(:incident, project: project) }
2023-04-23 21:23:45 +05:30
shared_examples 'add, edit, and delete timeline events' do
it 'submits event data on save' do
# Add event
click_button(s_('Incident|Add new timeline event'))
complete_form('Event note goes here', '07', '25')
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
2023-04-23 21:23:45 +05:30
# Edit event
trigger_dropdown_action(_('Edit'))
complete_form('Edited event note goes here', '08', '30')
2022-10-11 01:57:18 +05:30
2023-04-23 21:23:45 +05:30
page.within '.timeline-event-note' do
expect(page).to have_content('Edited event note goes here')
expect(page).to have_content('08:30')
end
2022-10-11 01:57:18 +05:30
2023-04-23 21:23:45 +05:30
# Delete event
trigger_dropdown_action(_('Delete'))
page.within '.modal' do
expect(page).to have_content(s_('Incident|Delete event'))
2022-10-11 01:57:18 +05:30
end
2023-04-23 21:23:45 +05:30
click_button s_('Incident|Delete event')
wait_for_requests
expect(page).to have_content(s_('Incident|No timeline items have been added yet.'))
end
2023-06-20 00:43:36 +05:30
it 'submits event data on save' do
2023-04-23 21:23:45 +05:30
# Add event
click_button(s_('Incident|Add new timeline event'))
2022-10-11 01:57:18 +05:30
2023-04-23 21:23:45 +05:30
select_from_listbox('Start time', from: 'Select tags')
2022-10-11 01:57:18 +05:30
2023-04-23 21:23:45 +05:30
complete_form('Event note goes here', '07', '25')
2022-10-11 01:57:18 +05:30
2023-04-23 21:23:45 +05:30
expect(page).to have_selector('.incident-timeline-events')
2022-10-11 01:57:18 +05:30
page.within '.timeline-event-note' do
expect(page).to have_content('Event note goes here')
expect(page).to have_content('07:25')
2023-04-23 21:23:45 +05:30
expect(page).to have_content('Start time')
2022-10-11 01:57:18 +05:30
end
2023-04-23 21:23:45 +05:30
# Edit event
trigger_dropdown_action(_('Edit'))
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
select_from_listbox('Start time', from: 'Start time')
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
complete_form('Edited event note goes here', '08', '30')
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
page.within '.timeline-event-note' do
expect(page).to have_content('Edited event note goes here')
expect(page).to have_content('08:30')
expect(page).not_to have_content('Start time')
2022-08-13 15:12:31 +05:30
end
2023-04-23 21:23:45 +05:30
end
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
private
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
def complete_form(title, hours, minutes)
fill_in _('Description'), with: title
fill_in 'timeline-input-hours', with: hours
fill_in 'timeline-input-minutes', with: minutes
click_button _('Save')
2022-08-13 15:12:31 +05:30
wait_for_requests
2023-04-23 21:23:45 +05:30
end
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
def trigger_dropdown_action(text)
click_button _('More actions')
page.within '.gl-dropdown-contents' do
page.find('.gl-dropdown-item', text: text).click
end
2022-08-13 15:12:31 +05:30
end
end
2023-04-23 21:23:45 +05:30
it_behaves_like 'for each incident details route',
'add, edit, and delete timeline events',
2023-05-27 22:25:52 +05:30
tab_text: s_('Incident|Timeline'),
tab: 'timeline'
2022-08-13 15:12:31 +05:30
end