Commit 0cd05d21 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '347496-consolidate-rspec-tests-for-sidebar-widgets' into 'master'

Consolidate milestone sidebar rspec tests RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!76513
parents 85fa77ec adb564bd
......@@ -29,7 +29,7 @@
= render_if_exists 'shared/issuable/sidebar_item_epic', issuable_sidebar: issuable_sidebar, group_path: @project.group.full_path, project_path: issuable_sidebar[:project_full_path], issue_iid: issuable_sidebar[:iid], issuable_type: issuable_type
- if issuable_sidebar[:supports_milestone]
.block.milestone{ :class => ("gl-border-b-0!" if in_group_context_with_iterations), data: { qa_selector: 'milestone_block' } }
.block.milestone{ :class => ("gl-border-b-0!" if in_group_context_with_iterations), data: { qa_selector: 'milestone_block', testid: 'sidebar-milestones' } }
.js-milestone-select{ data: { can_edit: can_edit_issuable.to_s, project_path: issuable_sidebar[:project_full_path], issue_iid: issuable_sidebar[:iid] } }
- if in_group_context_with_iterations
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Project issue boards sidebar milestones', :js do
include BoardHelpers
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:milestone) { create(:milestone, project: project) }
let_it_be(:issue1) { create(:issue, project: project, relative_position: 1) }
let_it_be(:issue2) { create(:issue, project: project, milestone: milestone, relative_position: 2) }
let_it_be(:board) { create(:board, project: project) }
let_it_be(:list) { create(:list, board: board, position: 0) }
let(:card1) { find('.board:nth-child(1) .board-card:nth-of-type(1)') }
let(:card2) { find('.board:nth-child(1) .board-card:nth-of-type(2)') }
before do
project.add_maintainer(user)
sign_in(user)
visit project_board_path(project, board)
wait_for_requests
end
context 'milestone' do
it 'adds a milestone' do
click_card(card1)
page.within('[data-testid="sidebar-milestones"]') do
click_button 'Edit'
wait_for_requests
click_button milestone.title
wait_for_requests
page.within('[data-testid="select-milestone"]') do
expect(page).to have_content(milestone.title)
end
end
end
it 'removes a milestone' do
click_card(card2)
page.within('[data-testid="sidebar-milestones"]') do
click_button 'Edit'
wait_for_requests
click_button "No milestone"
wait_for_requests
page.within('[data-testid="select-milestone"]') do
expect(page).not_to have_content(milestone.title)
end
end
end
end
end
......@@ -259,37 +259,7 @@ RSpec.describe 'Issue Sidebar' do
end
context 'editing issue milestone', :js do
let_it_be(:milestone_expired) { create(:milestone, project: project, title: 'Foo - expired', due_date: 5.days.ago) }
let_it_be(:milestone_no_duedate) { create(:milestone, project: project, title: 'Foo - No due date') }
let_it_be(:milestone1) { create(:milestone, project: project, title: 'Milestone-1', due_date: 20.days.from_now) }
let_it_be(:milestone2) { create(:milestone, project: project, title: 'Milestone-2', due_date: 15.days.from_now) }
let_it_be(:milestone3) { create(:milestone, project: project, title: 'Milestone-3', due_date: 10.days.from_now) }
before do
page.within('.block.milestone') do
click_button 'Edit'
end
wait_for_all_requests
end
it 'shows milestones list in the dropdown' do
page.within('.block.milestone') do
# 5 milestones + "No milestone" = 6 items
expect(page.find('.gl-new-dropdown-contents')).to have_selector('li.gl-new-dropdown-item', count: 6)
end
end
it 'shows expired milestone at the bottom of the list and milestone due earliest at the top of the list', :aggregate_failures do
page.within('.block.milestone .gl-new-dropdown-contents') do
expect(page.find('li:last-child')).to have_content milestone_expired.title
expect(page.all('li.gl-new-dropdown-item')[1]).to have_content milestone3.title
expect(page.all('li.gl-new-dropdown-item')[2]).to have_content milestone2.title
expect(page.all('li.gl-new-dropdown-item')[3]).to have_content milestone1.title
expect(page.all('li.gl-new-dropdown-item')[4]).to have_content milestone_no_duedate.title
end
end
it_behaves_like 'milestone sidebar widget'
end
context 'editing issue labels', :js do
......
# frozen_string_literal: true
RSpec.shared_examples 'milestone sidebar widget' do
context 'editing milestone' do
let_it_be(:milestone_expired) { create(:milestone, project: project, title: 'Foo - expired', due_date: 5.days.ago) }
let_it_be(:milestone_no_duedate) { create(:milestone, project: project, title: 'Foo - No due date') }
let_it_be(:milestone1) { create(:milestone, project: project, title: 'Milestone-1', due_date: 20.days.from_now) }
let_it_be(:milestone2) { create(:milestone, project: project, title: 'Milestone-2', due_date: 15.days.from_now) }
let_it_be(:milestone3) { create(:milestone, project: project, title: 'Milestone-3', due_date: 10.days.from_now) }
let(:milestone_widget) { find('[data-testid="sidebar-milestones"]') }
before do
within(milestone_widget) do
click_button 'Edit'
end
wait_for_all_requests
end
it 'shows milestones list in the dropdown' do
# 5 milestones + "No milestone" = 6 items
expect(milestone_widget.find('.gl-new-dropdown-contents')).to have_selector('li.gl-new-dropdown-item', count: 6)
end
it 'shows expired milestone at the bottom of the list and milestone due earliest at the top of the list', :aggregate_failures do
within(milestone_widget, '.gl-new-dropdown-contents') do
expect(page.find('li:last-child')).to have_content milestone_expired.title
[milestone3, milestone2, milestone1, milestone_no_duedate].each_with_index do |m, i|
expect(page.all('li.gl-new-dropdown-item')[i + 1]).to have_content m.title
end
end
end
it 'adds a milestone' do
within(milestone_widget) do
click_button milestone1.title
wait_for_requests
page.within('[data-testid="select-milestone"]') do
expect(page).to have_content(milestone1.title)
end
end
end
it 'removes a milestone' do
within(milestone_widget) do
click_button "No milestone"
wait_for_requests
page.within('[data-testid="select-milestone"]') do
expect(page).not_to have_content(milestone1.title)
end
end
end
end
end
......@@ -5,6 +5,7 @@ RSpec.shared_examples 'issue boards sidebar' do
before do
first_card.click
wait_for_requests
end
it 'shows sidebar when clicking issue' do
......@@ -41,6 +42,10 @@ RSpec.shared_examples 'issue boards sidebar' do
end
end
context 'editing issue milestone', :js do
it_behaves_like 'milestone sidebar widget'
end
context 'in notifications subscription' do
it 'displays notifications toggle', :aggregate_failures do
page.within('[data-testid="sidebar-notifications"]') do
......
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