Commit f72adcc9 authored by Dan Davison's avatar Dan Davison Committed by Rémy Coutable

Milestone tests

parent 51da26fd
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
= render_if_exists 'projects/sidebar/issues_service_desk' = render_if_exists 'projects/sidebar/issues_service_desk'
= nav_link(controller: :milestones) do = nav_link(controller: :milestones) do
= link_to project_milestones_path(@project), title: 'Milestones' do = link_to project_milestones_path(@project), title: 'Milestones', class: 'qa-milestones-link' do
%span %span
= _('Milestones') = _('Milestones')
- if project_nav_tab? :external_issue_tracker - if project_nav_tab? :external_issue_tracker
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
.form-group.row .form-group.row
= f.label :title, "Title", class: "col-form-label col-sm-2" = f.label :title, "Title", class: "col-form-label col-sm-2"
.col-sm-10 .col-sm-10
= f.text_field :title, maxlength: 255, class: "form-control", required: true, autofocus: true = f.text_field :title, maxlength: 255, class: "qa-milestone-title form-control", required: true, autofocus: true
.form-group.row.milestone-description .form-group.row.milestone-description
= f.label :description, "Description", class: "col-form-label col-sm-2" = f.label :description, "Description", class: "col-form-label col-sm-2"
.col-sm-10 .col-sm-10
= render layout: 'projects/md_preview', locals: { url: preview_markdown_path(@project) } do = render layout: 'projects/md_preview', locals: { url: preview_markdown_path(@project) } do
= render 'projects/zen', f: f, attr: :description, classes: 'note-textarea', placeholder: 'Write milestone description...' = render 'projects/zen', f: f, attr: :description, classes: 'qa-milestone-description note-textarea', placeholder: 'Write milestone description...'
= render 'shared/notes/hints' = render 'shared/notes/hints'
.clearfix .clearfix
.error-alert .error-alert
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
.form-actions .form-actions
- if @milestone.new_record? - if @milestone.new_record?
= f.submit 'Create milestone', class: "btn-create btn" = f.submit 'Create milestone', class: "btn-create btn qa-milestone-create-button"
= link_to "Cancel", project_milestones_path(@project), class: "btn btn-cancel" = link_to "Cancel", project_milestones_path(@project), class: "btn btn-cancel"
- else - else
= f.submit 'Save changes', class: "btn-save btn" = f.submit 'Save changes', class: "btn-save btn"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
.nav-controls .nav-controls
= render 'shared/milestones_sort_dropdown' = render 'shared/milestones_sort_dropdown'
- if can?(current_user, :admin_milestone, @project) - if can?(current_user, :admin_milestone, @project)
= link_to new_project_milestone_path(@project), class: "btn btn-new", title: 'New milestone' do = link_to new_project_milestone_path(@project), class: "btn btn-new qa-new-project-milestone", title: 'New milestone' do
New milestone New milestone
.milestones .milestones
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
= icon('angle-double-left') = icon('angle-double-left')
.detail-page-description.milestone-detail .detail-page-description.milestone-detail
%h2.title %h2.title.qa-milestone-title
= markdown_field(@milestone, :title) = markdown_field(@milestone, :title)
%div %div
......
- if any_projects?(@projects) - if any_projects?(@projects)
.project-item-select-holder.btn-group .project-item-select-holder.btn-group
%a.btn.btn-new.new-project-item-link{ href: '', data: { label: local_assigns[:label], type: local_assigns[:type] } } %a.btn.btn-new.new-project-item-link.qa-new-project-item-link{ href: '', data: { label: local_assigns[:label], type: local_assigns[:type] } }
= icon('spinner spin') = icon('spinner spin')
= project_select_tag :project_path, class: "project-item-select", data: { include_groups: local_assigns[:include_groups], order_by: 'last_activity_at', relative_path: local_assigns[:path] }, with_feature_enabled: local_assigns[:with_feature_enabled] = project_select_tag :project_path, class: "project-item-select", data: { include_groups: local_assigns[:include_groups], order_by: 'last_activity_at', relative_path: local_assigns[:path] }, with_feature_enabled: local_assigns[:with_feature_enabled]
%button.btn.btn-new.new-project-item-select-button %button.btn.btn-new.new-project-item-select-button.qa-new-project-item-select-button
= icon('caret-down') = icon('caret-down')
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
- dropdown_title = local_assigns.fetch(:dropdown_title, "Filter by milestone") - dropdown_title = local_assigns.fetch(:dropdown_title, "Filter by milestone")
- if selected.present? || params[:milestone_title].present? - if selected.present? || params[:milestone_title].present?
= hidden_field_tag(name, name == :milestone_title ? selected_text : selected.id) = hidden_field_tag(name, name == :milestone_title ? selected_text : selected.id)
= dropdown_tag(milestone_dropdown_label(selected_text), options: { title: dropdown_title, toggle_class: "js-milestone-select js-filter-submit #{extra_class}", filter: true, dropdown_class: "dropdown-menu-selectable dropdown-menu-milestone", = dropdown_tag(milestone_dropdown_label(selected_text), options: { title: dropdown_title, toggle_class: "qa-issuable-milestone-dropdown js-milestone-select js-filter-submit #{extra_class}", filter: true, dropdown_class: "qa-issuable-dropdown-menu-milestone dropdown-menu-selectable dropdown-menu-milestone",
placeholder: "Search milestones", footer_content: project.present?, data: { show_no: true, show_menu_above: show_menu_above, show_any: show_any, show_upcoming: show_upcoming, show_started: show_started, field_name: name, selected: selected_text, project_id: project.try(:id), milestones: milestones_filter_dropdown_path, default_label: "Milestone" } }) do placeholder: "Search milestones", footer_content: project.present?, data: { show_no: true, show_menu_above: show_menu_above, show_any: show_any, show_upcoming: show_upcoming, show_started: show_started, field_name: name, selected: selected_text, project_id: project.try(:id), milestones: milestones_filter_dropdown_path, default_label: "Milestone" } }) do
- if project - if project
%ul.dropdown-footer-list %ul.dropdown-footer-list
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
= form.label :milestone_id, "Milestone", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}" = form.label :milestone_id, "Milestone", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}"
.col-sm-10{ class: ("col-md-8" if has_due_date) } .col-sm-10{ class: ("col-md-8" if has_due_date) }
.issuable-form-select-holder .issuable-form-select-holder
= render "shared/issuable/milestone_dropdown", selected: issuable.milestone, name: "#{issuable.class.model_name.param_key}[milestone_id]", show_any: false, show_upcoming: false, show_started: false, extra_class: "js-issuable-form-dropdown js-dropdown-keep-input", dropdown_title: "Select milestone" = render "shared/issuable/milestone_dropdown", selected: issuable.milestone, name: "#{issuable.class.model_name.param_key}[milestone_id]", show_any: false, show_upcoming: false, show_started: false, extra_class: "qa-issuable-milestone-dropdown js-issuable-form-dropdown js-dropdown-keep-input", dropdown_title: "Select milestone"
.form-group.row .form-group.row
- has_labels = @labels && @labels.any? - has_labels = @labels && @labels.any?
= form.label :label_ids, "Labels", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}" = form.label :label_ids, "Labels", class: "col-form-label #{has_due_date ? "col-md-2 col-lg-4" : "col-sm-2"}"
......
...@@ -47,6 +47,7 @@ module QA ...@@ -47,6 +47,7 @@ module QA
autoload :Runner, 'qa/factory/resource/runner' autoload :Runner, 'qa/factory/resource/runner'
autoload :PersonalAccessToken, 'qa/factory/resource/personal_access_token' autoload :PersonalAccessToken, 'qa/factory/resource/personal_access_token'
autoload :KubernetesCluster, 'qa/factory/resource/kubernetes_cluster' autoload :KubernetesCluster, 'qa/factory/resource/kubernetes_cluster'
autoload :ProjectMilestone, 'qa/factory/resource/project_milestone'
autoload :Wiki, 'qa/factory/resource/wiki' autoload :Wiki, 'qa/factory/resource/wiki'
end end
...@@ -166,6 +167,11 @@ module QA ...@@ -166,6 +167,11 @@ module QA
autoload :Index, 'qa/page/project/issue/index' autoload :Index, 'qa/page/project/issue/index'
end end
module Milestone
autoload :New, 'qa/page/project/milestone/new'
autoload :Index, 'qa/page/project/milestone/index'
end
module Operations module Operations
module Kubernetes module Kubernetes
autoload :Index, 'qa/page/project/operations/kubernetes/index' autoload :Index, 'qa/page/project/operations/kubernetes/index'
......
...@@ -7,7 +7,10 @@ module QA ...@@ -7,7 +7,10 @@ module QA
attr_accessor :title, attr_accessor :title,
:description, :description,
:source_branch, :source_branch,
:target_branch :target_branch,
:assignee,
:milestone,
:labels
product :project do |factory| product :project do |factory|
factory.project factory.project
...@@ -41,16 +44,18 @@ module QA ...@@ -41,16 +44,18 @@ module QA
@description = 'This is a test merge request' @description = 'This is a test merge request'
@source_branch = "qa-test-feature-#{SecureRandom.hex(8)}" @source_branch = "qa-test-feature-#{SecureRandom.hex(8)}"
@target_branch = "master" @target_branch = "master"
@assignee = nil
@milestone = nil
@labels = []
end end
def fabricate! def fabricate!
project.visit! project.visit!
Page::Project::Show.act { new_merge_request } Page::Project::Show.act { new_merge_request }
Page::MergeRequest::New.perform do |page| Page::MergeRequest::New.perform do |page|
page.fill_title(@title) page.fill_title(@title)
page.fill_description(@description) page.fill_description(@description)
page.choose_milestone(@milestone) if @milestone
page.create_merge_request page.create_merge_request
end end
end end
......
module QA
module Factory
module Resource
class ProjectMilestone < Factory::Base
attr_accessor :description
attr_reader :title
dependency Factory::Resource::Project, as: :project
product(:title) { |factory| factory.title }
def title=(title)
@title = "#{title}-#{SecureRandom.hex(4)}"
@description = 'A milestone'
end
def fabricate!
project.visit!
Page::Menu::Side.act do
click_issues
click_milestones
end
Page::Project::Milestone::Index.act { click_new_milestone }
Page::Project::Milestone::New.perform do |milestone_new|
milestone_new.set_title(@title)
milestone_new.set_description(@description)
milestone_new.create_new_milestone
end
end
end
end
end
end
...@@ -16,6 +16,7 @@ module QA ...@@ -16,6 +16,7 @@ module QA
element :operations_section, "class: 'shortcuts-operations'" element :operations_section, "class: 'shortcuts-operations'"
element :activity_link, "title: 'Activity'" element :activity_link, "title: 'Activity'"
element :wiki_link_text, "Wiki" element :wiki_link_text, "Wiki"
element :milestones_link
end end
view 'app/assets/javascripts/fly_out_nav.js' do view 'app/assets/javascripts/fly_out_nav.js' do
...@@ -70,6 +71,12 @@ module QA ...@@ -70,6 +71,12 @@ module QA
end end
end end
def click_milestones
within_sidebar do
click_element :milestones_link
end
end
def click_wiki def click_wiki
within_sidebar do within_sidebar do
click_link('Wiki') click_link('Wiki')
......
...@@ -10,10 +10,18 @@ module QA ...@@ -10,10 +10,18 @@ module QA
element :issuable_form_title element :issuable_form_title
end end
view 'app/views/shared/issuable/form/_metadata.html.haml' do
element :issuable_milestone_dropdown
end
view 'app/views/shared/form_elements/_description.html.haml' do view 'app/views/shared/form_elements/_description.html.haml' do
element :issuable_form_description element :issuable_form_description
end end
view 'app/views/shared/issuable/_milestone_dropdown.html.haml' do
element :issuable_dropdown_menu_milestone
end
def create_merge_request def create_merge_request
click_element :issuable_create_button click_element :issuable_create_button
end end
...@@ -25,6 +33,13 @@ module QA ...@@ -25,6 +33,13 @@ module QA
def fill_description(description) def fill_description(description)
fill_element :issuable_form_description, description fill_element :issuable_form_description, description
end end
def choose_milestone(milestone)
click_element :issuable_milestone_dropdown
within_element(:issuable_dropdown_menu_milestone) do
click_on milestone.title
end
end
end end
end end
end end
......
...@@ -79,6 +79,12 @@ module QA ...@@ -79,6 +79,12 @@ module QA
click_element :squash_checkbox click_element :squash_checkbox
end end
def has_milestone?(milestone_title)
page.within('.issuable-sidebar') do
!!find("[href*='/milestones/']", text: milestone_title, wait: 1)
end
end
end end
end end
end end
......
module QA
module Page
module Project
module Milestone
class Index < Page::Base
view 'app/views/projects/milestones/index.html.haml' do
element :new_project_milestone
end
def click_new_milestone
click_element :new_project_milestone
end
end
end
end
end
end
module QA
module Page
module Project
module Milestone
class New < Page::Base
view 'app/views/projects/milestones/_form.html.haml' do
element :milestone_create_button
element :milestone_title
element :milestone_description
end
def set_title(title)
fill_element :milestone_title, title
end
def set_description(description)
fill_element :milestone_description, description
end
def create_new_milestone
click_element :milestone_create_button
end
end
end
end
end
end
...@@ -4,14 +4,28 @@ module QA ...@@ -4,14 +4,28 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.act { sign_in_using_credentials }
current_project = Factory::Resource::Project.fabricate! do |project|
project.name = 'project-with-merge-request-and-milestone'
end
current_milestone = Factory::Resource::ProjectMilestone.fabricate! do |milestone|
milestone.title = 'unique-milestone'
milestone.project = current_project
end
Factory::Resource::MergeRequest.fabricate! do |merge_request| Factory::Resource::MergeRequest.fabricate! do |merge_request|
merge_request.title = 'This is a merge request' merge_request.title = 'This is a merge request with a milestone'
merge_request.description = 'Great feature' merge_request.description = 'Great feature with milestone'
merge_request.project = current_project
merge_request.milestone = current_milestone
end end
expect(page).to have_content('This is a merge request') Page::MergeRequest::Show.perform do |merge_request|
expect(page).to have_content('Great feature') expect(page).to have_content('This is a merge request with a milestone')
expect(page).to have_content(/Opened [\w\s]+ ago/) expect(page).to have_content('Great feature with milestone')
expect(page).to have_content(/Opened [\w\s]+ ago/)
expect(merge_request).to have_milestone(current_milestone.title)
end
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