|
51 | 51 | author: user |
52 | 52 | end |
53 | 53 |
|
54 | | - shared_let(:meeting_section) { create(:meeting_section, meeting:, position: 1) } |
55 | | - shared_let(:first_agenda_item) { create(:meeting_agenda_item, meeting:, meeting_section:, title: "First Item", position: 1) } |
56 | | - shared_let(:second_agenda_item) { create(:meeting_agenda_item, meeting:, meeting_section:, title: "Second Item", position: 2) } |
| 54 | + shared_let(:first_meeting_section) { create(:meeting_section, meeting:, title: "Blockers", position: 1) } |
| 55 | + shared_let(:second_meeting_section) { create(:meeting_section, meeting:, title: "Other topics", position: 2) } |
| 56 | + shared_let(:first_agenda_item) { create(:meeting_agenda_item, meeting:, meeting_section: first_meeting_section, title: "First Item", position: 1) } |
| 57 | + shared_let(:second_agenda_item) { create(:meeting_agenda_item, meeting:, meeting_section: first_meeting_section, title: "Second Item", position: 2) } |
| 58 | + shared_let(:third_agenda_item) { create(:meeting_agenda_item, meeting:, meeting_section: second_meeting_section, title: "Third Item", position: 1) } |
57 | 59 |
|
58 | 60 | let(:show_page) { Pages::Meetings::Show.new(meeting) } |
59 | 61 | let(:editor) { Components::WysiwygEditor.new "#meetings-presentation-component", "opce-ckeditor-augmented-textarea" } |
@@ -85,26 +87,68 @@ def outcome_field_for(agenda_item) |
85 | 87 | expect(page).to have_text("First Item") |
86 | 88 | expect(page).to have_link("Next") |
87 | 89 | expect(page).to have_button("Previous", disabled: true) |
88 | | - expect(page).to have_text("1 of 2") |
| 90 | + expect(page).to have_text("1 of 3") |
| 91 | + |
| 92 | + within_test_selector("meeting-presentation-header") do |
| 93 | + expect(page).to have_text("Blockers") |
| 94 | + end |
| 95 | + |
| 96 | + within_test_selector("meeting-presentation-footer") do |
| 97 | + expect(page).to have_text("Second Item") |
| 98 | + expect(page).to have_no_text("Blockers") |
| 99 | + expect(page).to have_no_text("Other topics") |
| 100 | + end |
89 | 101 |
|
90 | 102 | # 1. Navigate between agenda items |
91 | 103 | click_link_or_button "Next" |
92 | 104 |
|
93 | | - expect(page).to have_text("Second Item") |
94 | | - expect(page).to have_no_text("First Item") |
95 | | - expect(page).to have_link("Previous") |
96 | | - expect(page).to have_button("Next", disabled: true) |
97 | | - expect(page).to have_text("2 of 2") |
| 105 | + within_test_selector("meeting-presentation-agenda-item") do |
| 106 | + expect(page).to have_text("Second Item") |
| 107 | + expect(page).to have_text("First Item") |
| 108 | + end |
| 109 | + |
| 110 | + within_test_selector("meeting-presentation-footer") do |
| 111 | + expect(page).to have_text("First item") |
| 112 | + expect(page).to have_text("Third item") |
| 113 | + expect(page).to have_no_text("Blockers") |
| 114 | + expect(page).to have_text("Other topics") |
| 115 | + expect(page).to have_link("Previous") |
| 116 | + expect(page).to have_link("Next") |
| 117 | + end |
| 118 | + |
| 119 | + expect(page).to have_text("2 of 3") |
| 120 | + |
| 121 | + # 1. Navigate between agenda items |
| 122 | + click_link_or_button "Next" |
| 123 | + |
| 124 | + within_test_selector("meeting-presentation-agenda-item") do |
| 125 | + expect(page).to have_text("Third Item") |
| 126 | + expect(page).to have_no_text("First Item") |
| 127 | + expect(page).to have_no_text("Second Item") |
| 128 | + end |
| 129 | + |
| 130 | + # On third item, footer shows second item and first item |
| 131 | + within_test_selector("meeting-presentation-footer") do |
| 132 | + # Shows second item with section |
| 133 | + expect(page).to have_text("Second item") |
| 134 | + expect(page).to have_text("Blockers") |
| 135 | + |
| 136 | + # Doesn't show first item or current section |
| 137 | + expect(page).to have_no_text("First item") |
| 138 | + expect(page).to have_no_text("Other topics") |
| 139 | + expect(page).to have_link("Previous") |
| 140 | + expect(page).to have_button("Next", disabled: true) |
| 141 | + end |
| 142 | + |
| 143 | + expect(page).to have_text("3 of 3") |
98 | 144 |
|
99 | 145 | click_link_or_button "Previous" |
| 146 | + expect(page).to have_text("2 of 3") |
100 | 147 |
|
101 | | - expect(page).to have_text("First Item") |
102 | | - expect(page).to have_no_text("Second Item") |
103 | | - expect(page).to have_link("Next") |
| 148 | + click_link_or_button "Previous" |
| 149 | + expect(page).to have_text("1 of 3") |
104 | 150 | expect(page).to have_button("Previous", disabled: true) |
105 | 151 |
|
106 | | - expect(page).to have_text("1 of 2") |
107 | | - |
108 | 152 | # 2. Edit an agenda item (add notes) |
109 | 153 | item = MeetingAgendaItem.find(first_agenda_item.id) |
110 | 154 |
|
@@ -154,6 +198,39 @@ def outcome_field_for(agenda_item) |
154 | 198 | expect(page).to have_current_path(project_meeting_path(project, meeting), ignore_query: true) |
155 | 199 | end |
156 | 200 |
|
| 201 | + it "automatically refreshes when things get updated" do |
| 202 | + visit project_meeting_presentation_path(project, meeting) |
| 203 | + expect(page).to have_css(".op-meeting-presentation") |
| 204 | + expect(page).to have_text("Sprint Planning") |
| 205 | + expect(page).to have_text("First Item") |
| 206 | + |
| 207 | + # In the background, update the first agenda item |
| 208 | + MeetingAgendaItems::UpdateService |
| 209 | + .new(model: first_agenda_item, user: User.system) |
| 210 | + .call(title: "Updated item") |
| 211 | + .on_failure { |result| raise "Failed to update agenda item in background: #{result.errors.full_messages}" } |
| 212 | + |
| 213 | + # In the background, delete the second item |
| 214 | + # so that the "new" second item is now the third one |
| 215 | + MeetingAgendaItems::DeleteService |
| 216 | + .new(model: second_agenda_item, user: User.system) |
| 217 | + .call |
| 218 | + .on_failure { |result| raise "Failed to update agenda item in background: #{result.errors.full_messages}" } |
| 219 | + |
| 220 | + # Wait for the changes to appear |
| 221 | + expect(page).to have_text("Updated item", wait: 10) |
| 222 | + expect(page).to have_no_text("Second Item") |
| 223 | + |
| 224 | + # On third item, footer shows second item and first item |
| 225 | + within_test_selector("meeting-presentation-footer") do |
| 226 | + # Shows second item with section |
| 227 | + expect(page).to have_text("Third Item") |
| 228 | + expect(page).to have_text("Other topics") |
| 229 | + expect(page).to have_no_text("Second Item") |
| 230 | + expect(page).to have_no_text("Blockers") |
| 231 | + end |
| 232 | + end |
| 233 | + |
157 | 234 | context "with an empty meeting" do |
158 | 235 | let(:meeting) do |
159 | 236 | create :meeting, |
|
0 commit comments