Commit 4abb8a06 authored by Eulyeon Ko's avatar Eulyeon Ko Committed by Miguel Rincon

Create shared sidebar examples

Use them in:

- Project boards (CE)
- Project boards with epic swimlanes (EE)
- Group boards with epic swimlanes (EE)
parent 10455f18
......@@ -7,6 +7,10 @@ fragment IssueNode on Issue {
referencePath: reference(full: true)
dueDate
timeEstimate
totalTimeSpent
humanTimeEstimate
humanTotalTimeSpent
emailsDisabled
confidential
webUrl
subscribed
......
......@@ -10,209 +10,42 @@ RSpec.describe 'epics swimlanes sidebar', :js do
let_it_be(:board) { create(:board, project: project) }
let_it_be(:label) { create(:label, project: project, name: 'Label 1') }
let_it_be(:list) { create(:list, board: board, label: label, position: 0) }
let_it_be(:epic1) { create(:epic, group: group) }
let_it_be(:epic2) { create(:epic, group: group) }
let_it_be(:issue1, reload: true) { create(:issue, project: project) }
let_it_be(:epic_issue1, reload: true) { create(:epic_issue, epic: epic1, issue: issue1) }
let_it_be(:issue, reload: true) { create(:issue, project: project) }
before do
project.add_maintainer(user)
stub_licensed_features(epics: true, swimlanes: true)
sign_in(user)
visit project_boards_path(project)
wait_for_requests
end
context 'when closing sidebar' do
let(:issue_card) { first("[data-testid='board-epic-lane-issues'] [data-testid='board_card']") }
it 'unhighlights the active issue card' do
load_epic_swimlanes
issue_card.click
find("[data-testid='sidebar-drawer'] .gl-drawer-close-button").click
project.add_maintainer(user)
group.add_maintainer(user)
expect(issue_card[:class]).not_to include('is-active')
expect(issue_card[:class]).not_to include('multi-select')
end
sign_in(user)
end
context 'epic dropdown' do
context "in project boards", :js do
before do
group.add_owner(user)
end
context 'when the issue is associated with an epic' do
it 'displays name of epic and links to it' do
load_epic_swimlanes
click_first_issue_card
page.within('[data-testid="sidebar-epic"]') do
expect(page).to have_link(epic1.title, href: epic_path(epic1))
end
end
it 'updates the epic associated with the issue' do
load_epic_swimlanes
click_first_issue_card
visit project_boards_path(project)
page.within('[data-testid="sidebar-epic"]') do
find("[data-testid='edit-button']").click
wait_for_requests
wait_for_all_requests
find('.gl-new-dropdown-item', text: epic2.title).click
wait_for_all_requests
expect(page).to have_link(epic2.title, href: epic_path(epic2))
end
end
end
end
context 'notifications subscription' do
it 'displays notifications toggle' do
load_epic_swimlanes
click_first_issue_card
page.within('[data-testid="sidebar-notifications"]') do
expect(page).to have_selector('[data-testid="notification-subscribe-toggle"]')
expect(page).to have_content('Notifications')
expect(page).not_to have_content('Notifications have been disabled by the project or group owner')
end
end
it 'shows toggle as on then as off as user toggles to subscribe and unsubscribe' do
load_epic_swimlanes
click_first_issue_card
toggle = find('[data-testid="notification-subscribe-toggle"]')
toggle.click
expect(toggle).to have_css("button.is-checked")
toggle.click
expect(toggle).not_to have_css("button.is-checked")
end
context 'when notifications have been disabled' do
before do
project.update_attribute(:emails_disabled, true)
load_epic_swimlanes
end
it 'displays a message that notifications have been disabled' do
click_first_issue_card
page.within('[data-testid="sidebar-notifications"]') do
expect(page).not_to have_selector('[data-testid="notification-subscribe-toggle"]')
expect(page).to have_content('Notifications have been disabled by the project or group owner')
end
end
end
it_behaves_like 'issue boards sidebar'
it_behaves_like 'issue boards sidebar EE'
end
context 'time tracking' do
it 'displays time tracking feature with default message' do
load_epic_swimlanes
click_first_issue_card
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Time tracking')
expect(page).to have_content('No estimate or time spent')
end
end
context 'when only spent time is recorded' do
before do
issue1.timelogs.create!(time_spent: 3600, user: user)
load_epic_swimlanes
click_first_issue_card
end
it 'shows the total time spent only' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Spent: 1h')
expect(page).not_to have_content('Estimated')
end
end
end
context 'when only estimated time is recorded' do
before do
issue1.update!(time_estimate: 3600)
load_epic_swimlanes
click_first_issue_card
end
it 'shows the estimated time only' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Estimated: 1h')
expect(page).not_to have_content('Spent')
end
end
end
context 'when estimated and spent times are available' do
before do
issue1.update!(time_estimate: 3600)
issue1.timelogs.create!(time_spent: 1800, user: user)
load_epic_swimlanes
click_first_issue_card
end
it 'shows time tracking progress bar' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_selector('[data-testid="timeTrackingComparisonPane"]')
end
end
it 'shows both estimated and spent time text' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Spent 30m')
expect(page).to have_content('Est 1h')
end
end
end
context 'when limitedToHours instance option is turned on' do
before do
stub_application_setting(time_tracking_limit_to_hours: true)
# 3600+3600*24 = 1d 1h or 25h
issue1.timelogs.create!(time_spent: 3600 + 3600 * 24, user: user)
load_epic_swimlanes
context 'in group boards', :js do
before do
visit group_boards_path(group)
click_first_issue_card
end
wait_for_requests
it 'shows the total time spent only' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Spent: 25h')
end
end
load_epic_swimlanes
end
end
def click_first_issue_card
page.within("[data-testid='board-epic-lane-issues']") do
first("[data-testid='board_card']").click
end
it_behaves_like 'issue boards sidebar'
it_behaves_like 'issue boards sidebar EE'
end
def load_epic_swimlanes
......@@ -221,6 +54,14 @@ RSpec.describe 'epics swimlanes sidebar', :js do
page.find('.dropdown-item', text: 'Epic').click
end
wait_for_all_requests
wait_for_requests
end
def first_card
find("[data-testid='board-lane-unassigned-issues']").first("[data-testid='board_card']")
end
def first_card_with_epic
find("[data-testid='board-epic-lane-issues']").first("[data-testid='board_card']")
end
end
# frozen_string_literal: true
RSpec.shared_examples 'issue boards sidebar EE' do
context 'epic dropdown' do
let_it_be(:epic1) { create(:epic, group: group) }
let_it_be(:epic2) { create(:epic, group: group) }
let_it_be(:epic_issue, reload: true) { create(:epic_issue, epic: epic1, issue: issue) }
context 'when the issue is associated with an epic' do
before do
first_card_with_epic.click
end
it 'displays name of epic and links to it' do
page.within('[data-testid="sidebar-epic"]') do
expect(page).to have_link(epic1.title, href: epic_path(epic1))
end
end
it 'updates the epic associated with the issue' do
page.within('[data-testid="sidebar-epic"]') do
find("[data-testid='edit-button']").click
wait_for_requests
find('.gl-new-dropdown-item', text: epic2.title).click
wait_for_requests
expect(page).to have_link(epic2.title, href: epic_path(epic2))
end
end
end
end
end
......@@ -7,10 +7,10 @@ RSpec.describe 'Project issue boards sidebar', :js do
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') }
let_it_be(:issue, reload: true) { create(:issue, project: project, relative_position: 1) }
before do
project.add_maintainer(user)
......@@ -18,41 +18,17 @@ RSpec.describe 'Project issue boards sidebar', :js do
sign_in(user)
visit project_board_path(project, board)
wait_for_requests
end
it 'shows sidebar when clicking issue' do
click_card(card)
expect(page).to have_selector('.issue-boards-sidebar')
end
it 'closes sidebar when clicking issue' do
click_card(card)
expect(page).to have_selector('.issue-boards-sidebar')
click_card(card)
expect(page).not_to have_selector('.issue-boards-sidebar')
wait_for_requests
end
it 'closes sidebar when clicking close button' do
click_card(card)
it_behaves_like 'issue boards sidebar'
expect(page).to have_selector('.issue-boards-sidebar')
find("[data-testid='sidebar-drawer'] .gl-drawer-close-button").click
expect(page).not_to have_selector('.issue-boards-sidebar')
def first_card
find('.board:nth-child(1)').first("[data-testid='board_card']")
end
it 'shows issue details when sidebar is open' do
click_card(card)
page.within('.issue-boards-sidebar') do
expect(page).to have_content(issue.title)
expect(page).to have_content(issue.to_reference)
end
def click_first_issue_card
click_card(first_card)
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Project issue boards sidebar subscription', :js do
include BoardHelpers
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:issue1) { create(:issue, project: project, relative_position: 1) }
let_it_be(:issue2) { create(:issue, project: project, relative_position: 2) }
let_it_be(:subscription) { create(:subscription, user: user, project: project, subscribable: issue2, subscribed: true) }
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
stub_feature_flags(graphql_board_lists: false)
project.add_maintainer(user)
sign_in(user)
visit project_board_path(project, board)
wait_for_requests
end
context 'subscription' do
it 'changes issue subscription' do
click_card(card1)
wait_for_requests
page.within('.subscriptions') do
find('[data-testid="subscription-toggle"] button:not(.is-checked)').click
wait_for_requests
expect(page).to have_css('[data-testid="subscription-toggle"] button.is-checked')
end
end
it 'has checked subscription toggle when already subscribed' do
click_card(card2)
wait_for_requests
page.within('.subscriptions') do
find('[data-testid="subscription-toggle"] button.is-checked').click
wait_for_requests
expect(page).to have_css('[data-testid="subscription-toggle"] button:not(.is-checked)')
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Project issue boards sidebar time tracking', :js do
include BoardHelpers
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:board) { create(:board, project: project) }
let_it_be(:list) { create(:list, board: board, position: 0) }
let!(:issue) { create(:issue, project: project, relative_position: 1) }
let(:card) { find('.board:nth-child(1)').first('.board-card') }
let(:application_settings) { {} }
before do
stub_feature_flags(graphql_board_lists: false)
project.add_maintainer(user)
sign_in(user)
stub_application_setting(application_settings)
visit project_board_path(project, board)
wait_for_requests
end
context 'time tracking' do
let(:compare_meter_tooltip) { find('.time-tracking .time-tracking-content .compare-meter')['title'] }
before do
issue.timelogs.create!(time_spent: 14400, user: user)
issue.update!(time_estimate: 128800)
click_card(card)
end
it 'shows time tracking progress bar' do
expect(compare_meter_tooltip).to eq('Time remaining: 3d 7h 46m')
end
context 'when time_tracking_limit_to_hours is true' do
let(:application_settings) { { time_tracking_limit_to_hours: true } }
it 'shows time tracking progress bar' do
expect(compare_meter_tooltip).to eq('Time remaining: 31h 46m')
end
end
end
end
# frozen_string_literal: true
RSpec.shared_examples 'issue boards sidebar' do
include MobileHelpers
before do
first_card.click
end
it 'shows sidebar when clicking issue' do
expect(page).to have_selector('.issue-boards-sidebar')
end
it 'closes sidebar when clicking issue' do
expect(page).to have_selector('.issue-boards-sidebar')
first_card.click
expect(page).not_to have_selector('.issue-boards-sidebar')
end
it 'shows issue details when sidebar is open', :aggregate_failures do
page.within('.issue-boards-sidebar') do
expect(page).to have_content(issue.title)
expect(page).to have_content(issue.to_reference)
end
end
context 'when clicking close button' do
before do
find("[data-testid='sidebar-drawer'] .gl-drawer-close-button").click
end
it 'unhighlights the active issue card' do
expect(first_card[:class]).not_to include('is-active')
expect(first_card[:class]).not_to include('multi-select')
end
it 'closes sidebar when clicking close button' do
expect(page).not_to have_selector('.issue-boards-sidebar')
end
end
context 'in notifications subscription' do
it 'displays notifications toggle', :aggregate_failures do
page.within('[data-testid="sidebar-notifications"]') do
expect(page).to have_selector('[data-testid="notification-subscribe-toggle"]')
expect(page).to have_content('Notifications')
expect(page).not_to have_content('Notifications have been disabled by the project or group owner')
end
end
it 'shows toggle as on then as off as user toggles to subscribe and unsubscribe', :aggregate_failures do
toggle = find('[data-testid="notification-subscribe-toggle"]')
toggle.click
expect(toggle).to have_css("button.is-checked")
toggle.click
expect(toggle).not_to have_css("button.is-checked")
end
context 'when notifications have been disabled' do
before do
project.update_attribute(:emails_disabled, true)
refresh_and_click_first_card
end
it 'displays a message that notifications have been disabled' do
page.within('[data-testid="sidebar-notifications"]') do
expect(page).not_to have_selector('[data-testid="notification-subscribe-toggle"]')
expect(page).to have_content('Notifications have been disabled by the project or group owner')
end
end
end
end
context 'in time tracking' do
it 'displays time tracking feature with default message' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Time tracking')
expect(page).to have_content('No estimate or time spent')
end
end
context 'when only spent time is recorded' do
before do
issue.timelogs.create!(time_spent: 3600, user: user)
refresh_and_click_first_card
end
it 'shows the total time spent only' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Spent: 1h')
expect(page).not_to have_content('Estimated')
end
end
end
context 'when only estimated time is recorded' do
before do
issue.update!(time_estimate: 3600)
refresh_and_click_first_card
end
it 'shows the estimated time only', :aggregate_failures do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Estimated: 1h')
expect(page).not_to have_content('Spent')
end
end
end
context 'when estimated and spent times are available' do
before do
issue.timelogs.create!(time_spent: 1800, user: user)
issue.update!(time_estimate: 3600)
refresh_and_click_first_card
end
it 'shows time tracking progress bar' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_selector('[data-testid="timeTrackingComparisonPane"]')
end
end
it 'shows both estimated and spent time text', :aggregate_failures do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Spent 30m')
expect(page).to have_content('Est 1h')
end
end
end
context 'when limitedToHours instance option is turned on' do
before do
# 3600+3600*24 = 1d 1h or 25h
issue.timelogs.create!(time_spent: 3600 + 3600 * 24, user: user)
stub_application_setting(time_tracking_limit_to_hours: true)
refresh_and_click_first_card
end
it 'shows the total time spent only' do
page.within('[data-testid="time-tracker"]') do
expect(page).to have_content('Spent: 25h')
end
end
end
end
def refresh_and_click_first_card
page.refresh
wait_for_requests
first_card.click
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