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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-20 02:18:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-20 02:18:09 +0300
commit6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch)
treedc4d20fe6064752c0bd323187252c77e0a89144b /spec/support/shared_examples/quick_actions/incident/timeline_quick_action_shared_examples.rb
parent9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff)
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/support/shared_examples/quick_actions/incident/timeline_quick_action_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/quick_actions/incident/timeline_quick_action_shared_examples.rb82
1 files changed, 82 insertions, 0 deletions
diff --git a/spec/support/shared_examples/quick_actions/incident/timeline_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/incident/timeline_quick_action_shared_examples.rb
new file mode 100644
index 00000000000..ae7e511a739
--- /dev/null
+++ b/spec/support/shared_examples/quick_actions/incident/timeline_quick_action_shared_examples.rb
@@ -0,0 +1,82 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'timeline quick action' do
+ describe '/timeline' do
+ context 'with valid args' do
+ where(:timeline_text, :date_time_arg) do
+ [
+ ['timeline comment', '2022-09-09 09:30'],
+ ['new timeline comment', '09:30'],
+ ['another timeline comment', ' 2022-09-09 09:15']
+ ]
+ end
+
+ with_them do
+ it 'adds a timeline event' do
+ add_note("/timeline #{timeline_text} | #{date_time_arg}")
+
+ expect(page).to have_content('Timeline event added successfully.')
+ expect(issue.incident_management_timeline_events.first.note).to eq(timeline_text)
+ expect(issue.incident_management_timeline_events.first.occurred_at).to eq(DateTime.parse(date_time_arg))
+ end
+ end
+
+ it 'adds a timeline event when no date is passed' do
+ freeze_time do
+ add_note('/timeline timeline event with not date')
+
+ expect(page).to have_content('Timeline event added successfully.')
+ expect(issue.incident_management_timeline_events.first.note).to eq('timeline event with not date')
+ expect(issue.incident_management_timeline_events.first.occurred_at).to eq(DateTime
+ .current.strftime("%Y-%m-%d %H:%M:00 UTC"))
+ end
+ end
+
+ it 'adds a timeline event when only date is passed' do
+ freeze_time do
+ add_note('/timeline timeline event with not date | 2022-10-11')
+
+ expect(page).to have_content('Timeline event added successfully.')
+ expect(issue.incident_management_timeline_events.first.note).to eq('timeline event with not date')
+ expect(issue.incident_management_timeline_events.first.occurred_at).to eq(DateTime
+ .current.strftime("%Y-%m-%d %H:%M:00 UTC"))
+ end
+ end
+ end
+
+ context 'with invalid args' do
+ where(:timeline_text, :date_time_arg) do
+ [
+ ['timeline comment', '2022-13-13 09:30'],
+ ['timeline comment 2', '2022-09-06 24:30']
+ ]
+ end
+
+ with_them do
+ it 'does not add a timeline event' do
+ add_note("/timeline #{timeline_text} | #{date_time_arg}")
+
+ expect(page).to have_content('Failed to apply commands.')
+ expect(issue.incident_management_timeline_events.length).to eq(0)
+ end
+ end
+ end
+
+ context 'when create service fails' do
+ before do
+ allow_next_instance_of(::IncidentManagement::TimelineEvents::CreateService) do |service|
+ allow(service).to receive(:execute).and_return(
+ ServiceResponse.error(payload: { timeline_event: nil }, message: 'Some error')
+ )
+ end
+ end
+
+ it 'does not add a timeline event' do
+ add_note('/timeline text | 2022-09-10 09:30')
+
+ expect(page).to have_content('Something went wrong while adding timeline event.')
+ expect(issue.incident_management_timeline_events.length).to eq(0)
+ end
+ end
+ end
+end