Skip to content
Snippets Groups Projects
Commit 713facd9 authored by Florie Guibert's avatar Florie Guibert
Browse files

Consolidate due date sidebar rspec tests

Unify tests for issue board and issue page
parent bb224023
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -154,7 +154,7 @@ export default {
};
},
dataTestId() {
return this.dateType === dateTypes.start ? 'start-date' : 'due-date';
return this.dateType === dateTypes.start ? 'sidebar-start-date' : 'sidebar-due-date';
},
},
methods: {
Loading
Loading
Loading
Loading
@@ -114,7 +114,7 @@
 
wait_for_requests
 
page.within('[data-testid="start-date"]') do
page.within('[data-testid="sidebar-start-date"]') do
edit_fixed_date
end
end
Loading
Loading
@@ -124,7 +124,7 @@
 
wait_for_requests
 
page.within('[data-testid="start-date"]') do
page.within('[data-testid="sidebar-start-date"]') do
remove_fixed_date
end
end
Loading
Loading
@@ -136,7 +136,7 @@
 
wait_for_requests
 
page.within('[data-testid="due-date"]') do
page.within('[data-testid="sidebar-due-date"]') do
edit_fixed_date
end
end
Loading
Loading
@@ -146,7 +146,7 @@
 
wait_for_requests
 
page.within('[data-testid="due-date"]') do
page.within('[data-testid="sidebar-due-date"]') do
remove_fixed_date
end
end
Loading
Loading
Loading
Loading
@@ -11,7 +11,6 @@
let_it_be(:label) { create(:label, project: project, title: 'bug') }
let_it_be(:issue) { create(:labeled_issue, project: project, labels: [label]) }
let_it_be(:mock_date) { Date.today.at_beginning_of_month + 2.days }
let_it_be(:issue_with_due_date) { create(:issue, project: project, due_date: mock_date) }
let_it_be(:xss_label) { create(:label, project: project, title: '<script>alert("xss");</script>') }
 
before do
Loading
Loading
@@ -201,30 +200,6 @@
end
end
 
context 'due date widget', :js do
let(:due_date_value) { find('[data-testid="due-date"] [data-testid="sidebar-date-value"]') }
context 'when no due date exists' do
before do
visit_issue(project, issue)
end
it "displays 'None'" do
expect(due_date_value.text).to have_content 'None'
end
end
context 'when due date exists' do
before do
visit_issue(project, issue_with_due_date)
end
it "displays the due date" do
expect(due_date_value.text).to have_content mock_date.strftime('%b %-d, %Y')
end
end
end
context 'as an allowed user' do
before do
project.add_developer(user)
Loading
Loading
@@ -262,6 +237,10 @@
it_behaves_like 'milestone sidebar widget'
end
 
context 'editing issue due date', :js do
it_behaves_like 'date sidebar widget'
end
context 'editing issue labels', :js do
before do
issue.update!(labels: [label])
Loading
Loading
Loading
Loading
@@ -417,7 +417,7 @@ def close_dropdown_menu_if_visible
it 'adds due date to issue' do
date = Date.today.at_beginning_of_month + 2.days
 
page.within '[data-testid="due-date"]' do
page.within '[data-testid="sidebar-due-date"]' do
click_button 'Edit'
page.within '.pika-single' do
click_button date.day
Loading
Loading
@@ -432,7 +432,7 @@ def close_dropdown_menu_if_visible
it 'removes due date from issue' do
date = Date.today.at_beginning_of_month + 2.days
 
page.within '[data-testid="due-date"]' do
page.within '[data-testid="sidebar-due-date"]' do
click_button 'Edit'
 
page.within '.pika-single' do
Loading
Loading
# frozen_string_literal: true
 
require 'spec_helper'
RSpec.shared_examples 'date sidebar widget' do
context 'editing due date' do
let(:due_date_value) { find('[data-testid="sidebar-due-date"] [data-testid="sidebar-date-value"]') }
 
RSpec.describe 'Project issue boards sidebar due date', :js do
include BoardHelpers
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:issue) { create(:issue, project: project, relative_position: 1) }
let_it_be(:board) { create(:board, project: project) }
let_it_be(:list) { create(:list, board: board, position: 0) }
let(:card) { find('.board:nth-child(1)').first('.board-card') }
around do |example|
freeze_time { example.run }
end
before do
project.add_maintainer(user)
sign_in(user)
around do |example|
freeze_time { example.run }
end
 
visit project_board_path(project, board)
wait_for_requests
end
it 'displays "None" when there is no due date' do
expect(due_date_value.text).to have_content 'None'
end
 
context 'due date' do
it 'updates due date' do
click_card(card)
page.within('[data-testid="sidebar-due-date"]') do
today = Date.today.day
 
Loading
Loading
@@ -40,6 +23,7 @@
wait_for_requests
 
expect(page).to have_content(today.to_s(:medium))
expect(due_date_value.text).to have_content Time.current.strftime('%b %-d, %Y')
end
end
end
Loading
Loading
Loading
Loading
@@ -46,6 +46,10 @@
it_behaves_like 'milestone sidebar widget'
end
 
context 'editing issue due date', :js do
it_behaves_like 'date sidebar widget'
end
context 'in notifications subscription' do
it 'displays notifications toggle', :aggregate_failures do
page.within('[data-testid="sidebar-notifications"]') do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment