Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Apr 10, 2018
1 parent 37910f9 commit cf80ddc
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</span>

<op-date-picker (onChange)="end = parser($event)">
<input [ngModel]="end"
<input [ngModel]="formatter(end)"
(ngModelChange)="end = parser($event)"
[disabled]="isLoading"
required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
id="values-{{filter.id}}"
name="v[{{filter.id}}][]"
class="advanced-filters--select">
<option disabled
[ngValue]="null"
<option [ngValue]="null"
[textContent]="text.placeholder"
disabled
selected
*ngIf="hasNoValue"></option>
<option *ngFor="let value of availableOptions"
[textContent]="value.name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ export class FilterToggledMultiselectValueComponent implements OnInit {
public get value() {
if (this.isValueMulti()) {
return this.filter.values;
} else {
} else if (this.filter.values.length > 0) {
return this.filter.values[0];
} else {
return null;
}
}

Expand All @@ -92,10 +94,6 @@ export class FilterToggledMultiselectValueComponent implements OnInit {
return _.isEmpty(this.filter.values);
}

private setAvailableOptions(options:CollectionResource) {
this.availableOptions = options.elements;
}

private fetchAllowedValues() {
if ((this.filter.currentSchema!.values!.allowedValues as CollectionResource)['$load']) {
this.loadAllowedValues();
Expand Down
29 changes: 7 additions & 22 deletions spec/features/work_packages/indem_sums_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
}

let(:wp_table) { Pages::WorkPackagesTable.new(project) }
let(:columns) { ::Components::WorkPackages::Columns.new }
let(:modal) { ::Components::WorkPackages::TableConfigurationModal.new }

before do
login_as(admin)
Expand All @@ -52,32 +54,15 @@
end

scenario 'calculates summs correctly' do
expect(page).to have_content('Work packages')
wp_table.expect_work_package_listed work_package_1, work_package_2

within('.work-packages-list-view--container') do
expect(page).to have_content(work_package_1.subject)
expect(page).to have_content(work_package_2.subject)
end

# name of the settings dropdown menu
dropdown_id = 'settings'
# Add estimated time column
columns.add 'Estimated time'

# Trigger action from action menu dropdown
find("#work-packages-settings-button").click
find("##{dropdown_id}Dropdown").click_link 'Columns'

within('.ng-modal-inner') do
find('input.select2-input').click

s2_result = find('ul.select2-result-single li', text: 'Estimated time')
s2_result.click
modal.set_display_sums enable: true

click_on 'Apply'
end

# Trigger action from action menu dropdown
find("#work-packages-settings-button").click
find("##{dropdown_id}Dropdown").click_link 'Display sums'
wp_table.expect_work_package_listed work_package_1, work_package_2

within('.sum.group.all') do
expect(page).to have_content('Sum for all work packages')
Expand Down
3 changes: 2 additions & 1 deletion spec/features/work_packages/table/invalid_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }
let(:filters) { ::Components::WorkPackages::Filters.new }
let(:group_by) { ::Components::WorkPackages::GroupBy.new }

let(:member) do
FactoryGirl.create(:member,
Expand Down Expand Up @@ -96,7 +97,7 @@
filters.expect_filter_by('Assignee', 'is', I18n.t('js.placeholders.selection'))
filters.expect_filter_by('Status', 'is', [status.name, status2.name])

wp_table.group_by('Assignee')
group_by.enable_via_menu('Assignee')
sleep(0.3)
filters.set_filter('Assignee', 'is', user.name)
sleep(0.3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
let(:query_menu) { Components::WorkPackages::QueryMenu.new }
let(:wp_timeline) { Pages::WorkPackagesTimeline.new(project) }
let(:settings_menu) { Components::WorkPackages::SettingsMenu.new }
let(:group_by) { Components::WorkPackages::GroupBy.new }

let(:work_package) do
FactoryGirl.create :work_package,
Expand Down Expand Up @@ -231,9 +232,7 @@
wp_table.visit_query(query)
wp_table.expect_work_package_listed(wp_cat1, wp_cat2, wp_none)

wp_table.click_setting_item 'Group by ...'
select 'Category', from: 'selected_columns_new'
click_button 'Apply'
group_by.enable_via_menu 'Category'

# Expect table to be grouped as WP created above
expect(page).to have_selector('.group--value .count', count: 3)
Expand Down
4 changes: 1 addition & 3 deletions spec/support/components/work_packages/columns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ def expect_column_not_available(name)
modal_open? or open_modal

within_modal do
page.find('#selected_columns').click

expect(page)
.to have_no_selector('li[role=option]', text: name)
.to have_no_selector('.form--check-box-container', text: name)
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/support/components/work_packages/filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def set_value(id, value)
select value, from: "values-#{id}"
else
page.all('input').each_with_index do |input, index|
input.click
sleep(0.5)
input.set value[index]
sleep(0.5)
end
Expand Down
11 changes: 11 additions & 0 deletions spec/support/components/work_packages/table_configuration_modal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ def open!
expect_open
end

def set_display_sums(enable: true)
open_and_switch_to 'Display settings'

if enable
check 'display_sums_switch'
else
uncheck 'display_sums_switch'
end
save
end

def save
find("#{selector} .button.-highlight").click
end
Expand Down

0 comments on commit cf80ddc

Please sign in to comment.