OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/spec/features/calendars/calendars_spec.rb

197 lines
7.7 KiB

Feature/angular calendar (#6766) * replace rails based calendar with angular * render empty calendar * update query on month switch * introduce specific interval filter * show colors * remove now unused filter partial * start on retaining the view in the url * hide datesInterval filter * I18n for calendars title * stengthen explicity of expected filters * spec moving to the next month * fix FilterSerializer reference * remove outdated feature spec * rework calendar controller specs * avoid undefined columns * bump ng-calendar to 1.7.0 * Revert "fix FilterSerializer reference" This reverts commit 2bb2e574cdd664a02a4eb9c3e94b5a170aec0a67. * Revert "avoid undefined columns" This reverts commit bcbb381b34b095526d3ee1aa15d6263a658c03c0. * load initial query only after calendar has been loaded * implement month remembering * implement history back and forth * cleanup code * remove unused methods * remove order value from filters * replace rails calendar widget completely * fix shrinkwrap * move module into correct namespace * linting * remove unused js * calculate full calendar height dynamically * setting calendar locale from service * retain week on reload * show notification in case of too many results * show tooltip on hover * go to work package on click * deactivate tooltip before wp show * narrow down style to tooltip * [28885] Improve html title consistency when navigating to queries Currently, query names are not reflected in the HTML title. This results in 'wrong' titles being shown when entering a split or full view and then returning back to the list. https://community.openproject.com/wp/28885 [ci skip]
6 years ago
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe 'Work package calendars', type: :feature, js: true do
let(:project) { FactoryBot.create(:project) }
let(:user) do
FactoryBot.create(:user,
member_in_project: project,
member_with_permissions: %i[view_work_packages view_calendar])
end
let!(:current_work_package) do
FactoryBot.create(:work_package,
subject: 'Current work package',
project: project,
start_date: Date.today.at_beginning_of_month + 15.days,
due_date: Date.today.at_beginning_of_month + 15.days)
end
let!(:another_current_work_package) do
FactoryBot.create(:work_package,
subject: 'Another current work package',
project: project,
start_date: Date.today.at_beginning_of_month + 12.days,
due_date: Date.today.at_beginning_of_month + 18.days)
end
let!(:future_work_package) do
FactoryBot.create(:work_package,
subject: 'Future work package',
project: project,
start_date: Date.today.at_beginning_of_month.next_month + 15.days,
due_date: Date.today.at_beginning_of_month.next_month + 15.days)
end
let!(:another_future_work_package) do
FactoryBot.create(:work_package,
subject: 'Another future work package',
project: project,
start_date: Date.today.at_beginning_of_month.next_month + 12.days,
due_date: Date.today.at_beginning_of_month.next_month + 18.days)
end
let(:filters) { ::Components::WorkPackages::Filters.new }
before do
login_as(user)
end
it 'navigates to today, allows filtering, switching the view and retrains the state' do
visit project_path(project)
within '#main-menu' do
click_link 'Calendar'
end
# should open the calendar with the current month displayed
expect(page)
.to have_selector '.fc-event-container', text: current_work_package.subject
expect(page)
.to have_selector '.fc-event-container', text: another_current_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: future_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: another_future_work_package.subject
filters.open
# The filter for the time frame added implicitly should not be visible
filters.expect_no_filter_by('Dates interval', 'datesInterval')
filters.expect_filter_count 1
# The user can filter by e.g. the subject filter
filters.add_filter_by 'Subject', 'contains', ['Another']
# non matching work packages are no longer displayed
expect(page)
.to have_no_selector '.fc-event-container', text: current_work_package.subject
expect(page)
.to have_selector '.fc-event-container', text: another_current_work_package.subject
# The filter for the time frame added implicitly should not be visible
filters.expect_filter_count 2
# navigate to the next month
find('.fc-left button.fc-next-button').click
expect(page)
.to have_no_selector '.fc-event-container', text: current_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: another_current_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: future_work_package.subject
expect(page)
.to have_selector '.fc-event-container', text: another_future_work_package.subject
# removing the filter will show the event again
filters.remove_filter 'subject'
expect(page)
.to have_no_selector '.fc-event-container', text: current_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: another_current_work_package.subject
expect(page)
.to have_selector '.fc-event-container', text: future_work_package.subject
expect(page)
.to have_selector '.fc-event-container', text: another_future_work_package.subject
future_url = current_url
# navigate back a month
find('.fc-left button.fc-prev-button').click
expect(page)
.to have_selector '.fc-event-container', text: current_work_package.subject
expect(page)
.to have_selector '.fc-event-container', text: another_current_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: future_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: another_future_work_package.subject
# open the page via the url should show the next month again
visit future_url
expect(page)
.to have_no_selector '.fc-event-container', text: current_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: another_current_work_package.subject
expect(page)
.to have_selector '.fc-event-container', text: future_work_package.subject
expect(page)
.to have_selector '.fc-event-container', text: another_future_work_package.subject
# go back a month by using the browser back functionality
page.execute_script('window.history.back()')
expect(page)
.to have_selector '.fc-event-container', text: current_work_package.subject
expect(page)
.to have_selector '.fc-event-container', text: another_current_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: future_work_package.subject
expect(page)
.to have_no_selector '.fc-event-container', text: another_future_work_package.subject
# click goes to work package show page
page.find('.fc-event-container', text: current_work_package.subject).click
expect(page)
.to have_selector('.subject-header', text: current_work_package.subject)
# Going back in browser history will lead us back to the calendar
# Regression #29664
page.go_back
# click goes to work package show page
expect(page)
.to have_selector('.fc-event-container', text: current_work_package.subject, wait: 20)
# click goes to work package show page again
page.find('.fc-event-container', text: current_work_package.subject).click
expect(page)
.to have_selector('.subject-header', text: current_work_package.subject)
# click back goes back to calendar
page.find('.work-packages-back-button').click
expect(page)
.to have_selector '.fc-event-container', text: current_work_package.subject, wait: 20
Feature/angular calendar (#6766) * replace rails based calendar with angular * render empty calendar * update query on month switch * introduce specific interval filter * show colors * remove now unused filter partial * start on retaining the view in the url * hide datesInterval filter * I18n for calendars title * stengthen explicity of expected filters * spec moving to the next month * fix FilterSerializer reference * remove outdated feature spec * rework calendar controller specs * avoid undefined columns * bump ng-calendar to 1.7.0 * Revert "fix FilterSerializer reference" This reverts commit 2bb2e574cdd664a02a4eb9c3e94b5a170aec0a67. * Revert "avoid undefined columns" This reverts commit bcbb381b34b095526d3ee1aa15d6263a658c03c0. * load initial query only after calendar has been loaded * implement month remembering * implement history back and forth * cleanup code * remove unused methods * remove order value from filters * replace rails calendar widget completely * fix shrinkwrap * move module into correct namespace * linting * remove unused js * calculate full calendar height dynamically * setting calendar locale from service * retain week on reload * show notification in case of too many results * show tooltip on hover * go to work package on click * deactivate tooltip before wp show * narrow down style to tooltip * [28885] Improve html title consistency when navigating to queries Currently, query names are not reflected in the HTML title. This results in 'wrong' titles being shown when entering a split or full view and then returning back to the list. https://community.openproject.com/wp/28885 [ci skip]
6 years ago
end
end