diff options
Diffstat (limited to 'spec/support/shared_examples/features/work_items_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/features/work_items_shared_examples.rb | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/spec/support/shared_examples/features/work_items_shared_examples.rb b/spec/support/shared_examples/features/work_items_shared_examples.rb index 6d4d0a5dd0a..526a56e7dab 100644 --- a/spec/support/shared_examples/features/work_items_shared_examples.rb +++ b/spec/support/shared_examples/features/work_items_shared_examples.rb @@ -307,3 +307,82 @@ RSpec.shared_examples 'work items notifications' do end end end + +RSpec.shared_examples 'work items todos' do + let(:todos_action_selector) { '[data-testid="work-item-todos-action"]' } + let(:todos_icon_selector) { '[data-testid="work-item-todos-icon"]' } + let(:header_section_selector) { '[data-testid="work-item-body"]' } + + def toggle_todo_action + find(todos_action_selector).click + wait_for_requests + end + + it 'adds item to the list' do + page.within(header_section_selector) do + expect(find(todos_action_selector)['aria-label']).to eq('Add a to do') + + toggle_todo_action + + expect(find(todos_action_selector)['aria-label']).to eq('Mark as done') + end + + page.within ".header-content span[aria-label='#{_('Todos count')}']" do + expect(page).to have_content '1' + end + end + + it 'marks a todo as done' do + page.within(header_section_selector) do + toggle_todo_action + toggle_todo_action + end + + expect(find(todos_action_selector)['aria-label']).to eq('Add a to do') + expect(page).to have_selector(".header-content span[aria-label='#{_('Todos count')}']", visible: :hidden) + end +end + +RSpec.shared_examples 'work items award emoji' do + let(:award_section_selector) { '[data-testid="work-item-award-list"]' } + let(:award_action_selector) { '[data-testid="award-button"]' } + let(:selected_award_action_selector) { '[data-testid="award-button"].selected' } + let(:emoji_picker_action_selector) { '[data-testid="emoji-picker"]' } + let(:basketball_emoji_selector) { 'gl-emoji[data-name="basketball"]' } + + def select_emoji + first(award_action_selector).click + + wait_for_requests + end + + it 'adds award to the work item' do + within(award_section_selector) do + select_emoji + + expect(page).to have_selector(selected_award_action_selector) + expect(first(award_action_selector)).to have_content '1' + end + end + + it 'removes award from work item' do + within(award_section_selector) do + select_emoji + + expect(first(award_action_selector)).to have_content '1' + + select_emoji + + expect(first(award_action_selector)).to have_content '0' + end + end + + it 'add custom award to the work item' do + within(award_section_selector) do + find(emoji_picker_action_selector).click + find(basketball_emoji_selector).click + + expect(page).to have_selector(basketball_emoji_selector) + end + end +end |