Commit ab2aa5d4 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch 'qa-add-create-project-milestone-spec' into 'master'

Add create project milestone spec

See merge request gitlab-org/gitlab!34964
parents b6e21033 cf7d23a6
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
.col-form-label.col-sm-2 .col-form-label.col-sm-2
= f.label :title, _('Title') = f.label :title, _('Title')
.col-sm-10 .col-sm-10
= f.text_field :title, maxlength: 255, class: 'qa-milestone-title form-control', required: true, autofocus: true = f.text_field :title, maxlength: 255, class: 'form-control', data: { qa_selector: 'milestone_title_field' }, required: true, autofocus: true
.form-group.row.milestone-description .form-group.row.milestone-description
.col-form-label.col-sm-2 .col-form-label.col-sm-2
= f.label :description, _('Description') = f.label :description, _('Description')
.col-sm-10 .col-sm-10
= render layout: 'shared/md_preview', locals: { url: preview_markdown_path(@project) } do = render layout: 'shared/md_preview', locals: { url: preview_markdown_path(@project) } do
= render 'shared/zen', f: f, attr: :description, classes: 'qa-milestone-description note-textarea', placeholder: _('Write milestone description...') = render 'shared/zen', f: f, attr: :description, classes: 'note-textarea', qa_selector: 'milestone_description_field', placeholder: _('Write milestone description...')
= render 'shared/notes/hints' = render 'shared/notes/hints'
.clearfix .clearfix
.error-alert .error-alert
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
.form-actions .form-actions
- if @milestone.new_record? - if @milestone.new_record?
= f.submit _('Create milestone'), class: 'btn-success btn qa-milestone-create-button' = f.submit _('Create milestone'), class: 'btn-success btn', data: { qa_selector: 'create_milestone_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-success btn' = f.submit _('Save changes'), class: 'btn-success btn'
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
= render 'shared/milestones/search_form' = render 'shared/milestones/search_form'
= 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-success qa-new-project-milestone', title: _('New milestone') do = link_to new_project_milestone_path(@project), class: 'btn btn-success', data: { qa_selector: "new_project_milestone_link" }, title: _('New milestone') do
= _('New milestone') = _('New milestone')
.milestones .milestones
......
.detail-page-description.milestone-detail .detail-page-description.milestone-detail
%h2.title %h2{ data: { qa_selector: "milestone_title_content" } }
.title
= markdown_field(milestone, :title) = markdown_field(milestone, :title)
- if milestone.try(:description).present? - if milestone.try(:description).present?
%div %div{ data: { qa_selector: "milestone_description_content" } }
.description.md .description.md
= markdown_field(milestone, :description) = markdown_field(milestone, :description)
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
.col-form-label.col-sm-2 .col-form-label.col-sm-2
= f.label :start_date, _('Start Date') = f.label :start_date, _('Start Date')
.col-sm-10 .col-sm-10
= f.text_field :start_date, class: "datepicker form-control", placeholder: _('Select start date'), autocomplete: 'off' = f.text_field :start_date, class: "datepicker form-control", data: { qa_selector: "start_date_field" }, placeholder: _('Select start date'), autocomplete: 'off'
%a.inline.float-right.prepend-top-5.js-clear-start-date{ href: "#" }= _('Clear start date') %a.inline.float-right.prepend-top-5.js-clear-start-date{ href: "#" }= _('Clear start date')
.form-group.row .form-group.row
.col-form-label.col-sm-2 .col-form-label.col-sm-2
= f.label :due_date, _('Due Date') = f.label :due_date, _('Due Date')
.col-sm-10 .col-sm-10
= f.text_field :due_date, class: "datepicker form-control", placeholder: _('Select due date'), autocomplete: 'off' = f.text_field :due_date, class: "datepicker form-control", data: { qa_selector: "due_date_field" }, placeholder: _('Select due date'), autocomplete: 'off'
%a.inline.float-right.prepend-top-5.js-clear-due-date{ href: "#" }= _('Clear due date') %a.inline.float-right.prepend-top-5.js-clear-due-date{ href: "#" }= _('Clear due date')
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
.row .row
.col-sm-6 .col-sm-6
.gl-mb-2 .gl-mb-2
%strong= link_to truncate(milestone.title, length: 100), milestone_path(milestone) %strong{ data: { qa_selector: "milestone_link", qa_milestone_title: milestone.title } }
= link_to truncate(milestone.title, length: 100), milestone_path(milestone)
- if @group - if @group
= " - #{milestone_type}" = " - #{milestone_type}"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
- if @project && can?(current_user, :admin_milestone, @project) - if @project && can?(current_user, :admin_milestone, @project)
= link_to s_('MilestoneSidebar|Edit'), edit_project_milestone_path(@project, @milestone), class: 'js-sidebar-dropdown-toggle edit-link float-right' = link_to s_('MilestoneSidebar|Edit'), edit_project_milestone_path(@project, @milestone), class: 'js-sidebar-dropdown-toggle edit-link float-right'
.value .value
%span.value-content %span.value-content{ data: { qa_selector: 'start_date_content' } }
- if milestone.start_date - if milestone.start_date
%span.bold= milestone.start_date.to_s(:medium) %span.bold= milestone.start_date.to_s(:medium)
- else - else
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
- if @project && can?(current_user, :admin_milestone, @project) - if @project && can?(current_user, :admin_milestone, @project)
= link_to s_('MilestoneSidebar|Edit'), edit_project_milestone_path(@project, @milestone), class: 'js-sidebar-dropdown-toggle edit-link float-right' = link_to s_('MilestoneSidebar|Edit'), edit_project_milestone_path(@project, @milestone), class: 'js-sidebar-dropdown-toggle edit-link float-right'
.value.hide-collapsed .value.hide-collapsed
%span.value-content %span.value-content{ data: { qa_selector: 'due_date_content' } }
- if milestone.due_date - if milestone.due_date
%span.bold= milestone.due_date.to_s(:medium) %span.bold= milestone.due_date.to_s(:medium)
- else - else
......
...@@ -320,6 +320,7 @@ module QA ...@@ -320,6 +320,7 @@ module QA
module Milestone module Milestone
autoload :New, 'qa/page/project/milestone/new' autoload :New, 'qa/page/project/milestone/new'
autoload :Index, 'qa/page/project/milestone/index' autoload :Index, 'qa/page/project/milestone/index'
autoload :Show, 'qa/page/project/milestone/show'
end end
module Operations module Operations
......
...@@ -5,17 +5,24 @@ module QA ...@@ -5,17 +5,24 @@ module QA
module Page module Page
module Project module Project
module Milestone module Milestone
class Show < ::QA::Page::Base module Show
view 'ee/app/views/shared/milestones/_weight.html.haml' do extend QA::Page::PageConcern
element :total_issue_weight_value
end
view 'ee/app/assets/javascripts/burndown_chart/components/burn_charts.vue' do def self.prepended(base)
element :weight_button super
end base.class_eval do
view 'ee/app/views/shared/milestones/_weight.html.haml' do
element :total_issue_weight_value
end
view 'ee/app/assets/javascripts/burndown_chart/components/burn_charts.vue' do
element :weight_button
end
view 'ee/app/assets/javascripts/burndown_chart/components/burndown_chart.vue' do view 'ee/app/assets/javascripts/burndown_chart/components/burndown_chart.vue' do
element :burndown_chart element :burndown_chart
end
end
end end
def click_weight_button def click_weight_button
......
...@@ -6,11 +6,23 @@ module QA ...@@ -6,11 +6,23 @@ module QA
module Milestone module Milestone
class Index < Page::Base class Index < Page::Base
view 'app/views/projects/milestones/index.html.haml' do view 'app/views/projects/milestones/index.html.haml' do
element :new_project_milestone element :new_project_milestone_link
end end
def click_new_milestone view 'app/views/shared/milestones/_milestone.html.haml' do
click_element :new_project_milestone element :milestone_link
end
def click_new_milestone_link
click_element :new_project_milestone_link
end
def has_milestone?(milestone)
has_element? :milestone_link, milestone_title: milestone.title
end
def click_milestone(milestone)
click_element :milestone_link, milestone_title: milestone.title
end end
end end
end end
......
...@@ -6,21 +6,34 @@ module QA ...@@ -6,21 +6,34 @@ module QA
module Milestone module Milestone
class New < Page::Base class New < Page::Base
view 'app/views/projects/milestones/_form.html.haml' do view 'app/views/projects/milestones/_form.html.haml' do
element :milestone_create_button element :create_milestone_button
element :milestone_title element :milestone_description_field
element :milestone_description element :milestone_title_field
end
view 'app/views/shared/milestones/_form_dates.html.haml' do
element :due_date_field
element :start_date_field
end
def click_create_milestone_button
click_element :create_milestone_button
end end
def set_title(title) def set_title(title)
fill_element :milestone_title, title fill_element :milestone_title_field, title
end end
def set_description(description) def set_description(description)
fill_element :milestone_description, description fill_element :milestone_description_field, description
end
def set_due_date(due_date)
fill_element :due_date_field, due_date.to_s + "\n"
end end
def click_milestone_create_button def set_start_date(start_date)
click_element :milestone_create_button fill_element :start_date_field, start_date.to_s + "\n"
end end
end end
end end
......
# frozen_string_literal: true
module QA
module Page
module Project
module Milestone
class Show < ::QA::Page::Base
include Support::Dates
view 'app/views/shared/milestones/_description.html.haml' do
element :milestone_title_content, required: true
element :milestone_description_content
end
view 'app/views/shared/milestones/_sidebar.html.haml' do
element :due_date_content
element :start_date_content
end
def has_due_date?(due_date)
formatted_due_date = format_date(due_date)
has_element?(:due_date_content, text: formatted_due_date)
end
def has_start_date?(start_date)
formatted_start_date = format_date(start_date)
has_element?(:start_date_content, text: formatted_start_date)
end
end
end
end
end
end
QA::Page::Project::Milestone::Show.prepend_if_ee('QA::EE::Page::Project::Milestone::Show')
...@@ -50,6 +50,14 @@ module QA ...@@ -50,6 +50,14 @@ module QA
end end
end end
def go_to_milestones
hover_issues do
within_submenu do
click_element(:milestones_link)
end
end
end
private private
def hover_issues def hover_issues
......
...@@ -7,6 +7,7 @@ module QA ...@@ -7,6 +7,7 @@ module QA
attribute :id attribute :id
attribute :title attribute :title
attribute :description
attribute :project do attribute :project do
Project.fabricate_via_api! do |resource| Project.fabricate_via_api! do |resource|
...@@ -16,6 +17,7 @@ module QA ...@@ -16,6 +17,7 @@ module QA
def initialize def initialize
@title = "project-milestone-#{SecureRandom.hex(4)}" @title = "project-milestone-#{SecureRandom.hex(4)}"
@description = "My awesome project milestone."
end end
def api_get_path def api_get_path
...@@ -28,12 +30,28 @@ module QA ...@@ -28,12 +30,28 @@ module QA
def api_post_body def api_post_body
{ {
title: title title: title,
description: description
}.tap do |hash| }.tap do |hash|
hash[:start_date] = @start_date if @start_date hash[:start_date] = @start_date if @start_date
hash[:due_date] = @due_date if @due_date hash[:due_date] = @due_date if @due_date
end end
end end
def fabricate!
project.visit!
Page::Project::Menu.perform(&:go_to_milestones)
Page::Project::Milestone::Index.perform(&:click_new_milestone_link)
Page::Project::Milestone::New.perform do |new_milestone|
new_milestone.set_title(@title)
new_milestone.set_description(@description)
new_milestone.set_start_date(@start_date) if @start_date
new_milestone.set_due_date(@due_date) if @due_date
new_milestone.click_create_milestone_button
end
end
end end
end end
end end
# frozen_string_literal: true
module QA
context 'Plan' do
describe 'Project milestone' do
include Support::Dates
let(:title) { 'Project milestone' }
let(:description) { 'This issue tests out project milestones.' }
let(:start_date) { current_date_yyyy_mm_dd }
let(:due_date) { next_month_yyyy_mm_dd }
before do
Flow::Login.sign_in
end
it 'creates a project milestone' do
project_milestone = Resource::ProjectMilestone.fabricate_via_browser_ui! do |milestone|
milestone.title = title
milestone.description = description
milestone.start_date = start_date
milestone.due_date = due_date
end
Page::Project::Menu.perform(&:go_to_milestones)
Page::Project::Milestone::Index.perform do |milestone_list|
expect(milestone_list).to have_milestone(project_milestone)
milestone_list.click_milestone(project_milestone)
end
Page::Project::Milestone::Show.perform do |milestone|
expect(milestone).to have_element(:milestone_title_content, text: title)
expect(milestone).to have_element(:milestone_description_content, text: description)
expect(milestone).to have_start_date(start_date)
expect(milestone).to have_due_date(due_date)
end
end
end
end
end
...@@ -24,7 +24,7 @@ module QA ...@@ -24,7 +24,7 @@ module QA
it 'shows burndown chart on milestone page' do it 'shows burndown chart on milestone page' do
milestone.visit! milestone.visit!
QA::EE::Page::Project::Milestone::Show.perform do |show| QA::Page::Project::Milestone::Show.perform do |show|
expect(show.burndown_chart).to be_visible expect(show.burndown_chart).to be_visible
expect(show.burndown_chart).to have_content("Open issues") expect(show.burndown_chart).to have_content("Open issues")
......
...@@ -31,7 +31,7 @@ module QA ...@@ -31,7 +31,7 @@ module QA
show.click_milestone_link show.click_milestone_link
end end
QA::EE::Page::Project::Milestone::Show.perform do |show| QA::Page::Project::Milestone::Show.perform do |show|
expect(show.total_issue_weight_value).to have_content(weight) expect(show.total_issue_weight_value).to have_content(weight)
end end
......
...@@ -11,6 +11,11 @@ module QA ...@@ -11,6 +11,11 @@ module QA
current_date.next_month.strftime("%Y/%m/%d") current_date.next_month.strftime("%Y/%m/%d")
end end
def format_date(date)
new_date = DateTime.strptime(date, "%Y/%m/%d")
new_date.strftime("%b %-d, %Y")
end
private private
def current_date def current_date
......
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