Merge pull request #11265 from opf/bug/43833-remaining-hours-sum-not-well-formed

[#43833] Correctly format remaining hours sum
pull/11278/head
Christophe Bliard 2 years ago committed by GitHub
commit 6df8dd61b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      frontend/src/app/shared/components/fields/display/display-field.initializer.ts
  2. 25
      modules/backlogs/spec/features/work_packages/remaining_time_spec.rb
  3. 3
      spec/features/work_packages/bulk/copy_work_package_spec.rb
  4. 21
      spec/support/pages/work_packages/work_packages_table.rb

@ -75,6 +75,7 @@ export function initializeCoreDisplayFields(displayFieldService:DisplayFieldServ
.addFieldType(MultipleUserFieldModule, 'users', ['[]User'])
.addFieldType(FormattableDisplayField, 'formattable', ['Formattable'])
.addFieldType(DaysDurationDisplayField, 'duration', ['duration'])
.addFieldType(HoursDurationDisplayField, 'remainingTime', ['remainingTime'])
.addFieldType(EstimatedTimeDisplayField, 'estimatedTime', ['estimatedTime'])
.addFieldType(DateDisplayField, 'date', ['Date'])
.addFieldType(DateTimeDisplayField, 'datetime', ['DateTime'])
@ -88,7 +89,6 @@ export function initializeCoreDisplayFields(displayFieldService:DisplayFieldServ
.addSpecificFieldType('WorkPackage', WorkPackageIdDisplayField, 'id', ['id'])
.addSpecificFieldType('WorkPackage', WorkPackageSpentTimeDisplayField, 'spentTime', ['spentTime'])
.addSpecificFieldType('WorkPackage', CombinedDateDisplayField, 'combinedDate', ['combinedDate'])
.addSpecificFieldType('WorkPackage', HoursDurationDisplayField, 'remainingTime', ['remainingTime'])
.addSpecificFieldType('TimeEntry', PlainFormattableDisplayField, 'comment', ['comment'])
.addSpecificFieldType('Project', ProjectStatusDisplayField, 'status', ['status'])
.addSpecificFieldType('TimeEntry', WorkPackageDisplayField, 'work_package', ['workPackage']);

@ -55,7 +55,7 @@ describe 'Work packages remaining time', type: :feature, js: true do
status:
end
it 'is can set and edit the remaining time in hours (Regression #43549)' do
it 'can set and edit the remaining time in hours (Regression #43549)' do
wp_page = Pages::FullWorkPackage.new(work_package)
wp_page.visit!
@ -65,10 +65,31 @@ describe 'Work packages remaining time', type: :feature, js: true do
wp_page.update_attributes remainingTime: '125' # rubocop:disable Rails/ActiveRecordAliases
wp_page.expect_attributes remainingTime: '125'
wp_page.expect_attributes remainingTime: '125 h'
work_package.reload
expect(work_package.remaining_hours).to eq 125.0
end
it 'displays the remaining time sum properly in hours (Regression #43833)' do
work_package
wp_table_page = Pages::WorkPackagesTable.new(project)
query_props = JSON.dump(c: %w(id subject remainingTime),
s: true)
wp_table_page.visit_with_params("query_props=#{query_props}")
wp_table_page.expect_work_package_with_attributes work_package, remainingTime: '-'
wp_table_page.update_work_package_attributes work_package, remainingTime: '125'
wp_table_page.expect_work_package_with_attributes work_package, remainingTime: '125 h'
wp_table_page.expect_sums_row_with_attributes remainingTime: '125 h'
work_package.reload
expect(work_package.remaining_hours).to eq 125.0
end
end

@ -237,6 +237,9 @@ describe 'Copy work packages through Rails view', js: true do
select_text: project2.name,
results_selector: 'body'
# wait for page reload after selecting the target project
sleep(2)
select 'nobody', from: 'Assignee'
click_on 'Copy and follow'

@ -68,6 +68,16 @@ module Pages
end
end
def expect_sums_row_with_attributes(attr_value_hash)
within(table_container) do
attr_value_hash.each do |column, value|
expect(page).to have_selector(
".wp-table--sums-row div.#{column}", text: value.to_s, wait: 10
)
end
end
end
def expect_work_package_subject(subject)
within(table_container) do
expect(page).to have_selector("td.subject",
@ -82,6 +92,13 @@ module Pages
end
end
def update_work_package_attributes(work_package, **key_value_map)
key_value_map.each do |key, value|
field = EditField.new(work_package_container(work_package), key)
field.update(value, save: true)
end
end
##
# Wraps expecting the page not to have the given work packages
# within a retry_block to ensure we do not fail when the page is
@ -219,6 +236,10 @@ module Pages
find('#content .work-packages-split-view--tabletimeline-side')
end
def work_package_container(work_package)
table_container.find(work_package_row_selector(work_package))
end
def work_package_row_selector(work_package)
".wp-row-#{work_package.id}"
end

Loading…
Cancel
Save