Rewrite removed frontend tests with feature specs (#4350)

This PR adds two feature specs:

Replacement for work-packages-modal-focus-spec.js
Replacement for parent-relations-handler-spec.js
The remainig tests removed with #4346 are already covered as follows:

activity-with-revisions-spec.js (covered by activity_comments_spec.rb)
details-pane-editable-spec.js (covered by edit_work_package_spec.rb)
details-pane-show-hide-accessibility-spec.js (obsolete)
details-pane-spec.js (covered by several feature specs)
pull/4355/head
Oliver Günther 9 years ago
parent 23ac3192ff
commit 21842335ac
  1. 2
      features/work_packages/editable_fields.feature
  2. 5
      frontend/app/templates/work_packages/tabs/_work_package_relations.html
  3. 18
      frontend/app/templates/work_packages/tabs/relations.html
  4. 3
      frontend/app/work_packages/tabs/work-package-relations-directive.js
  5. 6
      frontend/tests/unit/tests/work_packages/directives/work-package-relations-directive-test.js
  6. 59
      spec/features/work_packages/details/details_relations_spec.rb
  7. 0
      spec/features/work_packages/table/create_work_packages_spec.rb
  8. 0
      spec/features/work_packages/table/edit_work_packages_spec.rb
  9. 53
      spec/features/work_packages/table/modal_focus_spec.rb
  10. 2
      spec/support/pages/abstract_work_package.rb

@ -84,7 +84,7 @@ Feature: Fields editable on work package edit
When I click on "Relations"
Then I should see "parentpe" within ".relation[title='Parent']"
Then I should see "parentpe" within ".relation.parent"
@javascript
Scenario: Going to the page and viewing custom field fields

@ -1,6 +1,7 @@
<div class="relation">
<div ng-class="['relation', relationType]">
<h3>
<accessible-by-keyboard execute="toggleExpand()">
<accessible-by-keyboard execute="toggleExpand()"
link-class="{{ relationType }}-toggle-link">
<i class="icon-pull-content" ng-class="stateClass"></i> {{ title }}
<span ng-if="!handler.isSingletonRelation">({{ handler.getCount() }})</span>
</accessible-by-keyboard>

@ -1,54 +1,54 @@
<div class="detail-panel-description">
<div class="detail-panel-description-content">
<work-package-relations title="{{ I18n.t('js.relation_labels.parent') }}"
<work-package-relations relation-type="parent"
handler="wpParent"
button-title="{{ I18n.t('js.relation_buttons.change_parent') }}"
button-icon="<i class='icon-hierarchy icon-edit'></i>">
</work-package-relations>
<work-package-relations title="{{ I18n.t('js.relation_labels.children') }}"
<work-package-relations relation-type="children"
handler="wpChildren"
button-title="{{ I18n.t('js.relation_buttons.add_child') }}"
button-icon="<i class='icon-hierarchy icon-add'></i>">
</work-package-relations>
<work-package-relations title="{{ I18n.t('js.relation_labels.relates') }}"
<work-package-relations relation-type="relates"
handler="relatedTo"
button-title="{{ I18n.t('js.relation_buttons.add_related_to') }}"
button-icon="<i class='icon-hierarchy icon-add'></i>">
</work-package-relations>
<work-package-relations title="{{ I18n.t('js.relation_labels.duplicates') }}"
<work-package-relations relation-type="duplicates"
handler="duplicates"
button-title="{{ I18n.t('js.relation_buttons.add_duplicates') }}"
button-icon="<i class='icon-hierarchy icon-add'></i>">
</work-package-relations>
<work-package-relations title="{{ I18n.t('js.relation_labels.duplicated') }}"
<work-package-relations relation-type="duplicated"
handler="duplicated"
button-title="{{ I18n.t('js.relation_buttons.add_duplicated_by') }}"
button-icon="<i class='icon-hierarchy icon-add'></i>">
</work-package-relations>
<work-package-relations title="{{ I18n.t('js.relation_labels.blocks') }}"
<work-package-relations relation-type="blocks"
handler="blocks"
button-title="{{ I18n.t('js.relation_buttons.add_blocks') }}"
button-icon="<i class='icon-hierarchy icon-add'></i>">
</work-package-relations>
<work-package-relations title="{{ I18n.t('js.relation_labels.blocked') }}"
<work-package-relations relation-type="blocked"
handler="blocked"
button-title="{{ I18n.t('js.relation_buttons.add_blocked_by') }}"
button-icon="<i class='icon-hierarchy icon-add'></i>">
</work-package-relations>
<work-package-relations title="{{ I18n.t('js.relation_labels.precedes') }}"
<work-package-relations relation-type="precedes"
handler="precedes"
button-title="{{ I18n.t('js.relation_buttons.add_precedes') }}"
button-icon="<i class='icon-hierarchy icon-add'></i>">
</work-package-relations>
<work-package-relations title="{{ I18n.t('js.relation_labels.follows') }}"
<work-package-relations relation-type="follows"
handler="follows"
button-title="{{ I18n.t('js.relation_buttons.add_follows') }}"
button-icon="<i class='icon-hierarchy icon-add'></i>">

@ -31,7 +31,7 @@ module.exports = function(I18n, WorkPackagesHelper, $timeout) {
restrict: 'E',
replace: true,
scope: {
title: '@',
relationType: '@',
handler: '=',
btnTitle: '@buttonTitle',
btnIcon: '@buttonIcon',
@ -41,6 +41,7 @@ module.exports = function(I18n, WorkPackagesHelper, $timeout) {
link: function(scope, element, attrs) {
scope.I18n = I18n;
scope.focusElementIndex = -2;
scope.title = I18n.t('js.relation_labels.' + scope.relationType)
var setExpandState = function() {
scope.expand = !scope.handler.isEmpty();

@ -78,13 +78,15 @@ describe('Work Package Relations Directive', function() {
stub.withArgs('js.work_packages.properties.status').returns('Column1');
stub.withArgs('js.work_packages.properties.assignee').returns('Column2');
stub.withArgs('js.relations.remove').returns('Remove relation');
stub.withArgs('js.relation_labels.parent').returns('Parent');
}));
afterEach(function() {
I18n.t.restore();
});
var html = "<work-package-relations title='MyRelation' handler='relations' button-title='Add Relation' button-icon='%MyIcon%'></work-package-relations>";
var html = "<work-package-relations relation-type='parent' handler='relations' " +
"button-title='Add Relation' button-icon='%MyIcon%'></work-package-relations>";
var workPackage1;
var workPackage2;
@ -263,7 +265,7 @@ describe('Work Package Relations Directive', function() {
it('should have a title', function() {
var title = angular.element(element.find('h3'));
expect(title.text()).to.include('MyRelation');
expect(title.text()).to.include('Parent');
});
};

@ -0,0 +1,59 @@
require 'spec_helper'
describe 'Work package relations tab', js: true, selenium: true do
let(:user) { FactoryGirl.create :admin }
let(:work_package) { FactoryGirl.create(:work_package) }
let(:work_packages_page) { ::Pages::SplitWorkPackage.new(work_package) }
before do
login_as user
work_packages_page.visit_tab!('relations')
loading_indicator_saveguard
work_packages_page.expect_subject
end
describe 'no relations' do
it 'shows empty relation tabs' do
%w(parent children relates duplicates
duplicated blocks blocked precedes follows).each do |rel|
within ".relation.#{rel}" do
find(".#{rel}-toggle-link").click
expect(page).to have_selector('.content', text: 'No relation exists')
end
end
end
end
describe 'with parent' do
let(:parent) { FactoryGirl.create(:work_package) }
let(:work_package) { FactoryGirl.create(:work_package, parent: parent) }
it 'shows the parent relationship expanded' do
within '.relation.parent' do
expect(page).to have_selector('.content', text: "##{parent.id} #{parent.subject}")
end
end
end
describe 'create parent relationship' do
let(:parent) { FactoryGirl.create(:work_package) }
let(:work_package) { FactoryGirl.create(:work_package) }
include_context 'ui-select helpers'
it 'shows the parent relationship expanded' do
within '.relation.parent' do
# Expand parent
find('.parent-toggle-link').click
form = find('.choice--select')
ui_select_choose(form, parent.id)
click_button 'Change parent'
expect(page).to have_selector('.content', text: "##{parent.id} #{parent.subject}")
end
end
end
end

@ -0,0 +1,53 @@
require 'spec_helper'
describe 'Modal focus in work package table', js: true do
let(:user) { FactoryGirl.create :admin }
let!(:project) { FactoryGirl.create(:project) }
let!(:work_package) { FactoryGirl.create(:work_package, project: project) }
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }
before do
login_as user
wp_table.visit!
loading_indicator_saveguard
find('#work-packages-settings-button').click
end
describe 'columns' do
it 'sets the focus in the colum selection' do
within '#settingsDropdown' do
click_link 'Columns'
end
loading_indicator_saveguard
expect(page).to have_selector('.ng-modal-window h3', text: 'Columns')
expect(page).to have_focus_on('#selected_columns .select2-input')
end
end
describe 'sorting' do
it 'sets the focus in the sort selection' do
within '#settingsDropdown' do
click_link 'Sort by'
end
loading_indicator_saveguard
expect(page).to have_selector('.ng-modal-window h3', text: 'Sorting')
expect(page).to have_focus_on('#modal-sorting-attribute-0')
end
end
describe 'group by' do
it 'sets the focus in the sort selection' do
within '#settingsDropdown' do
click_link 'Group by'
end
loading_indicator_saveguard
expect(page).to have_selector('.ng-modal-window h3', text: 'Group by')
expect(page).to have_focus_on('#selected_columns_new')
end
end
end

@ -84,7 +84,7 @@ module Pages
visit_tab!('relations')
expect(page).to have_selector(".relation[title=#{I18n.t('js.relation_labels.parent')}] a",
expect(page).to have_selector('.relation.parent .content',
text: "##{parent.id} #{parent.subject}")
end

Loading…
Cancel
Save