Welcome to mirror list, hosted at ThFree Co, Russian Federation.

incident_timeline_events_spec.rb « incidents « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4ceae0f87808ef91d070a2676415122eb0dea57d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Incident timeline events', :js, feature_category: :incident_management do
  include ListboxHelpers

  let_it_be(:project) { create(:project) }
  let_it_be(:user) { create(:user, developer_projects: [project]) }
  let_it_be(:incident) { create(:incident, project: project) }

  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')

      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

      # Edit event
      trigger_dropdown_action(_('Edit'))
      complete_form('Edited event note goes here', '08', '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

      # Delete event
      trigger_dropdown_action(_('Delete'))

      page.within '.modal' do
        expect(page).to have_content(s_('Incident|Delete event'))
      end

      click_button s_('Incident|Delete event')
      wait_for_requests

      expect(page).to have_content(s_('Incident|No timeline items have been added yet.'))
    end

    it 'submits event data on save' do
      # Add event
      click_button(s_('Incident|Add new timeline event'))

      select_from_listbox('Start time', from: 'Select tags')

      complete_form('Event note goes here', '07', '25')

      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')
        expect(page).to have_content('Start time')
      end

      # Edit event
      trigger_dropdown_action(_('Edit'))

      select_from_listbox('Start time', from: 'Start time')

      complete_form('Edited event note goes here', '08', '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')
      end
    end

    private

    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')
      wait_for_requests
    end

    def trigger_dropdown_action(text)
      click_button _('More actions')

      within_testid 'disclosure-content' do
        find_by_testid('disclosure-dropdown-item', text: text).click
      end
    end
  end

  it_behaves_like 'for each incident details route',
    'add, edit, and delete timeline events',
    tab_text: s_('Incident|Timeline'),
    tab: 'timeline'
end