diff options
author | Aleksandr Soborov <asoborov@gmail.com> | 2018-10-17 12:17:32 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-10-17 12:17:32 +0000 |
commit | a68b6315f194be52ca0a5c672458c489d3dc0e42 (patch) | |
tree | 4927e3de5b308f4b15c607939ba634044e0f20e1 /qa | |
parent | d32ac958ddb76290cf32759952907b1b67cfd440 (diff) | |
download | gitlab-ce-a68b6315f194be52ca0a5c672458c489d3dc0e42.tar.gz |
Extend Create New Merge Request test to also add a label
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa.rb | 6 | ||||
-rw-r--r-- | qa/qa/factory/resource/label.rb | 39 | ||||
-rw-r--r-- | qa/qa/factory/resource/merge_request.rb | 4 | ||||
-rw-r--r-- | qa/qa/page/label/index.rb | 15 | ||||
-rw-r--r-- | qa/qa/page/label/new.rb | 30 | ||||
-rw-r--r-- | qa/qa/page/merge_request/new.rb | 10 | ||||
-rw-r--r-- | qa/qa/page/merge_request/show.rb | 11 | ||||
-rw-r--r-- | qa/qa/page/project/menu.rb | 13 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb | 16 |
9 files changed, 141 insertions, 3 deletions
@@ -45,6 +45,7 @@ module QA autoload :Group, 'qa/factory/resource/group' autoload :Issue, 'qa/factory/resource/issue' autoload :Project, 'qa/factory/resource/project' + autoload :Label, 'qa/factory/resource/label' autoload :MergeRequest, 'qa/factory/resource/merge_request' autoload :ProjectImportedFromGithub, 'qa/factory/resource/project_imported_from_github' autoload :MergeRequestFromFork, 'qa/factory/resource/merge_request_from_fork' @@ -240,6 +241,11 @@ module QA autoload :Banner, 'qa/page/layout/banner' end + module Label + autoload :New, 'qa/page/label/new' + autoload :Index, 'qa/page/label/index' + end + module MergeRequest autoload :New, 'qa/page/merge_request/new' autoload :Show, 'qa/page/merge_request/show' diff --git a/qa/qa/factory/resource/label.rb b/qa/qa/factory/resource/label.rb new file mode 100644 index 00000000000..4080f15bf66 --- /dev/null +++ b/qa/qa/factory/resource/label.rb @@ -0,0 +1,39 @@ +require 'securerandom' + +module QA + module Factory + module Resource + class Label < Factory::Base + attr_accessor :title, + :description, + :color + + product(:title) { |factory| factory.title } + + dependency Factory::Resource::Project, as: :project do |project| + project.name = 'project-with-label' + end + + def initialize + @title = "qa-test-#{SecureRandom.hex(8)}" + @description = 'This is a test label' + @color = '#0033CC' + end + + def fabricate! + project.visit! + + Page::Project::Menu.act { go_to_labels } + Page::Label::Index.act { go_to_new_label } + + Page::Label::New.perform do |page| + page.fill_title(@title) + page.fill_description(@description) + page.fill_color(@color) + page.create_label + end + end + end + end + end +end diff --git a/qa/qa/factory/resource/merge_request.rb b/qa/qa/factory/resource/merge_request.rb index ddb62bd0a68..c4620348202 100644 --- a/qa/qa/factory/resource/merge_request.rb +++ b/qa/qa/factory/resource/merge_request.rb @@ -56,6 +56,10 @@ module QA page.fill_title(@title) page.fill_description(@description) page.choose_milestone(@milestone) if @milestone + labels.each do |label| + page.select_label(label) + end + page.create_merge_request end end diff --git a/qa/qa/page/label/index.rb b/qa/qa/page/label/index.rb new file mode 100644 index 00000000000..323acd57743 --- /dev/null +++ b/qa/qa/page/label/index.rb @@ -0,0 +1,15 @@ +module QA + module Page + module Label + class Index < Page::Base + view 'app/views/projects/labels/index.html.haml' do + element :label_create_new + end + + def go_to_new_label + click_element :label_create_new + end + end + end + end +end diff --git a/qa/qa/page/label/new.rb b/qa/qa/page/label/new.rb new file mode 100644 index 00000000000..b5422dc9400 --- /dev/null +++ b/qa/qa/page/label/new.rb @@ -0,0 +1,30 @@ +module QA + module Page + module Label + class New < Page::Base + view 'app/views/shared/labels/_form.html.haml' do + element :label_title + element :label_description + element :label_color + element :label_create_button + end + + def create_label + click_element :label_create_button + end + + def fill_title(title) + fill_element :label_title, title + end + + def fill_description(description) + fill_element :label_description, description + end + + def fill_color(color) + fill_element :label_color, color + end + end + end + end +end diff --git a/qa/qa/page/merge_request/new.rb b/qa/qa/page/merge_request/new.rb index 83cc4bbbace..1f8f1fbca8e 100644 --- a/qa/qa/page/merge_request/new.rb +++ b/qa/qa/page/merge_request/new.rb @@ -22,6 +22,10 @@ module QA element :issuable_dropdown_menu_milestone end + view 'app/views/shared/issuable/_label_dropdown.html.haml' do + element :issuable_label + end + def create_merge_request click_element :issuable_create_button end @@ -40,6 +44,12 @@ module QA click_on milestone.title end end + + def select_label(label) + click_element :issuable_label + + click_link label.title + end end end end diff --git a/qa/qa/page/merge_request/show.rb b/qa/qa/page/merge_request/show.rb index b40e90ef4ad..376606afb5d 100644 --- a/qa/qa/page/merge_request/show.rb +++ b/qa/qa/page/merge_request/show.rb @@ -23,6 +23,10 @@ module QA element :squash_checkbox end + view 'app/views/shared/issuable/_sidebar.html.haml' do + element :labels_block + end + def fast_forward_possible? !has_text?('Fast-forward merge is not possible') end @@ -64,6 +68,13 @@ module QA end end + def has_label?(label) + page.within(element_selector_css(:labels_block)) do + element = find('span', text: label) + !element.nil? + end + end + def merge! # The merge button is disabled on load wait do diff --git a/qa/qa/page/project/menu.rb b/qa/qa/page/project/menu.rb index b32d5ea772b..bc125d1af88 100644 --- a/qa/qa/page/project/menu.rb +++ b/qa/qa/page/project/menu.rb @@ -22,6 +22,7 @@ module QA element :activity_link, "title: _('Activity')" # rubocop:disable QA/ElementWithPattern element :wiki_link_text, "Wiki" # rubocop:disable QA/ElementWithPattern element :milestones_link + element :labels_link end view 'app/assets/javascripts/fly_out_nav.js' do @@ -104,8 +105,20 @@ module QA end end + def go_to_labels + hover_issues { click_element :labels_link } + end + private + def hover_issues + within_sidebar do + find_element(:issues_item).hover + + yield + end + end + def hover_settings within_sidebar do find('.qa-settings-item').hover diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb index bcf55a02a61..f59bfb6b64d 100644 --- a/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb @@ -16,16 +16,26 @@ module QA milestone.project = current_project end + new_label = Factory::Resource::Label.fabricate! do |label| + label.project = current_project + label.title = 'qa-mr-test-label' + label.description = 'Merge Request label' + end + Factory::Resource::MergeRequest.fabricate! do |merge_request| merge_request.title = 'This is a merge request with a milestone' merge_request.description = 'Great feature with milestone' merge_request.project = current_project merge_request.milestone = current_milestone + merge_request.labels.push(new_label) end - expect(page).to have_content('This is a merge request with a milestone') - expect(page).to have_content('Great feature with milestone') - expect(page).to have_content(/Opened [\w\s]+ ago/) + Page::MergeRequest::Show.perform do |merge_request| + expect(merge_request).to have_content('This is a merge request with a milestone') + expect(merge_request).to have_content('Great feature with milestone') + expect(merge_request).to have_content(/Opened [\w\s]+ ago/) + expect(merge_request).to have_label(new_label.title) + end Page::Issuable::Sidebar.perform do |sidebar| expect(sidebar).to have_milestone(current_milestone.title) |