adapt feature specs

This commit is contained in:
Jens Ulferts
2018-12-07 08:26:43 +01:00
parent de2735f797
commit 3a63506b2d
2 changed files with 32 additions and 113 deletions
@@ -33,6 +33,23 @@ describe 'Assigned to me embedded query on my page', type: :feature, js: true do
let!(:priority) { FactoryBot.create :default_priority }
let!(:project) { FactoryBot.create :project, types: [type] }
let!(:open_status) { FactoryBot.create :default_status }
let!(:assigned_work_package) do
FactoryBot.create :work_package,
project: project,
type: type,
author: user,
assigned_to: user
end
let!(:assigned_to_other_work_package) do
FactoryBot.create :work_package,
project: project,
type: type,
author: user,
assigned_to: other_user
end
let(:other_user) do
FactoryBot.create(:user)
end
let(:role) { FactoryBot.create(:role, permissions: %i[view_work_packages add_work_packages]) }
@@ -41,16 +58,28 @@ describe 'Assigned to me embedded query on my page', type: :feature, js: true do
member_in_project: project,
member_through_role: role)
end
let(:my_page) do
Pages::My::Page.new
end
before do
login_as user
visit my_page_path
my_page.visit!
end
it 'can create a new ticket with correct me values (Regression test #28488)' do
expect(page).to have_selector('.widget-box--header-title', text: 'Work packages assigned to me')
# exists as default
assigned_area = Components::Grids::GridArea.new('.grid--area', text: 'Work packages assigned to me')
assigned_area.expect_to_exist
embedded_table = Pages::EmbeddedWorkPackagesTable.new(find('#left'))
expect(assigned_area.area)
.to have_selector('.subject', text: assigned_work_package.subject)
expect(assigned_area.area)
.to have_no_selector('.subject', text: assigned_to_other_work_package.subject)
embedded_table = Pages::EmbeddedWorkPackagesTable.new(assigned_area.area)
embedded_table.click_inline_create
subject_field = embedded_table.edit_field(nil, :subject)
@@ -59,7 +88,6 @@ describe 'Assigned to me embedded query on my page', type: :feature, js: true do
subject_field.set_value 'Assigned to me'
subject_field.save!
# Set project
project_field = embedded_table.edit_field(nil, :project)
project_field.expect_active!
-109
View File
@@ -1,109 +0,0 @@
#-- 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 'Blocks on the my page', type: :feature, js: true do
let(:project) { FactoryBot.create :project }
let(:open_status) { FactoryBot.create :default_status }
let(:closed_status) { FactoryBot.create :closed_status }
let!(:open_wp) { FactoryBot.create(:work_package, project: project, status: open_status) }
let!(:closed_wp) { FactoryBot.create(:work_package, project: project, status: closed_status) }
let!(:unwatched_wp) { FactoryBot.create(:work_package, project: project, status: open_status) }
let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) }
let(:layout) do
{ 'top' => ['issueswatched'], 'left' => [], 'right' => [] }
end
let(:user) do
FactoryBot.create(:user,
member_in_project: project,
member_through_role: role,
firstname: 'Mahboobeh').tap do |u|
u.pref[:my_page_layout] = layout
u.pref.save!
end
end
before do
Watcher.create(watchable: open_wp, user: user)
Watcher.create(watchable: closed_wp, user: user)
login_as user
visit my_page_path
end
scenario 'viewing and modifying the blocks' do
# displays only the open and watched work packages for the watched block
expect(page)
.to have_selector('#top .wp-table--cell-td.subject', text: open_wp.subject)
expect(page)
.to have_no_selector('#top .wp-table--cell-td.subject', text: closed_wp.subject)
expect(page)
.to have_no_selector('#top .wp-table--cell-td.subject', text: unwatched_wp.subject)
# Go to page layout
find('.my-page--personalize-button').click
# Add a block
select 'Calendar', from: 'block-options'
click_on 'Add'
# Expect block disabled
expect(page).to have_selector('#block-options option[value=calendar][disabled]')
within '#top' do
expect(page).to have_selector('#block-calendar')
end
# Add another block
select 'Latest news', from: 'block-options'
click_on 'Add'
expect(page).to have_selector('#block-options option[value=news][disabled]')
within '#top' do
expect(page).to have_selector('#block-news')
end
# Remove a block
within '#block-calendar' do
find('.my-page--remove-block').click
end
# Expect block reenabled
expect(page).to have_selector('#block-options option[value=calendar]')
expect(page).to have_no_selector('#block-options option[value=calendar][disabled]')
within '#top' do
expect(page).to have_no_selector('#block-calendar')
end
end
end