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
Automatically wait for agenda item update in specs
Christophe Bliard9f12360f62b8
diff --git a/modules/meeting/spec/features/meeting_backlogs_spec.rb b/modules/meeting/spec/features/meeting_backlogs_spec.rbindex cfbaa1f80a6..d382eaf63e3 100644--- a/modules/meeting/spec/features/meeting_backlogs_spec.rb+++ b/modules/meeting/spec/features/meeting_backlogs_spec.rb@@ -179,7 +179,6 @@ RSpec.describe "Meeting Backlogs", :js do# edit itemshow_page.edit_agenda_item(item) dofill_in "Title", with: "Updated title"- click_on "Save"endshow_page.expect_backlog collapsed: false@@ -326,7 +325,6 @@ RSpec.describe "Meeting Backlogs", :js do# edit itemfirst_occurrence_page.edit_agenda_item(item) dofill_in "Title", with: "Updated title"- click_on "Save"endfirst_occurrence_page.expect_series_backlog collapsed: false@@ -355,7 +353,6 @@ RSpec.describe "Meeting Backlogs", :js doitem = first_occurrence.agenda_items.firstfirst_occurrence_page.edit_agenda_item(item) dofill_in "Title", with: "Meeting 1 item"- click_on "Save"endfirst_occurrence_page.select_action(item, I18n.t(:label_agenda_item_move_to_backlog))@@ -371,7 +368,6 @@ RSpec.describe "Meeting Backlogs", :js doother_meeting_item = next_occurrence.agenda_items.firstnext_occurrence_page.edit_agenda_item(other_meeting_item) dofill_in "Title", with: "Meeting 2 item"- click_on "Save"endnext_occurrence_page.select_action(other_meeting_item, I18n.t(:label_agenda_item_move_to_backlog))@@ -396,7 +392,6 @@ RSpec.describe "Meeting Backlogs", :js do# update moved item to check if component is updated correctlyfirst_occurrence_page.edit_agenda_item(other_meeting_item) dofill_in "Title", with: "Meeting 2 item, now updated"- click_on "Save"endfirst_occurrence_page.expect_agenda_item(title: "Meeting 2 item, now updated")diff --git a/modules/meeting/spec/features/meetings_autofocus_spec.rb b/modules/meeting/spec/features/meetings_autofocus_spec.rbindex e0853a085db..55ae9ed1b6e 100644--- a/modules/meeting/spec/features/meetings_autofocus_spec.rb+++ b/modules/meeting/spec/features/meetings_autofocus_spec.rb@@ -95,7 +95,6 @@ RSpec.describe "Meetings autofocus", :js doshow_page.expect_focused_input("form_#{item.id}_meeting_agenda_item_title")fill_in "Title", with: "Updated title"- click_on "Save"endshow_page.expect_agenda_item title: "Updated title"@@ -146,7 +145,7 @@ RSpec.describe "Meetings autofocus", :js doexpect(wp_item).to be_present# edit wp item- show_page.edit_agenda_item(wp_item) do+ show_page.edit_agenda_item(wp_item, save: false) doshow_page.expect_focused_input("form_#{wp_item.id}_meeting_agenda_item_work_package_id")click_on "Cancel"end@@ -208,7 +207,6 @@ RSpec.describe "Meetings autofocus", :js doshow_page.expect_focused_input("form_#{item.id}_meeting_agenda_item_title")fill_in "Title", with: "Updated title"- click_on "Save"endshow_page.expect_agenda_item title: "Updated title"@@ -259,7 +257,7 @@ RSpec.describe "Meetings autofocus", :js doexpect(wp_item).to be_present# edit wp item- show_page.edit_agenda_item(wp_item) do+ show_page.edit_agenda_item(wp_item, save: false) doshow_page.expect_focused_input("form_#{wp_item.id}_meeting_agenda_item_work_package_id")click_on "Cancel"end@@ -302,7 +300,6 @@ RSpec.describe "Meetings autofocus", :js doshow_page.expect_focused_input("form_#{item.id}_meeting_agenda_item_title")fill_in "Title", with: "Updated title"- click_on "Save"endshow_page.expect_agenda_item title: "Updated title"@@ -329,7 +326,7 @@ RSpec.describe "Meetings autofocus", :js doexpect(wp_item).to be_present# edit wp item- show_page.edit_agenda_item(wp_item) do+ show_page.edit_agenda_item(wp_item, save: false) doshow_page.expect_focused_input("form_#{wp_item.id}_meeting_agenda_item_work_package_id")click_on "Cancel"enddiff --git a/modules/meeting/spec/features/meetings_edit_agenda_spec.rb b/modules/meeting/spec/features/meetings_edit_agenda_spec.rbindex 6f2528b8a9d..a0b26da83a2 100644--- a/modules/meeting/spec/features/meetings_edit_agenda_spec.rb+++ b/modules/meeting/spec/features/meetings_edit_agenda_spec.rb@@ -79,11 +79,11 @@ RSpec.describe "Meetings edit agenda", :js dosecond_item = MeetingAgendaItem.find_by(title: "Agenda Item #2")- show_page.edit_agenda_item(first_item) do+ show_page.edit_agenda_item(first_item, save: false) doexpect(show_page).to have_selector :rich_text, "Notes", text: "Preliminary notes ✅"end- show_page.edit_agenda_item(second_item) do+ show_page.edit_agenda_item(second_item, save: false) doexpect(show_page).to have_selector :rich_text, "Notes", text: "More notes..."endenddiff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rbindex 5b43a195522..9ab7549733d 100644--- a/modules/meeting/spec/features/structured_meetings/history_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb@@ -158,7 +158,6 @@ RSpec.describe "history",show_page.edit_agenda_item(item) dofill_in "Title", with: "Updated title"fill_in "Duration", with: "5"- click_on "Save"end# dynamically wait for the item to be updated successfully@@ -239,7 +238,6 @@ RSpec.describe "history",select_autocomplete(find_test_selector("op-agenda-items-wp-autocomplete"),query: "Changed task",results_selector: "body")- click_link_or_button "Save"endshow_page.expect_agenda_item title: "Changed task"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.rbindex 127b20a43cc..1ec15b4c181 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@@ -101,7 +101,6 @@ RSpec.describe "Meetings CRUD",# Can updateshow_page.edit_agenda_item(item) dofill_in "Title", with: "Updated title"- click_on "Save"endshow_page.expect_no_agenda_item title: "My agenda item"@@ -138,7 +137,7 @@ RSpec.describe "Meetings CRUD",show_page.assert_agenda_order! "First", "Updated title", "Second"# Can edit and cancel with escape- show_page.edit_agenda_item(first) do+ show_page.edit_agenda_item(first, save: false) dofind_field("Title").send_keys :escapeendshow_page.expect_item_edit_form(first, visible: false)@@ -159,16 +158,16 @@ RSpec.describe "Meetings CRUD",expect(wp_item).to be_present# Can edit and validate a work package item- show_page.edit_agenda_item(wp_item) do+ show_page.edit_agenda_item(wp_item, save: false) doshow_page.clear_item_edit_work_package_title- click_on "Save"+ click_on "Save" # triggers an errorendshow_page.expect_item_edit_field_error(wp_item, "Work package can't be blank.")show_page.cancel_edit_form(wp_item)# Keeping the editing state of an agenda item while modifying other items- show_page.edit_agenda_item(second) do+ show_page.edit_agenda_item(second, save: false) dofill_in "Title", with: "Second edited"end@@ -185,7 +184,6 @@ RSpec.describe "Meetings CRUD",show_page.edit_agenda_item(my_item) dofill_in "Title", with: "My agenda item edited"- click_on "Save"endshow_page.remove_agenda_item my_item@@ -275,12 +273,12 @@ RSpec.describe "Meetings CRUD",show_page.expect_agenda_item title: "My agenda item"item = MeetingAgendaItem.find_by!(title: "My agenda item")- show_page.edit_agenda_item(item) do+ show_page.edit_agenda_item(item, save: false) do# Side effect: update the itemitem.update!(title: "Updated title")fill_in "Title", with: "My agenda item edited"- click_on "Save"+ click_on "Save" # triggers an errorendexpect(page).to have_css(".flash", text: I18n.t("activerecord.errors.messages.error_conflict"))@@ -489,7 +487,6 @@ RSpec.describe "Meetings CRUD",show_page.edit_agenda_item(item_in_second_section) dofill_in "Duration", with: "15"- click_on "Save"end# duration gets updateddiff --git a/modules/meeting/spec/features/structured_meetings/structured_meeting_update_flash_spec.rb b/modules/meeting/spec/features/structured_meetings/structured_meeting_update_flash_spec.rbindex cc9e4cedb86..fb859e3a30b 100644--- a/modules/meeting/spec/features/structured_meetings/structured_meeting_update_flash_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_update_flash_spec.rb@@ -94,7 +94,6 @@ RSpec.describe "Meetings CRUD",show_page.edit_agenda_item(item) dofill_in "Title", with: "Updated title"- show_page.click_save_and_wait_for_agenda_item_updateend# Expect no notification in window1@@ -284,8 +283,6 @@ RSpec.describe "Meetings CRUD",item = MeetingAgendaItem.find_by(title: "Backlog agenda item")next_occurrence_page.edit_agenda_item(item) dofill_in "Title", with: "Edited title"- click_on "Save"- sleep 0.5 # wait for save to applyendnext_occurrence_page.trigger_change_polldiff --git a/modules/meeting/spec/features/structured_meetings/update_flash_shared_examples.rb b/modules/meeting/spec/features/structured_meetings/update_flash_shared_examples.rbindex eee406a1095..534f06732ba 100644--- a/modules/meeting/spec/features/structured_meetings/update_flash_shared_examples.rb+++ b/modules/meeting/spec/features/structured_meetings/update_flash_shared_examples.rb@@ -51,8 +51,6 @@ RSpec.shared_examples "no flash appears when interacting with backlog in multiplitem = MeetingAgendaItem.find_by(title: "Backlog agenda item")show_page.edit_agenda_item(item) dofill_in "Title", with: "Edited title"- click_on "Save"- sleep 1 # cannot use `show_page.click_save_and_wait_for_agenda_item_update` because of `travel_to`endshow_page.trigger_change_polldiff --git a/modules/meeting/spec/support/pages/meetings/show.rb b/modules/meeting/spec/support/pages/meetings/show.rbindex 740f4a1de2e..f15304c246d 100644--- a/modules/meeting/spec/support/pages/meetings/show.rb+++ b/modules/meeting/spec/support/pages/meetings/show.rb@@ -384,6 +384,8 @@ module Pages::Meetingsendend+ # Clicks "Save" button and waits until the number of agenda items in the database has+ # changed.def click_save_and_wait_for_agenda_item_creationinitial_db_items_count = MeetingAgendaItem.countclick_on("Save")@@ -396,13 +398,14 @@ module Pages::MeetingsMeetingAgendaItem.maximum(:id)end- # warning: does not work when using `travel_to` because time is stopped.+ # Clicks "Save" button and waits until some agenda items have a different+ # `lock_version` value in the database.def click_save_and_wait_for_agenda_item_update- initial_db_items_updated_at = MeetingAgendaItem.order(:id).pluck(:updated_at)+ initial_db_items_versions = MeetingAgendaItem.order(:id).pluck(:lock_version)click_on("Save")# wait for db save- wait_for { MeetingAgendaItem.order(:id).pluck(:updated_at) }.not_to eq(initial_db_items_updated_at)+ wait_for { MeetingAgendaItem.order(:id).pluck(:lock_version) }.not_to eq(initial_db_items_versions)enddef select_backlog_action(action)@@ -439,10 +442,15 @@ module Pages::Meetingsendend- def edit_agenda_item(item, &)+ def edit_agenda_item(item, save: true, &)select_action item, "Edit"expect_item_edit_form(item)- page.within("#meeting-agenda-items-form-component-#{item.id}", &)+ page.within("#meeting-agenda-items-form-component-#{item.id}") do+ yield+ if save+ click_save_and_wait_for_agenda_item_update+ end+ endenddef expect_item_edit_form(item, visible: true)