Commit de2d7f35 authored by Désirée Chevalier's avatar Désirée Chevalier Committed by Sanad Liaquat

Add assign project milestone spec

Adds a new e2e spec for assigning project milestones
parent e968773f
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
= _('Milestone') = _('Milestone')
= icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true') = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
- if can_edit_issuable - if can_edit_issuable
= link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link float-right', data: { track_label: "right_sidebar", track_property: "milestone", track_event: "click_edit_button", track_value: "" } = link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link float-right', data: { qa_selector: "edit_milestone_link", track_label: "right_sidebar", track_property: "milestone", track_event: "click_edit_button", track_value: "" }
.value.hide-collapsed .value.hide-collapsed
- if milestone.present? - if milestone.present?
= link_to milestone[:title], milestone[:web_url], class: "bold has-tooltip", title: sidebar_milestone_remaining_days(milestone), data: { container: "body", html: 'true', boundary: 'viewport', qa_selector: 'milestone_link', qa_title: milestone[:title] } = link_to milestone[:title], milestone[:web_url], class: "bold has-tooltip", title: sidebar_milestone_remaining_days(milestone), data: { container: "body", html: 'true', boundary: 'viewport', qa_selector: 'milestone_link', qa_title: milestone[:title] }
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
= _('Labels') = _('Labels')
= icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true') = icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
- if can_edit_issuable - if can_edit_issuable
= link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link qa-edit-link-labels float-right', data: { track_label: "right_sidebar", track_property: "labels", track_event: "click_edit_button", track_value: "" } = link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link float-right', data: { qa_selector: "edit_labels_link", track_label: "right_sidebar", track_property: "labels", track_event: "click_edit_button", track_value: "" }
.value.issuable-show-labels.dont-hide.hide-collapsed{ class: ("has-labels" if selected_labels.any?), data: { qa_selector: 'labels_block' } } .value.issuable-show-labels.dont-hide.hide-collapsed{ class: ("has-labels" if selected_labels.any?), data: { qa_selector: 'labels_block' } }
- if selected_labels.any? - if selected_labels.any?
- selected_labels.each do |label_hash| - selected_labels.each do |label_hash|
......
...@@ -25,13 +25,27 @@ module QA ...@@ -25,13 +25,27 @@ module QA
base.view 'app/views/shared/issuable/_sidebar.html.haml' do base.view 'app/views/shared/issuable/_sidebar.html.haml' do
element :assignee_block element :assignee_block
element :dropdown_menu_labels element :dropdown_menu_labels
element :edit_link_labels element :edit_labels_link
element :edit_milestone_link
element :labels_block element :labels_block
element :milestone_block element :milestone_block
element :milestone_link element :milestone_link
end end
end end
def assign_milestone(milestone)
click_element(:edit_milestone_link)
within_element(:milestone_block) do
click_link("#{milestone.title}")
end
wait_until(reload: false) do
has_element?(:milestone_block, text: milestone.title, wait: 0)
end
refresh
end
def click_milestone_link def click_milestone_link
click_element(:milestone_link) click_element(:milestone_link)
end end
...@@ -55,7 +69,7 @@ module QA ...@@ -55,7 +69,7 @@ module QA
end end
def has_milestone?(milestone_title) def has_milestone?(milestone_title)
within_element(:milestone_block) do wait_milestone_block_finish_loading do
has_element?(:milestone_link, title: milestone_title) has_element?(:milestone_link, title: milestone_title)
end end
end end
...@@ -66,7 +80,7 @@ module QA ...@@ -66,7 +80,7 @@ module QA
def select_labels_and_refresh(labels) def select_labels_and_refresh(labels)
Support::Retrier.retry_until do Support::Retrier.retry_until do
click_element(:edit_link_labels) click_element(:edit_labels_link)
has_element?(:dropdown_menu_labels, text: labels.first) has_element?(:dropdown_menu_labels, text: labels.first)
end end
...@@ -76,7 +90,7 @@ module QA ...@@ -76,7 +90,7 @@ module QA
end end
end end
click_element(:edit_link_labels) click_element(:edit_labels_link)
labels.each do |label| labels.each do |label|
has_element?(:labels_block, text: label, wait: 0) has_element?(:labels_block, text: label, wait: 0)
...@@ -103,6 +117,15 @@ module QA ...@@ -103,6 +117,15 @@ module QA
end end
end end
end end
def wait_milestone_block_finish_loading
within_element(:milestone_block) do
wait_until(reload: false, max_duration: 10, sleep_interval: 1) do
finished_loading_block?
yield
end
end
end
end end
end end
end end
......
...@@ -34,6 +34,7 @@ module QA ...@@ -34,6 +34,7 @@ module QA
Page::Project::Issue::New.perform do |new_page| Page::Project::Issue::New.perform do |new_page|
new_page.fill_title(@title) new_page.fill_title(@title)
new_page.fill_description(@description) new_page.fill_description(@description)
new_page.choose_milestone(@milestone) if @milestone
new_page.create_new_issue new_page.create_new_issue
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(:start_date) { current_date_yyyy_mm_dd }
let(:due_date) { next_month_yyyy_mm_dd }
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-to-test-milestones'
end
end
let(:issue) do
Resource::Issue.fabricate_via_api! do |issue|
issue.project = project
end
end
let(:project_milestone) do
Resource::ProjectMilestone.fabricate_via_api! do |milestone|
milestone.project = project
milestone.start_date = start_date
milestone.due_date = due_date
end
end
before do
Flow::Login.sign_in
end
it 'assigns a project milestone to an existing issue' do
issue.visit!
Page::Project::Issue::Show.perform do |existing_issue|
existing_issue.assign_milestone(project_milestone)
expect(existing_issue).to have_milestone(project_milestone.title)
end
end
it 'assigns a project milestone to a new issue' do
Resource::Issue.fabricate_via_browser_ui! do |issue|
issue.project = project
issue.milestone = project_milestone
end
Page::Project::Issue::Show.perform do |issue|
expect(issue).to have_milestone(project_milestone.title)
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