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:
Diffstat (limited to 'spec/support/shared_examples/quick_actions')
-rw-r--r--spec/support/shared_examples/quick_actions/incident/timeline_quick_action_shared_examples.rb82
-rw-r--r--spec/support/shared_examples/quick_actions/issuable/time_tracking_quick_action_shared_examples.rb54
-rw-r--r--spec/support/shared_examples/quick_actions/merge_request/rebase_quick_action_shared_examples.rb11
3 files changed, 136 insertions, 11 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
diff --git a/spec/support/shared_examples/quick_actions/issuable/time_tracking_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/issuable/time_tracking_quick_action_shared_examples.rb
index f414500f202..18304951e41 100644
--- a/spec/support/shared_examples/quick_actions/issuable/time_tracking_quick_action_shared_examples.rb
+++ b/spec/support/shared_examples/quick_actions/issuable/time_tracking_quick_action_shared_examples.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
RSpec.shared_examples 'issuable time tracker' do |issuable_type|
+ let_it_be(:time_tracker_selector) { '[data-testid="time-tracker"]' }
+
before do
project.add_maintainer(maintainer)
gitlab_sign_in(maintainer)
@@ -12,6 +14,14 @@ RSpec.shared_examples 'issuable time tracker' do |issuable_type|
wait_for_requests
end
+ def open_time_tracking_report
+ page.within time_tracker_selector do
+ click_link 'Time tracking report'
+
+ wait_for_requests
+ end
+ end
+
it 'renders the sidebar component empty state' do
page.within '[data-testid="noTrackingPane"]' do
expect(page).to have_content 'No estimate or time spent'
@@ -50,7 +60,7 @@ RSpec.shared_examples 'issuable time tracker' do |issuable_type|
submit_time('/estimate 3w 1d 1h')
submit_time('/remove_estimate')
- page.within '.time-tracking-component-wrap' do
+ page.within time_tracker_selector do
expect(page).to have_content 'No estimate or time spent'
end
end
@@ -59,13 +69,13 @@ RSpec.shared_examples 'issuable time tracker' do |issuable_type|
submit_time('/spend 3w 1d 1h')
submit_time('/remove_time_spent')
- page.within '.time-tracking-component-wrap' do
+ page.within time_tracker_selector do
expect(page).to have_content 'No estimate or time spent'
end
end
it 'shows the help state when icon is clicked' do
- page.within '.time-tracking-component-wrap' do
+ page.within time_tracker_selector do
find('[data-testid="helpButton"]').click
expect(page).to have_content 'Track time with quick actions'
expect(page).to have_content 'Learn more'
@@ -78,11 +88,7 @@ RSpec.shared_examples 'issuable time tracker' do |issuable_type|
wait_for_requests
- page.within '.time-tracking-component-wrap' do
- click_link 'Time tracking report'
-
- wait_for_requests
- end
+ open_time_tracking_report
page.within '#time-tracking-report' do
expect(find('tbody')).to have_content maintainer.name
@@ -90,8 +96,36 @@ RSpec.shared_examples 'issuable time tracker' do |issuable_type|
end
end
+ it 'removes time log when delete is clicked in time tracking report' do
+ submit_time('/estimate 1w')
+ submit_time('/spend 1d')
+ submit_time('/spend 3d')
+
+ wait_for_requests
+
+ open_time_tracking_report
+
+ page.within '#time-tracking-report tbody tr:nth-child(2)' do
+ click_button test_id: 'deleteButton'
+
+ wait_for_requests
+ end
+
+ # Assert that 2nd row was removed
+ expect(all('#time-tracking-report tbody tr').length).to eq(1)
+ expect(find('#time-tracking-report tbody')).not_to have_content('3d')
+
+ # Assert that summary line was updated
+ expect(find('#time-tracking-report tfoot')).to have_content('1d', exact: true)
+
+ # Assert that the time tracking widget was reactively updated
+ page.within '[data-testid="timeTrackingComparisonPane"]' do
+ expect(page).to have_content '1d'
+ end
+ end
+
it 'hides the help state when close icon is clicked' do
- page.within '.time-tracking-component-wrap' do
+ page.within time_tracker_selector do
find('[data-testid="helpButton"]').click
find('[data-testid="closeHelpButton"]').click
@@ -101,7 +135,7 @@ RSpec.shared_examples 'issuable time tracker' do |issuable_type|
end
it 'displays the correct help url' do
- page.within '.time-tracking-component-wrap' do
+ page.within time_tracker_selector do
find('[data-testid="helpButton"]').click
expect(find_link('Learn more')[:href]).to have_content('/help/user/project/time_tracking.md')
diff --git a/spec/support/shared_examples/quick_actions/merge_request/rebase_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/merge_request/rebase_quick_action_shared_examples.rb
index 2258bdd2c79..92705fc1b4d 100644
--- a/spec/support/shared_examples/quick_actions/merge_request/rebase_quick_action_shared_examples.rb
+++ b/spec/support/shared_examples/quick_actions/merge_request/rebase_quick_action_shared_examples.rb
@@ -75,7 +75,16 @@ RSpec.shared_examples 'rebase quick action' do
end
context 'when the merge request branch is protected from force push' do
- let!(:protected_branch) { create(:protected_branch, project: project, name: merge_request.source_branch, allow_force_push: false) }
+ let!(:protected_branch) do
+ ProtectedBranches::CreateService.new(
+ project,
+ user,
+ name: merge_request.source_branch,
+ allow_force_push: false,
+ push_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }],
+ merge_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }]
+ ).execute
+ end
it 'does not rebase the MR' do
add_note("/rebase")