Commit df818b6f authored by Désirée Chevalier's avatar Désirée Chevalier Committed by Sanad Liaquat

Consolidate issuable sidebar page object code

Combines shared code from merge request and issue page
objects into the issuable sidebar page object.
parent f2a49133
...@@ -356,7 +356,6 @@ module QA ...@@ -356,7 +356,6 @@ module QA
module Issuable module Issuable
autoload :New, 'qa/page/issuable/new' autoload :New, 'qa/page/issuable/new'
autoload :Sidebar, 'qa/page/issuable/sidebar'
end end
module Alert module Alert
...@@ -442,6 +441,7 @@ module QA ...@@ -442,6 +441,7 @@ module QA
module Issuable module Issuable
autoload :Common, 'qa/page/component/issuable/common' autoload :Common, 'qa/page/component/issuable/common'
autoload :Sidebar, 'qa/page/component/issuable/sidebar'
end end
module IssueBoard module IssueBoard
......
# frozen_string_literal: true
module QA
module Page
module Component
module Issuable
module Sidebar
extend QA::Page::PageConcern
def self.included(base)
super
base.view 'app/assets/javascripts/sidebar/components/assignees/assignee_avatar.vue' do
element :avatar_image
end
base.view 'app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue' do
element :more_assignees_link
end
base.view 'app/helpers/dropdowns_helper.rb' do
element :dropdown_input_field
end
base.view 'app/views/shared/issuable/_sidebar.html.haml' do
element :assignee_block
element :dropdown_menu_labels
element :edit_link_labels
element :labels_block
element :milestone_block
element :milestone_link
end
end
def click_milestone_link
click_element(:milestone_link)
end
def has_assignee?(username)
page.within(element_selector_css(:assignee_block)) do
has_text?(username)
end
end
def has_avatar_image_count?(count)
wait_assignees_block_finish_loading do
all_elements(:avatar_image, count: count)
end
end
def has_label?(label)
within_element(:labels_block) do
!!has_element?(:label, label_name: label)
end
end
def has_milestone?(milestone_title)
within_element(:milestone_block) do
has_element?(:milestone_link, title: milestone_title)
end
end
def more_assignees_link
find_element(:more_assignees_link)
end
def select_labels_and_refresh(labels)
Support::Retrier.retry_until do
click_element(:edit_link_labels)
has_element?(:dropdown_menu_labels, text: labels.first)
end
labels.each do |label|
within_element(:dropdown_menu_labels, text: label) do
send_keys_to_element(:dropdown_input_field, [label, :enter])
end
end
click_element(:edit_link_labels)
labels.each do |label|
has_element?(:labels_block, text: label, wait: 0)
end
refresh
end
def text_of_labels_block
find_element(:labels_block)
end
def toggle_more_assignees_link
click_element(:more_assignees_link)
end
private
def wait_assignees_block_finish_loading
within_element(:assignee_block) do
wait_until(reload: false, max_duration: 10, sleep_interval: 1) do
finished_loading_block?
yield
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Issuable
class Sidebar < Page::Base
view 'app/views/shared/issuable/_sidebar.html.haml' do
element :labels_block
element :milestone_block
element :milestone_link
end
def has_label?(label)
within_element(:labels_block) do
has_element?(:label, label_name: label)
end
end
def has_milestone?(milestone_title)
within_element(:milestone_block) do
has_element?(:milestone_link, title: milestone_title)
end
end
end
end
end
end
...@@ -5,6 +5,7 @@ module QA ...@@ -5,6 +5,7 @@ module QA
module MergeRequest module MergeRequest
class Show < Page::Base class Show < Page::Base
include Page::Component::Note include Page::Component::Note
include Page::Component::Issuable::Sidebar
view 'app/assets/javascripts/mr_tabs_popover/components/popover.vue' do view 'app/assets/javascripts/mr_tabs_popover/components/popover.vue' do
element :dismiss_popover_button element :dismiss_popover_button
...@@ -64,11 +65,6 @@ module QA ...@@ -64,11 +65,6 @@ module QA
element :new_diff_line element :new_diff_line
end end
view 'app/views/shared/issuable/_sidebar.html.haml' do
element :assignee_block
element :labels_block
end
view 'app/views/projects/merge_requests/_mr_title.html.haml' do view 'app/views/projects/merge_requests/_mr_title.html.haml' do
element :edit_button element :edit_button
end end
...@@ -178,18 +174,6 @@ module QA ...@@ -178,18 +174,6 @@ module QA
has_element?(:merge_button) has_element?(:merge_button)
end end
def has_assignee?(username)
page.within(element_selector_css(:assignee_block)) do
has_text?(username)
end
end
def has_label?(label)
within_element(:labels_block) do
!!has_element?(:label, label_name: label)
end
end
def has_pipeline_status?(text) def has_pipeline_status?(text)
# Pipelines can be slow, so we wait a bit longer than the usual 10 seconds # Pipelines can be slow, so we wait a bit longer than the usual 10 seconds
has_element?(:merge_request_pipeline_info_content, text: text, wait: 30) has_element?(:merge_request_pipeline_info_content, text: text, wait: 30)
......
...@@ -8,6 +8,7 @@ module QA ...@@ -8,6 +8,7 @@ module QA
include Page::Component::Issuable::Common include Page::Component::Issuable::Common
include Page::Component::Note include Page::Component::Note
include Page::Component::DesignManagement include Page::Component::DesignManagement
include Page::Component::Issuable::Sidebar
view 'app/assets/javascripts/notes/components/comment_form.vue' do view 'app/assets/javascripts/notes/components/comment_form.vue' do
element :comment_button element :comment_button
...@@ -23,45 +24,25 @@ module QA ...@@ -23,45 +24,25 @@ module QA
element :noteable_note_item element :noteable_note_item
end end
view 'app/assets/javascripts/sidebar/components/assignees/assignee_avatar.vue' do
element :avatar_image
end
view 'app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue' do
element :more_assignees_link
end
view 'app/assets/javascripts/vue_shared/components/issue/related_issuable_item.vue' do view 'app/assets/javascripts/vue_shared/components/issue/related_issuable_item.vue' do
element :remove_related_issue_button element :remove_related_issue_button
end end
view 'app/helpers/dropdowns_helper.rb' do
element :dropdown_input_field
end
view 'app/views/shared/issuable/_close_reopen_button.html.haml' do view 'app/views/shared/issuable/_close_reopen_button.html.haml' do
element :close_issue_button element :close_issue_button
element :reopen_issue_button element :reopen_issue_button
end end
view 'app/views/shared/issuable/_sidebar.html.haml' do
element :assignee_block
element :labels_block
element :edit_link_labels
element :dropdown_menu_labels
element :milestone_link
end
view 'app/views/shared/notes/_form.html.haml' do view 'app/views/shared/notes/_form.html.haml' do
element :new_note_form, 'new-note' # rubocop:disable QA/ElementWithPattern element :new_note_form, 'new-note' # rubocop:disable QA/ElementWithPattern
element :new_note_form, 'attr: :note' # rubocop:disable QA/ElementWithPattern element :new_note_form, 'attr: :note' # rubocop:disable QA/ElementWithPattern
end end
view 'app/views/projects/issues/_tabs.html.haml' do view 'app/views/projects/issues/_tabs.html.haml' do
element :discussion_tab_link
element :discussion_tab_content
element :designs_tab_link
element :designs_tab_content element :designs_tab_content
element :designs_tab_link
element :discussion_tab_content
element :discussion_tab_link
end end
def click_discussion_tab def click_discussion_tab
...@@ -74,10 +55,6 @@ module QA ...@@ -74,10 +55,6 @@ module QA
active_element?(:designs_tab_content) active_element?(:designs_tab_content)
end end
def click_milestone_link
click_element(:milestone_link)
end
def click_remove_related_issue_button def click_remove_related_issue_button
click_element(:remove_related_issue_button) click_element(:remove_related_issue_button)
end end
...@@ -100,20 +77,10 @@ module QA ...@@ -100,20 +77,10 @@ module QA
click_element :comment_button click_element :comment_button
end end
def has_avatar_image_count?(count)
wait_assignees_block_finish_loading do
all_elements(:avatar_image, count: count)
end
end
def has_comment?(comment_text) def has_comment?(comment_text)
has_element?(:noteable_note_item, text: comment_text, wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME) has_element?(:noteable_note_item, text: comment_text, wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME)
end end
def more_assignees_link
find_element(:more_assignees_link)
end
def noteable_note_item def noteable_note_item
find_element(:noteable_note_item) find_element(:noteable_note_item)
end end
...@@ -130,35 +97,6 @@ module QA ...@@ -130,35 +97,6 @@ module QA
select_filter_with_text('Show history only') select_filter_with_text('Show history only')
end end
def select_labels_and_refresh(labels)
Support::Retrier.retry_until do
click_element(:edit_link_labels)
has_element?(:dropdown_menu_labels, text: labels.first)
end
labels.each do |label|
within_element(:dropdown_menu_labels, text: label) do
send_keys_to_element(:dropdown_input_field, [label, :enter])
end
end
click_element(:edit_link_labels)
labels.each do |label|
has_element?(:labels_block, text: label, wait: 0)
end
refresh
end
def text_of_labels_block
find_element(:labels_block)
end
def toggle_more_assignees_link
click_element(:more_assignees_link)
end
private private
def select_filter_with_text(text) def select_filter_with_text(text)
...@@ -168,15 +106,6 @@ module QA ...@@ -168,15 +106,6 @@ module QA
find_element(:filter_options, text: text).click find_element(:filter_options, text: text).click
end end
end end
def wait_assignees_block_finish_loading
within_element(:assignee_block) do
wait_until(reload: false, max_duration: 10, sleep_interval: 1) do
finished_loading_block?
yield
end
end
end
end end
end end
end end
......
...@@ -62,12 +62,9 @@ module QA ...@@ -62,12 +62,9 @@ module QA
Page::Project::Issue::Show.perform do |issue_page| Page::Project::Issue::Show.perform do |issue_page|
expect(issue_page).to have_comment(comment_text) expect(issue_page).to have_comment(comment_text)
end expect(issue_page).to have_label('enhancement')
expect(issue_page).to have_label('help wanted')
Page::Issuable::Sidebar.perform do |issuable| expect(issue_page).to have_label('good first issue')
expect(issuable).to have_label('enhancement')
expect(issuable).to have_label('help wanted')
expect(issuable).to have_label('good first issue')
end end
end end
end end
...@@ -91,9 +88,9 @@ module QA ...@@ -91,9 +88,9 @@ module QA
expect(page).to have_content('[Review comment] Nice blank line.') expect(page).to have_content('[Review comment] Nice blank line.')
expect(page).to have_content('[Single diff comment] Much better without this line!') expect(page).to have_content('[Single diff comment] Much better without this line!')
Page::Issuable::Sidebar.perform do |issuable| Page::MergeRequest::Show.perform do |merge_request|
expect(issuable).to have_label('bug') expect(merge_request).to have_label('bug')
expect(issuable).to have_label('enhancement') expect(merge_request).to have_label('enhancement')
end end
end end
......
...@@ -53,10 +53,7 @@ module QA ...@@ -53,10 +53,7 @@ module QA
expect(merge_request).to have_description(@merge_request_description) expect(merge_request).to have_description(@merge_request_description)
expect(merge_request).to have_assignee(gitlab_account_username) expect(merge_request).to have_assignee(gitlab_account_username)
expect(merge_request).to have_label(label.title) expect(merge_request).to have_label(label.title)
end expect(merge_request).to have_milestone(milestone.title)
Page::Issuable::Sidebar.perform do |sidebar|
expect(sidebar).to have_milestone(milestone.title)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment