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
Add feature specs for status-based modal behavior
Aaron Contreras984032e78510
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.html b/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.htmlindex 8dc10c83c49..5d16f3d58b5 100644--- a/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.html+++ b/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.html@@ -28,7 +28,7 @@class="button button_no-margin -transparent spot-modal--header-close-button"[attr.aria-label]="text.button_close"(click)="closeMe()"- data-test-selector="op-share-wp-modal--close-icon"+ data-test-selector="op-progress-modal--close-icon"><svg x-icon size="small" class="spot-modal--header-close-button-icon"></svg></button>diff --git a/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.tsindex c2b0e3bf0c4..4ce21062763 100644--- a/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.ts+++ b/frontend/src/app/shared/components/fields/edit/field-types/progress-popover-edit-field.component.ts@@ -139,6 +139,13 @@ export class ProgressPopoverEditFieldComponent extends ProgressEditFieldComponenreturn moment.duration(value).asHours().toFixed(1);}+ public statusFormatter(value:null|string):string {+ if (value === null) {+ return '';+ }+ return value;+ }+private contextBasedListener(event:CustomEvent) {// eslint-disable-next-line @typescript-eslint/no-unsafe-member-accessif (this.resource.id === 'new') {@@ -208,7 +215,7 @@ export class ProgressPopoverEditFieldComponent extends ProgressEditFieldComponen// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-accessurl.searchParams.set('work_package[remaining_hours]', this.formatter(this.resource.remainingTime));// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access- url.searchParams.set('work_package[status_id]', this.resource.status.id as string);+ url.searchParams.set('work_package[status_id]', this.statusFormatter(this.resource.status?.id as string));// eslint-disable-next-line @typescript-eslint/no-unsafe-member-accessthis.frameSrc = url.toString();diff --git a/spec/features/work_packages/progress_modal_spec.rb b/spec/features/work_packages/progress_modal_spec.rbindex f5a78e17799..aa935d6b1fb 100644--- a/spec/features/work_packages/progress_modal_spec.rb+++ b/spec/features/work_packages/progress_modal_spec.rb@@ -32,7 +32,17 @@ require "spec_helper"RSpec.describe "Progress modal", :js, :with_cuprite doshared_let(:user) { create(:admin) }- shared_let(:project) { create(:project) }+ shared_let(:type_task) { create(:type_task) }+ shared_let(:project) { create(:project, types: [type_task]) }+ shared_let(:open_status_with_0p_done_ratio) do+ create(:status, name: "open", default_done_ratio: 0)+ end+ shared_let(:in_progress_status_with_50p_done_ratio) do+ create(:status, name: "in progress", default_done_ratio: 50)+ end+ shared_let(:complete_status_with_100p_done_ratio) do+ create(:status, name: "complete", default_done_ratio: 100)+ endshared_let(:estimated_hours) { 10.0 }shared_let(:remaining_hours) { 5.0 }@@ -49,8 +59,6 @@ RSpec.describe "Progress modal", :js, :with_cuprite do.call(**attributes)end- current_user { user }-let(:progress_query) docreate(:query,project:,@@ -61,49 +69,180 @@ RSpec.describe "Progress modal", :js, :with_cuprite docreate(:view_work_packages_table, query:)endend+let(:work_package_table) { Pages::WorkPackagesTable.new(project) }let(:work_package_row) { work_package_table.work_package_container(work_package) }+ let(:work_package_create_page) { Pages::FullWorkPackageCreate.new(project:) }++ current_user { user }describe "clicking on a field on the work package table" do- it "opens the modal with its work field in focus " \- "when clicking on the work input field" do+ it "sets the cursor after the last character on the selected input field" dowork_package_table.visit_query(progress_query)work_package_table.expect_work_package_listed(work_package)work_edit_field = ProgressEditField.new(work_package_row, :estimatedTime)modal = work_edit_field.activate!- modal.expect_modal_field_in_focus+ modal.expect_cursor_at_end_of_inputend+ end- it "sets the cursor after the last character on the selected input field" do- work_package_table.visit_query(progress_query)- work_package_table.expect_work_package_listed(work_package)+ describe "work based mode" do+ shared_examples_for "opens the modal with its work field in focus" do+ it "opens the modal with its work field in focus" do+ work_package_table.visit_query(progress_query)+ work_package_table.expect_work_package_listed(work_package)- work_edit_field = ProgressEditField.new(work_package_row, :estimatedTime)- modal = work_edit_field.activate!+ work_edit_field = ProgressEditField.new(work_package_row, :estimatedTime)+ modal = work_edit_field.activate!- modal.expect_cursor_at_end_of_input+ modal.expect_modal_field_in_focus+ end+ end++ describe "clicking on the work field on the work package table " \+ "with no fields set" do+ before do+ update_work_package_with(work_package, estimated_hours: nil, remaining_hours: nil)+ end++ include_examples "opens the modal with its work field in focus"+ end++ describe "clicking on the work field on the work package table" \+ "with all fields set" do+ before do+ update_work_package_with(work_package, estimated_hours: 25.0, remaining_hours: 15.0)+ end++ include_examples "opens the modal with its work field in focus"+ end++ describe "clicking on the remaining work field on the work package table " \+ "with no fields set" do+ before do+ update_work_package_with(work_package, estimated_hours: nil, remaining_hours: nil)+ end++ it "opens the modal with work in focus and remaining work disabled" do+ work_package_table.visit_query(progress_query)+ work_package_table.expect_work_package_listed(work_package)++ work_edit_field = ProgressEditField.new(work_package_row, :estimatedTime)+ remaining_work_field = ProgressEditField.new(work_package_row, :remainingTime)++ remaining_work_field.activate!++ work_edit_field.expect_modal_field_in_focus+ remaining_work_field.expect_modal_field_disabled+ end+ end++ describe "clicking on the remaining work field on the work package table " \+ "with all fields set" do+ before do+ update_work_package_with(work_package, estimated_hours: 20.0, remaining_hours: 15.0)+ end++ it "opens the modal with remaining work in focus" do+ work_package_table.visit_query(progress_query)+ work_package_table.expect_work_package_listed(work_package)++ remaining_work_field = ProgressEditField.new(work_package_row, :remainingTime)++ remaining_work_field.activate!++ remaining_work_field.expect_modal_field_in_focus+ endendend- describe "clicking on the remaining work field on the work package table " \- "with no fields set" do- before do- update_work_package_with(work_package, estimated_hours: nil, remaining_hours: nil)+ describe "status based mode", with_settings: { work_package_done_ratio: "status" } do+ describe "clicking on the work field in the work package table " \+ "with no fields set" do+ before { update_work_package_with(work_package, estimated_hours: nil, remaining_hours: nil) }++ it "opens the modal with work in focus" do+ work_package_table.visit_query(progress_query)+ work_package_table.expect_work_package_listed(work_package)++ work_edit_field = ProgressEditField.new(work_package_row, :estimatedTime)+ modal = work_edit_field.activate!++ modal.expect_modal_field_in_focus+ endend- it "opens the modal with work in focus and remaining work disabled" do- work_package_table.visit_query(progress_query)- work_package_table.expect_work_package_listed(work_package)+ describe "clicking on the work field in the work package table " \+ "with all fields set" do+ before { update_work_package_with(work_package, estimated_hours: 20.0, remaining_hours: 15.0) }- work_edit_field = ProgressEditField.new(work_package_row, :estimatedTime)- remaining_work_field = ProgressEditField.new(work_package_row, :remainingTime)+ it "opens the modal with work in focus" do+ work_package_table.visit_query(progress_query)+ work_package_table.expect_work_package_listed(work_package)- remaining_work_field.activate!+ work_edit_field = ProgressEditField.new(work_package_row, :estimatedTime)+ modal = work_edit_field.activate!- work_edit_field.expect_modal_field_in_focus- remaining_work_field.expect_modal_field_disabled+ modal.expect_modal_field_in_focus+ end+ end++ describe "Remaining work field" do+ it "is readonly" do+ work_package_table.visit_query(progress_query)+ work_package_table.expect_work_package_listed(work_package)++ work_field = ProgressEditField.new(work_package_row, :estimatedTime)+ remaining_work_field = ProgressEditField.new(work_package_row, :remainingTime)+ work_field.activate!++ remaining_work_field.expect_read_only_modal_field+ end+ end++ context "when on a new work package form" do+ specify "modal renders when no default status is set for new work packages" do+ work_package_create_page.visit!++ work_field = work_package_create_page.edit_field(:estimatedTime)+ work_field.activate!+ end++ context "with a default status set for new work packages" do+ before { open_status_with_0p_done_ratio.update!(is_default: true) }++ shared_let(:workflow) do+ create(:workflow,+ type_id: type_task.id,+ old_status: open_status_with_0p_done_ratio,+ new_status: in_progress_status_with_50p_done_ratio)+ end++ it "renders the status selection field inside the modal as disabled " \+ "and allows setting the status solely by the top-left field" do+ work_package_create_page.visit!+ work_package_create_page.expect_fully_loaded++ work_field = work_package_create_page.edit_field(:estimatedTime)+ modal_status_field = work_package_create_page.edit_field(:statusWithinProgressModal)++ modal = work_field.activate!++ modal_status_field.expect_modal_field_disabled+ modal_status_field.expect_modal_field_value("open (0%)", disabled: true)++ modal.close!++ status_field = work_package_create_page.edit_field(:status)++ status_field.update("in progress")++ work_field.activate!+ modal_status_field.expect_modal_field_value("in progress (50%)", disabled: true)+ end+ endendend@@ -147,6 +286,22 @@ RSpec.describe "Progress modal", :js, :with_cuprite dopercent_complete_edit_field.expect_modal_field_value("-", readonly: true)endend++ describe "status field", with_settings: { work_package_done_ratio: "status" } do+ it "renders the status options as the << status_name (percent_complete_value %) >>" do+ work_package_table.visit_query(progress_query)+ work_package_table.expect_work_package_listed(work_package)++ work_field = ProgressEditField.new(work_package_row, :estimatedTime)+ status_field = ProgressEditField.new(work_package_row, :statusWithinProgressModal)++ work_field.activate!++ status_field.expect_select_field_with_options("open (0%)",+ "in progress (50%)",+ "complete (100%)")+ end+ endendit "disables the field that triggered the modal" dodiff --git a/spec/support/edit_fields/progress_edit_field.rb b/spec/support/edit_fields/progress_edit_field.rbindex afd1ae08af4..ff50a205e04 100644--- a/spec/support/edit_fields/progress_edit_field.rb+++ b/spec/support/edit_fields/progress_edit_field.rb@@ -35,7 +35,8 @@ class ProgressEditField < EditFieldFIELD_NAME_MAP = {"estimatedTime" => :estimated_hours,"remainingTime" => :remaining_hours,- "percentageDone" => :done_ratio+ "percentageDone" => :done_ratio,+ "statusWithinProgressModal" => :status_id}.freezedef initialize(context,@@ -92,6 +93,10 @@ class ProgressEditField < EditFieldinput_element.native.send_keys :returnend+ def close!+ page.find("[data-test-selector='op-progress-modal--close-icon']").click+ end+def expect_active!expect(page).to have_css(MODAL_SELECTOR)end@@ -143,12 +148,20 @@ class ProgressEditField < EditFieldwithin modal_element doif @property_name == "percentageDone" && value.to_s == "-"expect(page).to have_field(field_name, readonly:, placeholder: value.to_s)+ elsif @property_name == "statusWithinProgressModal"+ expect(page).to have_select(field_name, disabled:, with_selected: value.to_s)elseexpect(page).to have_field(field_name, disabled:, readonly:, with: value.to_s)endendend+ def expect_select_field_with_options(*expected_options)+ within modal_element do+ expect(page).to have_select(field_name, with_options: expected_options)+ end+ end+privateattr_reader :field_namediff --git a/spec/support/pages/work_packages/abstract_work_package.rb b/spec/support/pages/work_packages/abstract_work_package.rbindex 483b0d23538..60aa5cf7788 100644--- a/spec/support/pages/work_packages/abstract_work_package.rb+++ b/spec/support/pages/work_packages/abstract_work_package.rb@@ -223,7 +223,7 @@ module Pageswork_package_custom_field(key, $1)when :date, :startDate, :dueDate, :combinedDateDateEditField.new container, key, is_milestone: work_package&.milestone?- when :estimatedTime, :remainingTime+ when :estimatedTime, :remainingTime, :statusWithinProgressModalProgressEditField.new container, key, create_form: create_page?when :descriptionTextEditorField.new container, key