Add spec for group-by headers

pull/4655/head
Oliver Günther 8 years ago
parent b278564f28
commit 19b30f4b2b
  1. 56
      spec/features/work_packages/table/group_headers_spec.rb
  2. 5
      spec/support/pages/work_packages_table.rb

@ -0,0 +1,56 @@
require 'spec_helper'
describe 'Work Package table group headers', js: true do
let(:user) { FactoryGirl.create :admin }
let(:project) { FactoryGirl.create(:project) }
let(:category) { FactoryGirl.create :category, project: project, name: 'Foo' }
let(:category2) { FactoryGirl.create :category, project: project, name: 'Bar' }
let!(:wp_cat1) { FactoryGirl.create(:work_package, project: project, category: category) }
let!(:wp_cat2) { FactoryGirl.create(:work_package, project: project, category: category2) }
let!(:wp_none) { FactoryGirl.create(:work_package, project: project) }
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
let!(:query) do
query = FactoryGirl.build(:query, user: user, project: project)
query.column_names = ['subject', 'category']
query.save!
query
end
before do
login_as(user)
wp_table.visit_query(query)
wp_table.expect_work_package_listed(wp_cat1)
wp_table.expect_work_package_listed(wp_cat2)
wp_table.expect_work_package_listed(wp_none)
end
it 'shows group headers for group by category' do
# Group by category
wp_table.click_setting_item 'Group by ...'
select 'Category', from: 'selected_columns_new'
click_button 'Apply'
# Expect table to be grouped as WP created above
expect(page).to have_selector('tr.group .count', count: 3)
expect(page).to have_selector('tr.group div', text: 'Foo (1)')
expect(page).to have_selector('tr.group div', text: 'Bar (1)')
expect(page).to have_selector('tr.group div', text: '- (1)')
# Update category of wp_none
cat = wp_table.edit_field(wp_none, :category)
cat.activate!
cat.set_value 'Foo'
loading_indicator_saveguard
# Expect changed groups
expect(page).to have_selector('tr.group .count', count: 2)
expect(page).to have_selector('tr.group div', text: 'Foo (2)')
expect(page).to have_selector('tr.group div', text: 'Bar (1)')
end
end

@ -130,6 +130,11 @@ module Pages
WorkPackageField.new(context, attribute)
end
def click_setting_item(label)
find('#work-packages-settings-button').click
find('#settingsDropdown .menu-item', text: label).click
end
def open_filter_section
unless page.has_selector?('#work-packages-filter-toggle-button.-active')
click_button('work-packages-filter-toggle-button')

Loading…
Cancel
Save