OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix spec expecting for start date to be moved back
Oliver Günther3b78c25588a8
diff --git a/frontend/src/app/components/wp-edit-form/display-field-renderer.ts b/frontend/src/app/components/wp-edit-form/display-field-renderer.tsindex d884b84877e..72303030a2c 100644--- a/frontend/src/app/components/wp-edit-form/display-field-renderer.ts+++ b/frontend/src/app/components/wp-edit-form/display-field-renderer.ts@@ -148,7 +148,8 @@ export class DisplayFieldRenderer<T extends HalResource = HalResource> {span.classList.add(placeholderClassName);}- if (this.schema(resource, change).isAttributeEditable(name)) {+ const schema = this.schema(resource, change);+ if (this.isAttributeEditable(schema, name)) {span.classList.add(editableClassName);span.setAttribute('role', 'button');} else {@@ -156,6 +157,15 @@ export class DisplayFieldRenderer<T extends HalResource = HalResource> {}}+ private isAttributeEditable(schema:SchemaResource, fieldName:string) {+ // We need to handle start/due date cases like they were combined dates+ if (['startDate', 'dueDate', 'date'].includes(fieldName)) {+ fieldName = 'combinedDate';+ }++ return schema.isAttributeEditable(fieldName);+ }+private getAriaLabel(field:DisplayField, schema:SchemaResource):string {let titleContent;let labelContent = this.getLabelContent(field);diff --git a/frontend/src/app/components/wp-edit-form/table-edit-form.ts b/frontend/src/app/components/wp-edit-form/table-edit-form.tsindex 223c0e5e5c4..185aee86c55 100644--- a/frontend/src/app/components/wp-edit-form/table-edit-form.ts+++ b/frontend/src/app/components/wp-edit-form/table-edit-form.ts@@ -134,6 +134,20 @@ export class TableEditForm extends EditForm<WorkPackageResource> {.trigger('focus');}+ /**+ * Load the resource form to get the current field schema with all+ * values loaded.+ * @param fieldName+ */+ protected loadFieldSchema(fieldName:string, noWarnings:boolean = false):Promise<IFieldSchema> {+ // We need to handle start/due date cases like they were combined dates+ if (['startDate', 'dueDate', 'date'].includes(fieldName)) {+ fieldName = 'combinedDate';+ }++ return super.loadFieldSchema(fieldName, noWarnings);+ }+// Ensure the given field is visible.// We may want to look into MutationObserver if we need this in several places.private waitForContainer(fieldName:string):Promise<HTMLElement> {diff --git a/frontend/src/app/modules/fields/edit/edit-form/edit-form.ts b/frontend/src/app/modules/fields/edit/edit-form/edit-form.tsindex 0f3d51e83ef..7f66ec15d74 100644--- a/frontend/src/app/modules/fields/edit/edit-form/edit-form.ts+++ b/frontend/src/app/modules/fields/edit/edit-form/edit-form.ts@@ -269,7 +269,7 @@ export abstract class EditForm<T extends HalResource = HalResource> {* values loaded.* @param fieldName*/- private loadFieldSchema(fieldName:string, noWarnings:boolean = false):Promise<IFieldSchema> {+ protected loadFieldSchema(fieldName:string, noWarnings:boolean = false):Promise<IFieldSchema> {return new Promise((resolve, reject) => {this.loadFormAndCheck(fieldName, noWarnings);const fieldSchema:IFieldSchema = this.change.schema.ofProperty(fieldName);diff --git a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rbnew file mode 100644index 00000000000..03fca0d9110--- /dev/null+++ b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb@@ -0,0 +1,116 @@+require 'spec_helper'++describe 'Manual scheduling', js: true do+ let(:project) { FactoryBot.create(:project, types: [type]) }+ let(:type) { FactoryBot.create :type }++ let(:user) { FactoryBot.create :user, member_in_project: project, member_through_role: role }++ let!(:parent) do+ FactoryBot.create(:work_package,+ project: project,+ type: type,+ subject: 'Parent')+ end++ let!(:child) do+ FactoryBot.create(:work_package,+ project: project,+ parent: parent,+ type: type,+ subject: 'Child')+ end++ let!(:wp_table) { Pages::WorkPackagesTable.new(project) }+ let!(:query) do+ query = FactoryBot.build(:query, user: user, project: project)+ query.column_names = %w(subject start_date due_date)+ query.filters.clear+ query.show_hierarchies = false++ query.save!+ query+ end++ before do+ login_as(user)++ wp_table.visit_query query+ wp_table.expect_work_package_listed parent, child+ end++ context 'with a user allowed to edit dates' do+ let(:role) { FactoryBot.create :role, permissions: %i[view_work_packages edit_work_packages] }++ it 'allows to edit start and due date multiple times switching between scheduling modes' do+ start_date = wp_table.edit_field(parent, :startDate)+ due_date = wp_table.edit_field(parent, :dueDate)++ # Open start date+ start_date.activate!+ start_date.expect_active!++ # Expect not to be scheduled manually+ start_date.expect_scheduling_mode manually: false++ # Expect not editable+ start_date.within_modal do+ expect(page).to have_selector('input[name="startDate"][disabled]')+ expect(page).to have_selector('input[name="endDate"][disabled]')+ end++ start_date.toggle_scheduling_mode+ start_date.expect_scheduling_mode manually: true++ # Expect editable+ start_date.within_modal do+ expect(page).to have_selector('input[name="startDate"]:not([disabled])')+ expect(page).to have_selector('input[name="endDate"]:not([disabled])')+ end++ start_date.cancel_by_click++ # Both are closed+ start_date.expect_inactive!+ due_date.expect_inactive!++ # Open second date, closes first+ due_date.activate!+ due_date.expect_active!++ # Close with escape+ due_date.cancel_by_click++ start_date.activate!+ start_date.expect_scheduling_mode manually: false++ # Expect not editable+ start_date.within_modal do+ expect(page).to have_selector('input[name=startDate][disabled]')+ expect(page).to have_selector('input[name=endDate][disabled]')+ end++ start_date.toggle_scheduling_mode+ start_date.expect_scheduling_mode manually: true++ # Expect not editable+ start_date.within_modal do+ fill_in 'startDate', with: '2020-07-20'+ fill_in 'endDate', with: '2020-07-25'+ end++ start_date.save!+ start_date.expect_state_text '07/20/2020'+ due_date.expect_state_text '07/25/2020'++ parent.reload+ expect(parent).to be_schedule_manually+ expect(parent.start_date.iso8601).to eq('2020-07-20')+ expect(parent.due_date.iso8601).to eq('2020-07-25')+ end+ end++ context 'with a user allowed to view only' do+ let(:role) { FactoryBot.create :role, permissions: %i[view_work_packages] }+ end+enddiff --git a/spec/services/work_packages/set_attributes_service_spec.rb b/spec/services/work_packages/set_attributes_service_spec.rbindex 5e95be86404..120b626e2a6 100644--- a/spec/services/work_packages/set_attributes_service_spec.rb+++ b/spec/services/work_packages/set_attributes_service_spec.rb@@ -674,8 +674,8 @@ describe WorkPackages::SetAttributesService, type: :model doit 'sets the start date to the soonest possible start date' dosubject- expect(work_package.start_date).to eql(Date.today)- expect(work_package.due_date).to eql(Date.today + 5.days)+ expect(work_package.start_date).to eql(soonest_start)+ expect(work_package.due_date).to eql(Date.today + 2.days)endendenddiff --git a/spec/support/edit_fields/date_edit_field.rb b/spec/support/edit_fields/date_edit_field.rbindex 13ca301290a..a38bb57ebd2 100644--- a/spec/support/edit_fields/date_edit_field.rb+++ b/spec/support/edit_fields/date_edit_field.rb@@ -70,12 +70,12 @@ class DateEditField < EditFieldenddef active?- page.has_selector?("#{modal_selector} #{input_selector}", wait: 1)+ page.has_selector?(modal_selector, wait: 1)enddef expect_active!expect(page)- .to have_selector("#{modal_selector} #{input_selector}", wait: 10),+ .to have_selector(modal_selector, wait: 10),"Expected date field '#{property_name}' to be active."end