Commit cf7d23a6 authored by Desiree Chevalier's avatar Desiree Chevalier

Add create project milestone spec

Adds an e2e spec for creating a project milestone
parent 368ba899
......@@ -7,13 +7,13 @@
.col-form-label.col-sm-2
= f.label :title, _('Title')
.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
.col-form-label.col-sm-2
= f.label :description, _('Description')
.col-sm-10
= 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'
.clearfix
.error-alert
......@@ -21,7 +21,7 @@
.form-actions
- 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'
- else
= f.submit _('Save changes'), class: 'btn-success btn'
......
......@@ -7,7 +7,7 @@
= render 'shared/milestones/search_form'
= render 'shared/milestones_sort_dropdown'
- 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')
.milestones
......
.detail-page-description.milestone-detail
%h2.title
%h2{ data: { qa_selector: "milestone_title_content" } }
.title
= markdown_field(milestone, :title)
- if milestone.try(:description).present?
%div
%div{ data: { qa_selector: "milestone_description_content" } }
.description.md
= markdown_field(milestone, :description)
......@@ -3,11 +3,11 @@
.col-form-label.col-sm-2
= f.label :start_date, _('Start Date')
.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')
.form-group.row
.col-form-label.col-sm-2
= f.label :due_date, _('Due Date')
.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')
......@@ -6,7 +6,8 @@
.row
.col-sm-6
.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
= " - #{milestone_type}"
......
......@@ -24,7 +24,7 @@
- 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'
.value
%span.value-content
%span.value-content{ data: { qa_selector: 'start_date_content' } }
- if milestone.start_date
%span.bold= milestone.start_date.to_s(:medium)
- else
......@@ -60,7 +60,7 @@
- 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'
.value.hide-collapsed
%span.value-content
%span.value-content{ data: { qa_selector: 'due_date_content' } }
- if milestone.due_date
%span.bold= milestone.due_date.to_s(:medium)
- else
......
......@@ -320,6 +320,7 @@ module QA
module Milestone
autoload :New, 'qa/page/project/milestone/new'
autoload :Index, 'qa/page/project/milestone/index'
autoload :Show, 'qa/page/project/milestone/show'
end
module Operations
......
......@@ -5,7 +5,12 @@ module QA
module Page
module Project
module Milestone
class Show < ::QA::Page::Base
module Show
extend QA::Page::PageConcern
def self.prepended(base)
super
base.class_eval do
view 'ee/app/views/shared/milestones/_weight.html.haml' do
element :total_issue_weight_value
end
......@@ -17,6 +22,8 @@ module QA
view 'ee/app/assets/javascripts/burndown_chart/components/burndown_chart.vue' do
element :burndown_chart
end
end
end
def click_weight_button
click_element(:weight_button)
......
......@@ -6,11 +6,23 @@ module QA
module Milestone
class Index < Page::Base
view 'app/views/projects/milestones/index.html.haml' do
element :new_project_milestone
element :new_project_milestone_link
end
def click_new_milestone
click_element :new_project_milestone
view 'app/views/shared/milestones/_milestone.html.haml' do
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
......
......@@ -6,21 +6,34 @@ module QA
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
element :create_milestone_button
element :milestone_description_field
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
def set_title(title)
fill_element :milestone_title, title
fill_element :milestone_title_field, title
end
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
def click_milestone_create_button
click_element :milestone_create_button
def set_start_date(start_date)
fill_element :start_date_field, start_date.to_s + "\n"
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
end
end
def go_to_milestones
hover_issues do
within_submenu do
click_element(:milestones_link)
end
end
end
private
def hover_issues
......
......@@ -7,6 +7,7 @@ module QA
attribute :id
attribute :title
attribute :description
attribute :project do
Project.fabricate_via_api! do |resource|
......@@ -16,6 +17,7 @@ module QA
def initialize
@title = "project-milestone-#{SecureRandom.hex(4)}"
@description = "My awesome project milestone."
end
def api_get_path
......@@ -28,12 +30,28 @@ module QA
def api_post_body
{
title: title
title: title,
description: description
}.tap do |hash|
hash[:start_date] = @start_date if @start_date
hash[:due_date] = @due_date if @due_date
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
# 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
it 'shows burndown chart on milestone page' do
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 have_content("Open issues")
......
......@@ -31,7 +31,7 @@ module QA
show.click_milestone_link
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)
end
......
......@@ -11,6 +11,11 @@ module QA
current_date.next_month.strftime("%Y/%m/%d")
end
def format_date(date)
new_date = DateTime.strptime(date, "%Y/%m/%d")
new_date.strftime("%b %-d, %Y")
end
private
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