Skip to content

Commit a1c95dd

Browse files
Add spec for refresh
1 parent 316c6df commit a1c95dd

File tree

7 files changed

+121
-33
lines changed

7 files changed

+121
-33
lines changed

modules/meeting/app/components/meetings/presentation_mode/footer_component.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<%= component_wrapper(class: "op-meeting-presentation--footer") do %>
1+
<%= component_wrapper(class: "op-meeting-presentation--footer",
2+
data: { "test-selector": "meeting-presentation-footer" }) do %>
23
<div class="op-meeting-presentation--footer-left">
34
<%= render(Primer::Beta::Button.new(
45
tag: :a,

modules/meeting/app/components/meetings/presentation_mode/header_component.html.erb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<%=
2-
component_wrapper do
1+
<%= component_wrapper(data: { "test-selector": "meeting-presentation-header" }) do %>
2+
<%=
33
render Primer::OpenProject::PageHeader.new(classes: "op-meeting-presentation-header") do |header|
44
header.with_breadcrumbs([])
55
header.with_title_content(@meeting.title)
@@ -17,5 +17,11 @@
1717
t(:"meeting.presentation_mode.exit")
1818
end
1919
end
20-
end
21-
%>
20+
%>
21+
<div class="op-meeting-presentation--header">
22+
<div class="op-meeting-presentation--header-title">
23+
<%= render(Primer::Beta::Text.new(color: :subtle)) { MeetingSection.model_name.human } %>:
24+
<%= render(Primer::Beta::Text.new(font_weight: :bold, color: :subtle)) { current_section.title } %>
25+
</div>
26+
</div>
27+
<% end %>

modules/meeting/app/components/meetings/presentation_mode/header_component.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,17 @@ module PresentationMode
3333
class HeaderComponent < ApplicationComponent
3434
include OpTurbo::Streamable
3535

36-
def initialize(meeting:)
36+
attr_reader :meeting, :current_item
37+
38+
def initialize(meeting:, current_item:)
3739
super()
3840

3941
@meeting = meeting
42+
@current_item = current_item
43+
end
44+
45+
def current_section
46+
current_item&.meeting_section
4047
end
4148
end
4249
end

modules/meeting/app/components/meetings/presentation_mode/show_component.html.erb

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,25 @@
55
zen_mode_autostart_value: @initial,
66
poll_for_changes_continuous_value: true,
77
poll_for_changes_url_value: check_for_updates_project_meeting_presentation_path(
8-
@meeting.project,
9-
@meeting,
8+
meeting.project,
9+
meeting,
1010
meeting_agenda_item_id: current_item.id,
1111
started_at: started_at_param
1212
),
1313
poll_for_changes_interval_value: check_for_updates_interval,
1414
}
1515
) do %>
16-
<%= render Meetings::PresentationMode::HeaderComponent.new(meeting: @meeting) %>
1716
<%= content_tag :div,
1817
id: "op-meeting-presentation-content",
1918
class: "op-meeting-presentation--content",
2019
data: {
2120
controller: "meetings--submit",
2221
poll_for_changes_target: "reference",
23-
reference_value: @meeting.changed_hash
22+
reference_value: meeting.changed_hash
2423
} do %>
25-
<div class="op-meeting-presentation--header">
26-
<div class="op-meeting-presentation--header-title">
27-
<%= render(Primer::Beta::Text.new(color: :subtle)) { MeetingSection.model_name.human } %>:
28-
<%= render(Primer::Beta::Text.new(font_weight: :bold, color: :subtle)) { current_section.title } %>
29-
</div>
30-
</div>
24+
<%= render Meetings::PresentationMode::HeaderComponent.new(meeting:, current_item:) %>
3125

32-
<%= render(border_box_container) do |container| %>
26+
<%= render(border_box_container(test_selector: "meeting-presentation-agenda-item")) do |container| %>
3327
<%= render MeetingAgendaItems::ItemComponent.new(
3428
container:,
3529
meeting_agenda_item: current_item,
@@ -39,7 +33,7 @@
3933
<% end %>
4034

4135
<%= render Meetings::PresentationMode::FooterComponent.new(
42-
meeting: @meeting,
36+
meeting: meeting,
4337
sorted_agenda_item_ids: @agenda_item_ids,
4438
current_item: current_item,
4539
started_at: @started_at

modules/meeting/app/components/meetings/presentation_mode/show_component.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class ShowComponent < ApplicationComponent
3535
include OpTurbo::Streamable
3636
include OpPrimer::ComponentHelpers
3737

38+
attr_reader :meeting
39+
3840
def initialize(meeting:, sorted_agenda_item_ids:, current_id: nil, started_at: nil)
3941
super()
4042

modules/meeting/app/controllers/concerns/meetings/presentation_component_streams.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def update_reference_value(new_reference)
5353
def update_header_via_turbo_stream
5454
update_via_turbo_stream(
5555
component: Meetings::PresentationMode::HeaderComponent.new(
56-
meeting: @meeting
56+
meeting: @meeting,
57+
current_item: @meeting_agenda_item
5758
)
5859
)
5960
end

modules/meeting/spec/features/presentation/meeting_presentation_mode_spec.rb

Lines changed: 91 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@
5151
author: user
5252
end
5353

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) }
5759

5860
let(:show_page) { Pages::Meetings::Show.new(meeting) }
5961
let(:editor) { Components::WysiwygEditor.new "#meetings-presentation-component", "opce-ckeditor-augmented-textarea" }
@@ -85,26 +87,68 @@ def outcome_field_for(agenda_item)
8587
expect(page).to have_text("First Item")
8688
expect(page).to have_link("Next")
8789
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
89101

90102
# 1. Navigate between agenda items
91103
click_link_or_button "Next"
92104

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")
98144

99145
click_link_or_button "Previous"
146+
expect(page).to have_text("2 of 3")
100147

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")
104150
expect(page).to have_button("Previous", disabled: true)
105151

106-
expect(page).to have_text("1 of 2")
107-
108152
# 2. Edit an agenda item (add notes)
109153
item = MeetingAgendaItem.find(first_agenda_item.id)
110154

@@ -154,6 +198,39 @@ def outcome_field_for(agenda_item)
154198
expect(page).to have_current_path(project_meeting_path(project, meeting), ignore_query: true)
155199
end
156200

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+
157234
context "with an empty meeting" do
158235
let(:meeting) do
159236
create :meeting,

0 commit comments

Comments
 (0)