debian-mirror-gitlab/spec/support/shared_examples/quick_actions/issuable/time_tracking_quick_action_shared_examples.rb

99 lines
2.7 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2020-03-13 15:44:24 +05:30
RSpec.shared_examples 'issuable time tracker' do |issuable_type|
2019-07-07 11:18:12 +05:30
before do
project.add_maintainer(maintainer)
gitlab_sign_in(maintainer)
visit public_send("project_#{issuable_type}_path", project, issuable)
wait_for_all_requests
end
after do
wait_for_requests
end
2017-08-17 22:00:37 +05:30
it 'renders the sidebar component empty state' do
page.within '.time-tracking-no-tracking-pane' do
expect(page).to have_content 'No estimate or time spent'
end
end
it 'updates the sidebar component when estimate is added' do
submit_time('/estimate 3w 1d 1h')
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
page.within '.time-tracking-estimate-only-pane' do
expect(page).to have_content '3w 1d 1h'
end
end
it 'updates the sidebar component when spent is added' do
submit_time('/spend 3w 1d 1h')
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
page.within '.time-tracking-spend-only-pane' do
expect(page).to have_content '3w 1d 1h'
end
end
it 'shows the comparison when estimate and spent are added' do
submit_time('/estimate 3w 1d 1h')
submit_time('/spend 3w 1d 1h')
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
page.within '.time-tracking-comparison-pane' do
expect(page).to have_content '3w 1d 1h'
end
end
it 'updates the sidebar component when estimate is removed' do
submit_time('/estimate 3w 1d 1h')
submit_time('/remove_estimate')
page.within '.time-tracking-component-wrap' do
expect(page).to have_content 'No estimate or time spent'
end
end
it 'updates the sidebar component when spent is removed' do
submit_time('/spend 3w 1d 1h')
submit_time('/remove_time_spent')
page.within '.time-tracking-component-wrap' 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
find('.help-button').click
2017-09-10 17:25:29 +05:30
expect(page).to have_content 'Track time with quick actions'
2017-08-17 22:00:37 +05:30
expect(page).to have_content 'Learn more'
end
end
it 'hides the help state when close icon is clicked' do
page.within '.time-tracking-component-wrap' do
find('.help-button').click
find('.close-help-button').click
2017-09-10 17:25:29 +05:30
expect(page).not_to have_content 'Track time with quick actions'
2017-08-17 22:00:37 +05:30
expect(page).not_to have_content 'Learn more'
end
end
it 'displays the correct help url' do
page.within '.time-tracking-component-wrap' do
find('.help-button').click
2020-06-23 00:09:42 +05:30
expect(find_link('Learn more')[:href]).to have_content('/help/user/project/time_tracking.md')
2017-08-17 22:00:37 +05:30
end
end
end
2017-09-10 17:25:29 +05:30
def submit_time(quick_action)
fill_in 'note[note]', with: quick_action
2018-03-17 18:26:18 +05:30
find('.js-comment-submit-button').click
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
end