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
added basic section specs as feature specs
Jonas Jabari1d216d75517a
diff --git a/modules/meeting/app/components/meeting_sections/header_component.rb b/modules/meeting/app/components/meeting_sections/header_component.rbindex a8b275e320d..151c9a24d01 100644--- a/modules/meeting/app/components/meeting_sections/header_component.rb+++ b/modules/meeting/app/components/meeting_sections/header_component.rb@@ -49,7 +49,7 @@ module MeetingSectionsdef wrapper_data_attributes{- test_selector: "meeting-section-container-#{@meeting_section.id}"+ test_selector: "meeting-section-header-container-#{@meeting_section.id}"}enddiff --git a/modules/meeting/app/components/meeting_sections/show_component.html.erb b/modules/meeting/app/components/meeting_sections/show_component.html.erbindex 45a7315ef69..af760927a6a 100644--- a/modules/meeting/app/components/meeting_sections/show_component.html.erb+++ b/modules/meeting/app/components/meeting_sections/show_component.html.erb@@ -1,39 +1,37 @@<%=component_wrapper(class: "op-meeting-section-container", data: { test_selector: "meeting-section-container-#{@meeting_section.id}" }.merge(draggable_item_config)) do- unless hide_section?- render(Primer::Beta::BorderBox.new(mt: top_margin, data: drag_and_drop_target_config)) do |component|- if render_section_wrapper?- component.with_header(font_weight: :bold, pl: 0) do- render(MeetingSections::HeaderComponent.new(meeting_section: @meeting_section))- end+ render(Primer::Beta::BorderBox.new(mt: top_margin, data: drag_and_drop_target_config)) do |component|+ if render_section_wrapper?+ component.with_header(font_weight: :bold, pl: 0) do+ render(MeetingSections::HeaderComponent.new(meeting_section: @meeting_section))end- if render_new_button_in_section?- component.with_row(data: { 'empty-list-item': true }) do- flex_layout(align_items: :center, justify_content: :space_between) do |empty_list_container|- empty_list_container.with_column(mr: 2) do- render(Primer::Beta::Text.new(color: :subtle)) { "Drag items here or create a new one" } # TODO: i18n- end- empty_list_container.with_column do- render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting, meeting_section: @meeting_section))- end+ end+ if render_new_button_in_section?+ component.with_row(data: { 'empty-list-item': true }) do+ flex_layout(align_items: :center, justify_content: :space_between) do |empty_list_container|+ empty_list_container.with_column(mr: 2) do+ render(Primer::Beta::Text.new(color: :subtle)) { "Drag items here or create a new one" } # TODO: i18n+ end+ empty_list_container.with_column do+ render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting, meeting_section: @meeting_section))end- end- else- first_and_last = [@meeting_agenda_items.first, @meeting_agenda_items.last]- @meeting_agenda_items.each do |agenda_item|- render(- MeetingAgendaItems::ItemComponent.new(- meeting_agenda_item: agenda_item,- container: component,- first_and_last:- )- )endend- component.with_row(p: 0, border_top: 0, id: insert_target_modifier_id) do- render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, meeting_section: @meeting_section, hidden: @form_hidden, type: @form_type))+ else+ first_and_last = [@meeting_agenda_items.first, @meeting_agenda_items.last]+ @meeting_agenda_items.each do |agenda_item|+ render(+ MeetingAgendaItems::ItemComponent.new(+ meeting_agenda_item: agenda_item,+ container: component,+ first_and_last:+ )+ )endend+ component.with_row(p: 0, border_top: 0, id: insert_target_modifier_id) do+ render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, meeting_section: @meeting_section, hidden: @form_hidden, type: @form_type))+ endendend%>diff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rbindex d3249374006..9fc298faf58 100644--- a/modules/meeting/app/components/meeting_sections/show_component.rb+++ b/modules/meeting/app/components/meeting_sections/show_component.rb@@ -63,11 +63,6 @@ module MeetingSections@meeting_section.editable? && User.current.allowed_in_project?(:manage_agendas, @meeting_section.project)end- def hide_section?- false- # @meeting.sections.count == 1 && @meeting_agenda_items.empty? && @meeting_section.untitled?- end-def render_section_wrapper?# true!@meeting_section.untitled? || @meeting.sections.count > 1diff --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 7811151dfcf..71b194955a8 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@@ -311,4 +311,133 @@ RSpec.describe "Structured meetings CRUD",expect(page).to have_no_text "Private task"endend++ context "with sections" do+ let!(:meeting) { create(:structured_meeting, project:, author: current_user) }+ let(:show_page) { Pages::StructuredMeeting::Show.new(meeting) }++ context "when starting with empty sections" do+ it "can add, edit and delete sections" do+ show_page.expect_toast(message: "Successful creation")++ # create the first section+ show_page.add_section do+ fill_in "Title", with: "First section"+ click_on "Save"+ end++ show_page.expect_section(title: "First section")++ first_section = MeetingSection.find_by!(title: "First section")++ # edit the first section+ show_page.edit_section(first_section) do+ fill_in "Title", with: "Updated first section title"+ click_on "Save"+ end++ show_page.expect_no_section title: "First section"+ show_page.expect_section title: "Updated first section title"++ # add a second section+ show_page.add_section do+ fill_in "Title", with: "Second section"+ click_on "Save"+ end++ show_page.expect_section(title: "Updated first section title")+ show_page.expect_section(title: "Second section")++ second_section = MeetingSection.find_by!(title: "Second section")++ # remove the second section+ show_page.remove_section second_section++ ## the first section is still rendered explicitly, as a name was specified+ show_page.expect_section(title: "Updated first section title")+ show_page.expect_no_section(title: "Second section")++ # add a section without a name+ show_page.add_section do+ click_on "Save"+ end++ ## "Untitled" is applied automatically as a name+ show_page.expect_section(title: "Updated first section title")+ show_page.expect_section(title: "Untitled")++ # remove the first section+ show_page.remove_section first_section++ ## the last existing section is not explicitly rendered as a section as no name was specified for this section+ ## -> back to "no section mode"+ show_page.expect_no_section(title: "Updated first section title")+ show_page.expect_no_section(title: "Untitled")++ # add a second section again+ show_page.add_section do+ fill_in "Title", with: "Second section"+ click_on "Save"+ end++ ## the first section without a name is now explicitly rendered as "Untitled"+ show_page.expect_section(title: "Untitled")+ show_page.expect_section(title: "Second section")++ second_section = MeetingSection.find_by!(title: "Second section")++ # add an item to the latest section+ show_page.add_agenda_item do+ fill_in "Title", with: "First item"+ fill_in "min", with: "25"+ end++ show_page.expect_agenda_item_in_section title: "First item", section: second_section++ first_section = MeetingSection.find_by!(title: "Untitled")++ # add an item to the first section explicitly+ show_page.add_agenda_item_to_section(section: first_section) do+ fill_in "Title", with: "Second item"+ fill_in "min", with: "30"+ end++ show_page.expect_agenda_item_in_section title: "Second item", section: first_section++ # duration per section is shown+ show_page.expect_section_duration(section: first_section, duration_text: "30 min")+ show_page.expect_section_duration(section: second_section, duration_text: "25 min")++ item_in_first_section = MeetingAgendaItem.find_by!(title: "Second item")+ item_in_second_section = MeetingAgendaItem.find_by!(title: "First item")++ show_page.edit_agenda_item(item_in_second_section) do+ fill_in "min", with: "15"+ click_on "Save"+ end++ # duration gets updated+ show_page.expect_section_duration(section: second_section, duration_text: "15 min")++ # deleting a section with agenda items is not possible+ show_page.select_section_action(second_section, "Delete") # delete is disabled+ ## -> no effect+ show_page.expect_section(title: "Untitled")+ show_page.expect_section(title: "Second section")++ show_page.click_on_section_menu(second_section) # close the menu again++ # deleting a section without agenda items is possible+ show_page.remove_agenda_item(item_in_second_section)+ show_page.remove_section(second_section) # empty secion gets deleted++ # only untitle secion is left -> will not be rendered explicitly as secion+ show_page.expect_no_section(title: "Untitled")+ show_page.expect_no_section(title: "Second section")++ # the agenda items of the "untitled" section are still visible in "no-section mode"+ show_page.expect_agenda_item(title: item_in_first_section.title)+ end+ end+ endenddiff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rbindex c29e6254e19..3370db6ed29 100644--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb@@ -55,6 +55,17 @@ module Pages::StructuredMeetingendend+ def add_agenda_item_to_section(section:, type: MeetingAgendaItem, save: true, &)+ select_section_action(section, type.model_name.human)++ within("#meeting-sections-show-component-#{section.id}") do+ in_agenda_form do+ yield+ click_on("Save") if save+ end+ end+ end+def cancel_edit_form(item)in_edit_form(item) doclick_on I18n.t(:button_cancel)@@ -91,6 +102,12 @@ module Pages::StructuredMeetingexpect(page).to have_test_selector("op-meeting-agenda-title", text: title)end+ def expect_agenda_item_in_section(title:, section:)+ within("#meeting-sections-show-component-#{section.id}") do+ expect_agenda_item(title:)+ end+ end+def expect_agenda_link(item)if item.is_a?(WorkPackage)expect(page).to have_css("[id^='meeting-agenda-items-item-component-']", text: item.subject)@@ -125,6 +142,23 @@ module Pages::StructuredMeetingendend+ def select_section_action(section, action)+ retry_block do+ click_on_section_menu(section)+ page.find(".Overlay")+ end++ page.within(".Overlay") do+ click_on action+ end+ end++ def click_on_section_menu(section)+ page.within_test_selector("meeting-section-header-container-#{section.id}") do+ page.find_test_selector("meeting-section-action-menu").click+ end+ end+def edit_agenda_item(item, &)select_action item, "Edit"expect_item_edit_form(item)@@ -196,5 +230,46 @@ module Pages::StructuredMeetingdef meeting_details_containerfind_by_id("meetings-sidebar-details-component")end++ def in_latest_section_form(&)+ page.within(all(".op-meeting-section-container").last, &)+ end++ def add_section(&)+ page.within("#meeting-agenda-items-new-button-component") do+ click_on I18n.t(:button_add)+ click_on "Section"+ # wait for the disabled button, indicating the turbo streams are applied+ expect(page).to have_css("#meeting-agenda-items-new-button-component button[disabled='disabled']")+ end++ in_latest_section_form(&)+ end++ def expect_section(title:)+ expect(page).to have_css(".op-meeting-section-container", text: title)+ end++ def expect_no_section(title:)+ expect(page).to have_no_css(".op-meeting-section-container", text: title)+ end++ def expect_section_duration(section:, duration_text:)+ page.within_test_selector("meeting-section-header-container-#{section.id}") do+ expect(page).to have_text(duration_text)+ end+ end++ def edit_section(section, &)+ select_section_action(section, "Edit")++ page.within_test_selector("meeting-section-header-container-#{section.id}", &)+ end++ def remove_section(section)+ accept_confirm do+ select_section_action(section, "Delete")+ end+ endendend