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/menu_items/top_menu_item_spec.rb

149 lines
4.4 KiB

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
#
# 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-2013 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 COPYRIGHT and LICENSE files for more details.
#++
require 'spec_helper'
feature 'Top menu items', js: true, selenium: true do
let(:user) { FactoryBot.create :user }
let(:open_menu) { true }
def has_menu_items?(*labels)
Refactor/app header (#9110) * [35527] Add quick add button menu in top menu * Add quick menu item to top menu * Refactor top_menu.sass to follow BEM * Only render project-based path if persisted * Render project types when in project context * Add headline and determine if any types are visible * Hide quick add menu for unauthorized users * Fix login menu dropdown by adding class * Add schematic for correctly generating components * Add augment service for triggering invite user modal * Fix allowed_to? check in menu * Add spec * Highlight types and show all * Fix help menu overridden * Extend spec * Add parent_id to project in dropdown and expand advanced settings * Reload the page if the modal returned any data * Fix invalid url allowed check if there is no URL to check * Basic BEM changes * Remove old classes * Update more classes * Update togling logic * Fixed menu opening and some styles * Added op-menu * Fix some help menu styles * Add op-menu to help menug * Add avatar border * Fix auth_provider_spec * Fix zen mode * Fix static link help menu * Fixed top menu specs * Fix self registration specs * Fix logout spec * Fix bim revit navigation spec * Fixed menu permissions spec * Fix homescreen onboarding tour spec * Fix top menu item spec * Remove unused file * Fix a lot of mobile styles * Fix more mobile styles * Fixed build * Move quick add menu to right hand side * Improve quick-add-button styles, fix main-menu-toggle close icon * Remove add new project spec * Fix spec * Update project dropdown styles * Fix click handler for chrome mobile, update some styles Co-authored-by: Oliver Günther <mail@oliverguenther.de>
4 years ago
within '.op-app-header' do
labels.each do |l|
expect(page).to have_link(l)
end
(all_items - labels).each do |l|
expect(page).not_to have_link(l)
end
end
end
def click_link_in_open_menu(title)
# if the menu is not completely expanded (e.g. if the frontend thread is too fast),
# the click might be ignored
Refactor/app header (#9110) * [35527] Add quick add button menu in top menu * Add quick menu item to top menu * Refactor top_menu.sass to follow BEM * Only render project-based path if persisted * Render project types when in project context * Add headline and determine if any types are visible * Hide quick add menu for unauthorized users * Fix login menu dropdown by adding class * Add schematic for correctly generating components * Add augment service for triggering invite user modal * Fix allowed_to? check in menu * Add spec * Highlight types and show all * Fix help menu overridden * Extend spec * Add parent_id to project in dropdown and expand advanced settings * Reload the page if the modal returned any data * Fix invalid url allowed check if there is no URL to check * Basic BEM changes * Remove old classes * Update more classes * Update togling logic * Fixed menu opening and some styles * Added op-menu * Fix some help menu styles * Add op-menu to help menug * Add avatar border * Fix auth_provider_spec * Fix zen mode * Fix static link help menu * Fixed top menu specs * Fix self registration specs * Fix logout spec * Fix bim revit navigation spec * Fixed menu permissions spec * Fix homescreen onboarding tour spec * Fix top menu item spec * Remove unused file * Fix a lot of mobile styles * Fix more mobile styles * Fixed build * Move quick add menu to right hand side * Improve quick-add-button styles, fix main-menu-toggle close icon * Remove add new project spec * Fix spec * Update project dropdown styles * Fix click handler for chrome mobile, update some styles Co-authored-by: Oliver Günther <mail@oliverguenther.de>
4 years ago
within '.op-app-menu--dropdown[aria-expanded=true]' do
expect(page).not_to have_selector('[style~=overflow]')
page.find_link(title).find('span').click
end
end
before do |ex|
allow(User).to receive(:current).and_return user
FactoryBot.create(:anonymous_role)
FactoryBot.create(:non_member)
if ex.metadata.key?(:allowed_to)
allow(user).to receive(:allowed_to?).and_return(ex.metadata[:allowed_to])
end
visit root_path
top_menu.click if open_menu
end
describe 'Modules' do
!let(:top_menu) { find(:css, "[title=#{I18n.t('label_modules')}]") }
let(:news_item) { I18n.t('label_news_plural') }
let(:project_item) { I18n.t('label_projects_menu') }
let(:reporting_item) { I18n.t('cost_reports_title') }
Feature/remove timelog (#8557) * rename costs, introduce budgets * move files from costs to budgets * rename cost_object to budget * remove unused code * move hook - should be turned into standard code in the long run * move type attributes change over to budgets * move patch to work_package proper * move budget menu item up * combine reporting, time and cost module * remove rails based time_entries & reports code * rename cost object filter * adapt menu spec expectations * use cost project module name in administration * include timeline labels in migration * properly place budget linking method * fix permitted params * remove outdated routing spec * adapt budget request specs * ensure order of descendent updates * remove outdated specs * fix checking for reporting to be enabled * fix displaying spent units * fix time entries activity event url * reenable current rate tab * fix path on budget page * allow bulk editing of budgets only in one project scenario * fix sanitizing reference in controller * include module required for format_date * fix reference to correct units from work package spent units * linting * remove outdated spec * remove outdated views and permission references * remove acts_as_event from time_entries There is no atom link for time entries * remove acts_as_event from projects There are no atom links for projects * introduce budget filter for cost reports * remove actions added to removed controller * move time entries to the costs module * factor in view_own permission when calculating time entry visibility * linting * move mounting of time entries * include budgets into api v3 documentation
4 years ago
let(:all_items) { [news_item, project_item, reporting_item] }
context 'as an admin' do
let(:user) { FactoryBot.create :admin }
it 'displays all items' do
has_menu_items?(reporting_item, news_item, project_item)
end
it 'visits the news page' do
click_link_in_open_menu(news_item)
expect(page).to have_current_path(news_index_path)
end
end
context 'as a regular user' do
it 'displays news and projects only' do
has_menu_items? news_item, project_item
end
end
context 'as a user with permissions', allowed_to: true do
it 'displays all options' do
has_menu_items?(reporting_item, news_item, project_item)
end
end
context 'as an anonymous user' do
let(:user) { FactoryBot.create :anonymous }
it 'displays only news and projects' do
has_menu_items? news_item, project_item
end
end
end
describe 'Projects' do
let(:top_menu) { find(:css, '#projects-menu') }
let(:all_projects) { I18n.t(:label_project_view_all) }
Refactor/app header (#9110) * [35527] Add quick add button menu in top menu * Add quick menu item to top menu * Refactor top_menu.sass to follow BEM * Only render project-based path if persisted * Render project types when in project context * Add headline and determine if any types are visible * Hide quick add menu for unauthorized users * Fix login menu dropdown by adding class * Add schematic for correctly generating components * Add augment service for triggering invite user modal * Fix allowed_to? check in menu * Add spec * Highlight types and show all * Fix help menu overridden * Extend spec * Add parent_id to project in dropdown and expand advanced settings * Reload the page if the modal returned any data * Fix invalid url allowed check if there is no URL to check * Basic BEM changes * Remove old classes * Update more classes * Update togling logic * Fixed menu opening and some styles * Added op-menu * Fix some help menu styles * Add op-menu to help menug * Add avatar border * Fix auth_provider_spec * Fix zen mode * Fix static link help menu * Fixed top menu specs * Fix self registration specs * Fix logout spec * Fix bim revit navigation spec * Fixed menu permissions spec * Fix homescreen onboarding tour spec * Fix top menu item spec * Remove unused file * Fix a lot of mobile styles * Fix more mobile styles * Fixed build * Move quick add menu to right hand side * Improve quick-add-button styles, fix main-menu-toggle close icon * Remove add new project spec * Fix spec * Update project dropdown styles * Fix click handler for chrome mobile, update some styles Co-authored-by: Oliver Günther <mail@oliverguenther.de>
4 years ago
let(:all_items) { [all_projects] }
context 'as an admin' do
let(:user) { FactoryBot.create :admin }
it 'displays all items' do
Refactor/app header (#9110) * [35527] Add quick add button menu in top menu * Add quick menu item to top menu * Refactor top_menu.sass to follow BEM * Only render project-based path if persisted * Render project types when in project context * Add headline and determine if any types are visible * Hide quick add menu for unauthorized users * Fix login menu dropdown by adding class * Add schematic for correctly generating components * Add augment service for triggering invite user modal * Fix allowed_to? check in menu * Add spec * Highlight types and show all * Fix help menu overridden * Extend spec * Add parent_id to project in dropdown and expand advanced settings * Reload the page if the modal returned any data * Fix invalid url allowed check if there is no URL to check * Basic BEM changes * Remove old classes * Update more classes * Update togling logic * Fixed menu opening and some styles * Added op-menu * Fix some help menu styles * Add op-menu to help menug * Add avatar border * Fix auth_provider_spec * Fix zen mode * Fix static link help menu * Fixed top menu specs * Fix self registration specs * Fix logout spec * Fix bim revit navigation spec * Fixed menu permissions spec * Fix homescreen onboarding tour spec * Fix top menu item spec * Remove unused file * Fix a lot of mobile styles * Fix more mobile styles * Fixed build * Move quick add menu to right hand side * Improve quick-add-button styles, fix main-menu-toggle close icon * Remove add new project spec * Fix spec * Update project dropdown styles * Fix click handler for chrome mobile, update some styles Co-authored-by: Oliver Günther <mail@oliverguenther.de>
4 years ago
has_menu_items?(all_projects)
end
it 'visits the projects page' do
click_link_in_open_menu(all_projects)
expect(page).to have_current_path(projects_path)
end
end
context 'as a user without project permission' do
before do
Role.non_member.update_attribute :permissions, [:view_project]
end
it 'does not display new_project' do
has_menu_items? all_projects
end
end
context 'as an anonymous user' do
let(:user) { FactoryBot.create :anonymous }
let(:open_menu) { false }
it 'does not show the menu' do
expect(page).to have_no_selector('#projects-menu')
end
end
end
end