Skip to content

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

fix specs and copy service

Jonas Jabari9105759d8ff8
diff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rb
index fc190c32fdd..d3249374006 100644
--- a/modules/meeting/app/components/meeting_sections/show_component.rb
+++ b/modules/meeting/app/components/meeting_sections/show_component.rb
@@ -51,6 +51,14 @@ module MeetingSections
@meeting_section.id
end
+ def insert_target_modified?
+ true
+ end
+
+ def insert_target_modifier_id
+ "meeting-agenda-items-new-item-#{@meeting_section.id}"
+ end
+
def editable?
@meeting_section.editable? && User.current.allowed_in_project?(:manage_agendas, @meeting_section.project)
end
@@ -93,13 +101,5 @@ module MeetingSections
"target-allowed-drag-type": "agenda-item" # the type of dragged items which are allowed to be dropped in this target
}
end
-
- def insert_target_modified?
- true
- end
-
- def insert_target_modifier_id
- "meeting-agenda-items-new-item"
- end
end
end
diff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
index accf2c901fc..005f8520744 100644
--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
@@ -91,16 +91,19 @@ module Meetings
end
def update_show_items_via_turbo_stream(meeting: @meeting)
- # TODO: scope to specific section in cases where only one section is affected for less computation
meeting.sections.each do |meeting_section|
- agenda_items = meeting_section.agenda_items.with_includes_to_render
- first_and_last = [agenda_items.first, agenda_items.last]
+ update_show_items_of_section_via_turbo_stream(meeting_section:)
+ end
+ end
- agenda_items.each do |meeting_agenda_item|
- update_via_turbo_stream(
- component: MeetingAgendaItems::ItemComponent::ShowComponent.new(meeting_agenda_item:, first_and_last:)
- )
- end
+ def update_show_items_of_section_via_turbo_stream(meeting_section: @meeting_section)
+ agenda_items = meeting_section.agenda_items.with_includes_to_render
+ first_and_last = [agenda_items.first, agenda_items.last]
+
+ agenda_items.each do |meeting_agenda_item|
+ update_via_turbo_stream(
+ component: MeetingAgendaItems::ItemComponent::ShowComponent.new(meeting_agenda_item:, first_and_last:)
+ )
end
end
@@ -207,20 +210,24 @@ module Meetings
type: @agenda_item_type
)
else
- # TODO: more specific UI update as before
- update_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)
- # add_before_via_turbo_stream(
- # component: MeetingAgendaItems::ItemComponent.new(
- # state: :show,
- # meeting_agenda_item:
- # ),
- # target_component: MeetingAgendaItems::ListComponent.new(meeting: @meeting)
- # )
+ update_section_header_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)
+
+ add_before_via_turbo_stream(
+ component: MeetingAgendaItems::ItemComponent.new(
+ state: :show,
+ meeting_agenda_item:
+ ),
+ target_component: MeetingSections::ShowComponent.new(
+ meeting_section: @meeting_agenda_item.meeting_section
+ )
+ )
+
update_new_component_via_turbo_stream(
hidden: false,
meeting_section: meeting_agenda_item.meeting_section,
type: @agenda_item_type
)
+
update_show_items_via_turbo_stream
end
end
@@ -229,7 +236,7 @@ module Meetings
if clear_slate
update_list_via_turbo_stream
else
- update_show_items_via_turbo_stream
+ update_show_items_of_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)
if meeting_agenda_item.meeting_section.agenda_items.empty?
# Show the empty section state by updating the whole section if items are empty
update_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)
@@ -249,27 +256,24 @@ module Meetings
# Note: The `remove_component` and the `component` are pointing to the same
# component, but we still need to instantiate them separately, otherwise re-adding
# of the item will render and empty component.
- # remove_component = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)
- # remove_via_turbo_stream(component: remove_component)
-
- # component = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)
- # target_component =
- # if @meeting_agenda_item.lower_item
- # MeetingAgendaItems::ItemComponent.new(
- # state: :show,
- # meeting_agenda_item: @meeting_agenda_item.lower_item
- # )
- # else
- # MeetingSections::ShowComponent.new(
- # meeting_section: @meeting_agenda_item.meeting_section
- # )
- # # MeetingAgendaItems::ListComponent.new(meeting: @meeting)
- # end
- # add_before_via_turbo_stream(component:, target_component:)
- # update_show_items_via_turbo_stream
-
- # TODO: review above implementation and adapt properly to section based approach
- update_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)
+ remove_component = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)
+ remove_via_turbo_stream(component: remove_component)
+
+ component = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)
+
+ target_component = if @meeting_agenda_item.lower_item
+ MeetingAgendaItems::ItemComponent.new(
+ state: :show,
+ meeting_agenda_item: @meeting_agenda_item.lower_item
+ )
+ else
+ MeetingSections::ShowComponent.new(
+ meeting_section: @meeting_agenda_item.meeting_section
+ )
+ end
+
+ add_before_via_turbo_stream(component:, target_component:)
+ update_show_items_of_section_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section)
end
def render_base_error_in_flash_message_via_turbo_stream(errors)
diff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rb
index d69ae64c049..a6d83eb6934 100644
--- a/modules/meeting/app/models/meeting_agenda_item.rb
+++ b/modules/meeting/app/models/meeting_agenda_item.rb
@@ -72,6 +72,8 @@ class MeetingAgendaItem < ApplicationRecord
# after_destroy :delete_meeting_section_if_empty
def add_to_latest_meeting_section
+ return if meeting.nil?
+
if meeting_section_id.nil?
meeting_section = meeting.sections.order(position: :asc).last
diff --git a/modules/meeting/app/services/meetings/copy_service.rb b/modules/meeting/app/services/meetings/copy_service.rb
index 1e40c87ea05..3585e91f805 100644
--- a/modules/meeting/app/services/meetings/copy_service.rb
+++ b/modules/meeting/app/services/meetings/copy_service.rb
@@ -102,8 +102,14 @@ module Meetings
def copy_meeting_agenda(copy)
if meeting.is_a?(StructuredMeeting)
- meeting.agenda_items.each do |agenda_item|
- copy.agenda_items << agenda_item.dup
+ meeting.sections.each do |section|
+ copy.sections << section.dup
+ copied_section = copy.reload.sections.last
+ section.agenda_items.each do |agenda_item|
+ copied_agenda_item = agenda_item.dup
+ copied_agenda_item.meeting_id = copy.id
+ copied_section.agenda_items << copied_agenda_item
+ end
end
else
MeetingAgenda.create!(
diff --git a/modules/meeting/spec/features/structured_meetings/attachment_upload_spec.rb b/modules/meeting/spec/features/structured_meetings/attachment_upload_spec.rb
index 01d2e32a25e..b2f584bacd1 100644
--- a/modules/meeting/spec/features/structured_meetings/attachment_upload_spec.rb
+++ b/modules/meeting/spec/features/structured_meetings/attachment_upload_spec.rb
@@ -53,6 +53,7 @@ RSpec.describe "Upload attachment to meetings", :js do
show_page.visit!
show_page.add_agenda_item(save: false) do
+ sleep 1 # TODO: dynamically wait - without sleep running into timing issues locally
click_on "Notes"
end
diff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rb
index 184087f12b8..b242aa3e23e 100644
--- a/modules/meeting/spec/features/structured_meetings/history_spec.rb
+++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb
@@ -161,6 +161,10 @@ RSpec.describe "history",
click_on "Save"
end
+ # dynamically wait for the item to be updated successfully
+ # before checking the history modal, otherwise running into timing issues
+ show_page.expect_agenda_item(title: "Updated title")
+
history_page.open_history_modal
history_page.expect_event(
'Agenda item "Updated title"',
@@ -202,6 +206,7 @@ RSpec.describe "history",
show_page.remove_agenda_item(second)
history_page.open_history_modal
+
item = history_page.first_item
expect(item).to have_css(".op-activity-list--item-title", text: 'Agenda item "Second"')
expect(item).to have_css(".op-activity-list--item-subtitle", text: "deleted by")
@@ -221,6 +226,7 @@ RSpec.describe "history",
expect(wp_item).to be_present
history_page.open_history_modal
+
item = history_page.first_item
expect(item).to have_css(".op-activity-list--item-title", text: work_package.to_s.strip)
expect(item).to have_css(".op-activity-list--item-subtitle", text: "added by")
@@ -241,6 +247,7 @@ RSpec.describe "history",
expect(wp_item).to be_present
history_page.open_history_modal
+
item = history_page.first_item
expect(item).to have_css(".op-activity-list--item-title", text: changed_wp.to_s.strip)
expect(item).to have_css(".op-activity-list--item-subtitle", text: "updated by")
@@ -271,6 +278,7 @@ RSpec.describe "history",
# Is visible for user
history_page.open_history_modal
+
item = history_page.first_item
expect(item).to have_css(".op-activity-list--item-title", text: other_wp.to_s.strip)
expect(item).to have_css(".op-activity-list--item-subtitle", text: "added by")
@@ -281,6 +289,7 @@ RSpec.describe "history",
show_page.visit!
history_page.open_history_modal
+
item = history_page.first_item
expect(item).to have_css(".op-activity-list--item-title", text: I18n.t(:label_agenda_item_undisclosed_wp, id: other_wp.id))
expect(item).to have_css(".op-activity-list--item-subtitle", text: "added by")
@@ -289,6 +298,10 @@ RSpec.describe "history",
login_as(user)
show_page.visit!
show_page.remove_agenda_item wp_item
+
+ # dynamically wait for the item to be removed successfully
+ show_page.expect_no_agenda_item(title: wp_item.to_s)
+
history_page.open_history_modal
item = history_page.first_item
@@ -301,6 +314,7 @@ RSpec.describe "history",
show_page.visit!
history_page.open_history_modal
+
item = history_page.first_item
expect(item).to have_css(".op-activity-list--item-title", text: I18n.t(:label_agenda_item_undisclosed_wp, id: other_wp.id))
expect(item).to have_css(".op-activity-list--item-subtitle", text: "removed by")
@@ -318,7 +332,7 @@ RSpec.describe "history",
show_page.expect_agenda_item(title: "My agenda item")
item = MeetingAgendaItem.find_by(title: "My agenda item")
- show_page.cancel_add_form
+ show_page.cancel_add_form(item)
show_page.select_action(item, "Add notes")
editor.set_markdown "# Hello there"
diff --git a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
index a4985cf3f22..7811151dfcf 100644
--- a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
@@ -90,15 +90,17 @@ RSpec.describe "Structured meetings CRUD",
end
show_page.expect_agenda_item title: "My agenda item"
- show_page.cancel_add_form
-
item = MeetingAgendaItem.find_by(title: "My agenda item")
+ show_page.cancel_add_form(item)
+
+ # can update
show_page.edit_agenda_item(item) do
fill_in "Title", with: "Updated title"
click_on "Save"
end
show_page.expect_no_agenda_item title: "My agenda item"
+ show_page.expect_agenda_item title: "Updated title"
# Can add multiple items
show_page.add_agenda_item do
@@ -136,7 +138,7 @@ RSpec.describe "Structured meetings CRUD",
# Can remove
show_page.remove_agenda_item first
show_page.assert_agenda_order! "Updated title", "Second"
- show_page.cancel_add_form
+ show_page.cancel_add_form(second)
# Can link work packages
show_page.add_agenda_item(type: WorkPackage) do
@@ -164,7 +166,7 @@ RSpec.describe "Structured meetings CRUD",
end
show_page.select_action(item, I18n.t(:label_sort_lowest))
- show_page.cancel_add_form
+ show_page.cancel_add_form(item)
show_page.add_agenda_item do
fill_in "Title", with: "My agenda item"
@@ -223,6 +225,16 @@ RSpec.describe "Structured meetings CRUD",
click_on I18n.t(:label_icalendar_download)
+ # dynamically wait for download to finish, otherwise expectation is too early
+ seconds = 0
+ while seconds < 5
+ # don't use subject as it will not get reevaluated in the next iteration
+ break if @download_list.refresh_from(page).latest_download.to_s != ""
+
+ sleep 1
+ seconds += 1
+ end
+
expect(subject).to end_with ".ics"
end
end
@@ -237,9 +249,10 @@ RSpec.describe "Structured meetings CRUD",
end
show_page.expect_agenda_item title: "My agenda item"
- show_page.cancel_add_form
-
item = MeetingAgendaItem.find_by!(title: "My agenda item")
+
+ show_page.cancel_add_form(item)
+
show_page.edit_agenda_item(item) do
# Side effect: update the item
item.update!(title: "Updated title")
@@ -261,7 +274,9 @@ RSpec.describe "Structured meetings CRUD",
end
show_page.expect_agenda_item title: "My agenda item"
- show_page.cancel_add_form
+ item = MeetingAgendaItem.find_by!(title: "My agenda item")
+
+ show_page.cancel_add_form(item)
click_on("op-meetings-header-action-trigger")
click_on "Copy"
diff --git a/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb b/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb
index f0fcd27170b..4f42ac4ad93 100644
--- a/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb
+++ b/modules/meeting/spec/services/meetings/copy_service_integration_spec.rb
@@ -92,7 +92,7 @@ RSpec.describe Meetings::CopyService, "integration", type: :model do
end
it "copies the agenda item" do
- expect(copy.agenda_items.length)
+ expect(copy.reload.agenda_items.length)
.to eq 1
expect(copy.agenda_items.first.notes)
@@ -121,6 +121,7 @@ RSpec.describe Meetings::CopyService, "integration", type: :model do
context "when asking to copy attachments" do
let(:params) { { copy_attachments: true } }
+
it "copies the attachment" do
expect(copy.attachments.length)
.to eq 1
diff --git a/modules/meeting/spec/support/pages/structured_meeting/history.rb b/modules/meeting/spec/support/pages/structured_meeting/history.rb
index a4df4a6f691..33bcabb2ad0 100644
--- a/modules/meeting/spec/support/pages/structured_meeting/history.rb
+++ b/modules/meeting/spec/support/pages/structured_meeting/history.rb
@@ -37,6 +37,9 @@ module Pages::StructuredMeeting
retry_block do
click_link_or_button "op-meetings-header-action-trigger"
click_link_or_button "History"
+ # dynamically wait for the modal to be loaded
+ # otherwise running into timing issues with `item = history_page.first_item`
+ expect(page).to have_css(".op-activity-list--item")
end
end
@@ -66,9 +69,7 @@ module Pages::StructuredMeeting
def find_item(detail)
detail = page.find("li.op-activity-list--item-detail", text: detail)
- item = detail.ancestor(".op-activity-list--item-details").ancestor(".op-activity-list--item")
-
- item
+ detail.ancestor(".op-activity-list--item-details").ancestor(".op-activity-list--item")
end
end
end
diff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rb
index 8b3b2a6ae18..c29e6254e19 100644
--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb
+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb
@@ -48,8 +48,8 @@ module Pages::StructuredMeeting
end
end
- def cancel_add_form
- page.within("#meeting-agenda-items-new-component") do
+ def cancel_add_form(item)
+ page.within("#meeting-agenda-items-new-component-#{item.meeting_section_id}") do
click_on I18n.t(:button_cancel)
expect(page).to have_no_link I18n.t(:button_cancel)
end