Commit 56f3deb5 authored by Dan Davison's avatar Dan Davison

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

Add create group milestone spec

See merge request gitlab-org/gitlab!36138
parents 1c0faeb6 e4b4caf0
......@@ -6,20 +6,20 @@
.col-form-label.col-sm-2
= f.label :title, "Title"
.col-sm-10
= f.text_field :title, maxlength: 255, class: "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: group_preview_markdown_path } do
= render 'shared/zen', f: f, attr: :description, classes: 'note-textarea', placeholder: 'Write milestone description...', supports_autocomplete: false
= render 'shared/zen', f: f, attr: :description, classes: 'note-textarea', qa_selector: 'milestone_description_field', placeholder: 'Write milestone description...', supports_autocomplete: false
.clearfix
.error-alert
= render "shared/milestones/form_dates", f: f
.form-actions
- if @milestone.new_record?
= f.submit 'Create milestone', class: "btn-success btn"
= f.submit 'Create milestone', class: "btn-success btn", data: { qa_selector: "create_milestone_button" }
= link_to "Cancel", group_milestones_path(@group), class: "btn btn-cancel"
- else
= f.submit 'Update milestone', class: "btn-success btn"
......
......@@ -7,7 +7,7 @@
= render 'shared/milestones/search_form'
= render 'shared/milestones_sort_dropdown'
- if can?(current_user, :admin_milestone, @group)
= link_to "New milestone", new_group_milestone_path(@group), class: "btn btn-success"
= link_to "New milestone", new_group_milestone_path(@group), class: "btn btn-success", data: { qa_selector: "new_group_milestone_link" }
.milestones
%ul.content-list
......
......@@ -81,7 +81,7 @@
- if group_sidebar_link?(:milestones)
= nav_link(path: 'milestones#index') do
= link_to group_milestones_path(@group), title: _('Milestones') do
= link_to group_milestones_path(@group), title: _('Milestones'), data: { qa_selector: 'group_milestones_link' } do
%span
= _('Milestones')
......
......@@ -209,6 +209,11 @@ module QA
autoload :Show, 'qa/page/group/show'
autoload :Menu, 'qa/page/group/menu'
module Milestone
autoload :Index, 'qa/page/group/milestone/index'
autoload :New, 'qa/page/group/milestone/new'
end
module SubMenus
autoload :Common, 'qa/page/group/sub_menus/common'
autoload :Members, 'qa/page/group/sub_menus/members'
......@@ -219,6 +224,12 @@ module QA
end
end
module Milestone
autoload :Index, 'qa/page/milestone/index'
autoload :New, 'qa/page/milestone/new'
autoload :Show, 'qa/page/milestone/show'
end
module File
autoload :Form, 'qa/page/file/form'
autoload :Show, 'qa/page/file/show'
......@@ -320,7 +331,6 @@ 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
......
......@@ -87,6 +87,10 @@ module QA
end
end
module Milestone
autoload :Show, 'qa/ee/page/milestone/show'
end
module Profile
autoload :Menu, 'qa/ee/page/profile/menu'
end
......@@ -113,10 +117,6 @@ module QA
autoload :Show, 'qa/ee/page/project/wiki/show'
end
module Milestone
autoload :Show, 'qa/ee/page/project/milestone/show'
end
module Settings
autoload :ProtectedBranches, 'qa/ee/page/project/settings/protected_branches'
autoload :Main, 'qa/ee/page/project/settings/main'
......
# frozen_string_literal: true
module QA
module EE
module Page
module Milestone
module Show
extend QA::Page::PageConcern
def self.prepended(base)
super
base.class_eval do
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
element :burndown_chart
end
view 'ee/app/views/shared/milestones/_weight.html.haml' do
element :total_issue_weight_value
end
end
end
def burndown_chart
find_element(:burndown_chart)
end
def click_weight_button
click_element(:weight_button)
end
def total_issue_weight_value
find_element(:total_issue_weight_value)
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Milestone
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
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
element :burndown_chart
end
end
end
def click_weight_button
click_element(:weight_button)
end
def burndown_chart
find_element(:burndown_chart)
end
def total_issue_weight_value
find_element(:total_issue_weight_value)
end
end
end
end
end
end
end
......@@ -7,9 +7,11 @@ module QA
include SubMenus::Common
view 'app/views/layouts/nav/sidebar/_group.html.haml' do
element :group_settings_item
element :group_members_item
element :general_settings_link
element :group_issues_item
element :group_members_item
element :group_milestones_link
element :group_settings_item
end
view 'app/views/layouts/nav/sidebar/_analytics_links.html.haml' do
......@@ -44,6 +46,25 @@ module QA
end
end
end
def go_to_milestones
hover_issues do
within_submenu do
click_element(:group_milestones_link)
end
end
end
private
def hover_issues
within_sidebar do
scroll_to_element(:group_issues_item)
find_element(:group_issues_item).hover
yield
end
end
end
end
end
......
# frozen_string_literal: true
module QA
module Page
module Group
module Milestone
class Index < Page::Milestone::Index
view 'app/views/groups/milestones/index.html.haml' do
element :new_group_milestone_link
end
def click_new_milestone_link
click_element(:new_group_milestone_link)
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Group
module Milestone
class New < Page::Milestone::New
view 'app/views/groups/milestones/_form.html.haml' do
element :create_milestone_button
element :milestone_description_field
element :milestone_title_field
end
def click_create_milestone_button
click_element(:create_milestone_button)
end
def set_description(description)
fill_element(:milestone_description_field, description)
end
def set_title(title)
fill_element(:milestone_title_field, title)
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Milestone
class Index < Page::Base
view 'app/views/shared/milestones/_milestone.html.haml' do
element :milestone_link
end
def click_milestone(milestone)
click_element(:milestone_link, milestone_title: milestone.title)
end
def has_milestone?(milestone)
has_element?(:milestone_link, milestone_title: milestone.title)
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Milestone
class New < Page::Base
view 'app/views/shared/milestones/_form_dates.html.haml' do
element :due_date_field
element :start_date_field
end
def set_due_date(due_date)
fill_element(:due_date_field, due_date.to_s + "\n")
end
def set_start_date(start_date)
fill_element(:start_date_field, start_date.to_s + "\n")
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Milestone
class Show < Page::Base
include Support::Dates
view 'app/views/shared/milestones/_description.html.haml' do
element :milestone_description_content
element :milestone_title_content, required: true
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
QA::Page::Milestone::Show.prepend_if_ee('QA::EE::Page::Milestone::Show')
......@@ -4,7 +4,7 @@ module QA
module Page
module Project
module Milestone
class Index < Page::Base
class Index < Page::Milestone::Index
view 'app/views/projects/milestones/index.html.haml' do
element :new_project_milestone_link
end
......
......@@ -4,7 +4,7 @@ module QA
module Page
module Project
module Milestone
class New < Page::Base
class New < Page::Milestone::New
view 'app/views/projects/milestones/_form.html.haml' do
element :create_milestone_button
element :milestone_description_field
......
# 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')
......@@ -7,6 +7,7 @@ module QA
attribute :id
attribute :title
attribute :description
attribute :group do
Group.fabricate_via_api! do |resource|
......@@ -16,6 +17,7 @@ module QA
def initialize
@title = "group-milestone-#{SecureRandom.hex(4)}"
@description = "My awesome group 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!
group.visit!
Page::Group::Menu.perform(&:go_to_milestones)
Page::Group::Milestone::Index.perform(&:click_new_milestone_link)
Page::Group::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
RSpec.describe 'Plan' do
describe 'Group milestone' do
include Support::Dates
let(:title) { 'Group milestone' }
let(:description) { 'This milestone tests out group 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 group milestone' do
group_milestone = Resource::GroupMilestone.fabricate_via_browser_ui! do |milestone|
milestone.title = title
milestone.description = description
milestone.start_date = start_date
milestone.due_date = due_date
end
Page::Group::Menu.perform(&:go_to_milestones)
Page::Group::Milestone::Index.perform do |milestone_list|
expect(milestone_list).to have_milestone(group_milestone)
milestone_list.click_milestone(group_milestone)
end
Page::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
# frozen_string_literal: true
module QA
context 'Plan' do
RSpec.describe 'Plan' do
describe 'Project milestone' do
include Support::Dates
......@@ -29,7 +29,7 @@ module QA
milestone_list.click_milestone(project_milestone)
end
Page::Project::Milestone::Show.perform do |milestone|
Page::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)
......
......@@ -24,7 +24,7 @@ module QA
it 'shows burndown chart on milestone page' do
milestone.visit!
QA::Page::Project::Milestone::Show.perform do |show|
Page::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::Page::Project::Milestone::Show.perform do |show|
Page::Milestone::Show.perform do |show|
expect(show.total_issue_weight_value).to have_content(weight)
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