Skip to content

A platform for community discussion. Free, open, simple.

FIX: Persist reviewable notes when toggle tabs (#35495)

Krzysztof Kotlarek6e39bb9728e6
diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/item.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/item.gjs
index d4c3e662178..eddc67b0d29 100644
--- a/app/assets/javascripts/discourse/app/components/reviewable-refresh/item.gjs
+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/item.gjs
@@ -21,6 +21,7 @@ import ReviewableCreatedBy from "discourse/components/reviewable-created-by";
import ReviewableFlagReason from "discourse/components/reviewable-refresh/flag-reason";
import ReviewableInsights from "discourse/components/reviewable-refresh/insights";
import ReviewableTimeline from "discourse/components/reviewable-refresh/timeline";
+import concatClass from "discourse/helpers/concat-class";
import icon from "discourse/helpers/d-icon";
import { newReviewableStatus } from "discourse/helpers/reviewable-status";
import { ajax } from "discourse/lib/ajax";
@@ -620,7 +621,12 @@ export default class ReviewableItem extends Component {
@ariaLabel="Review tabs"
class="d-nav-submenu__tabs"
>
- <li class={{if (eq this.activeTab "insights") "active"}}>
+ <li
+ class={{concatClass
+ "insights"
+ (if (eq this.activeTab "insights") "active")
+ }}
+ >
<a
href="#"
class={{if (eq this.activeTab "insights") "active"}}
@@ -629,7 +635,12 @@ export default class ReviewableItem extends Component {
{{i18n "review.insights.title"}}
</a>
</li>
- <li class={{if (eq this.activeTab "timeline") "active"}}>
+ <li
+ class={{concatClass
+ "timeline"
+ (if (eq this.activeTab "timeline") "active")
+ }}
+ >
<a
href="#"
class={{if (eq this.activeTab "timeline") "active"}}
diff --git a/app/assets/javascripts/discourse/app/components/reviewable-refresh/timeline.gjs b/app/assets/javascripts/discourse/app/components/reviewable-refresh/timeline.gjs
index e34ffda9752..b234c8bdb4e 100644
--- a/app/assets/javascripts/discourse/app/components/reviewable-refresh/timeline.gjs
+++ b/app/assets/javascripts/discourse/app/components/reviewable-refresh/timeline.gjs
@@ -184,6 +184,7 @@ export default class ReviewableTimeline extends Component {
}
this.reviewableNotes = [...this.reviewableNotes, noteData];
+ this.args.reviewable.reviewable_notes = this.reviewableNotes;
}
/**
diff --git a/spec/system/page_objects/components/review_note_form.rb b/spec/system/page_objects/components/review_note_form.rb
new file mode 100644
index 00000000000..af2e3d75990
--- /dev/null
+++ b/spec/system/page_objects/components/review_note_form.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+module PageObjects
+ module Components
+ class ReviewNoteForm < PageObjects::Components::Base
+ def add_note(note)
+ form.fill_in("note", with: note)
+ form.submit
+ end
+
+ def form
+ @form ||= PageObjects::Components::FormKit.new(".reviewable-note-form__form")
+ end
+ end
+ end
+end
diff --git a/spec/system/page_objects/pages/review.rb b/spec/system/page_objects/pages/review.rb
index 4c66bff6b28..aac27b17c24 100644
--- a/spec/system/page_objects/pages/review.rb
+++ b/spec/system/page_objects/pages/review.rb
@@ -154,6 +154,14 @@ module PageObjects
PageObjects::Components::Review::TopicLink.new
end
+ def click_timeline_tab
+ find(".action-list li.timeline").click
+ end
+
+ def click_insights_tab
+ find(".action-list li.insights").click
+ end
+
private
def reviewable_action_dropdown
diff --git a/spec/system/viewing_reviewable_spec.rb b/spec/system/viewing_reviewable_spec.rb
index e2a26c7b09f..325ac6a5911 100644
--- a/spec/system/viewing_reviewable_spec.rb
+++ b/spec/system/viewing_reviewable_spec.rb
@@ -6,6 +6,7 @@ describe "Viewing reviewable item", type: :system do
fab!(:reviewable_flagged_post)
let(:review_page) { PageObjects::Pages::Review.new }
+ let(:review_note_form) { PageObjects::Components::ReviewNoteForm.new }
describe "when user is part of the groups list of the `reviewable_ui_refresh` site setting" do
before do
@@ -105,6 +106,15 @@ describe "Viewing reviewable item", type: :system do
# TODO: Add test for watched words highlighting
end
+
+ it "allows to add notes and persists them when toggle tabs" do
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_timeline_tab
+ review_note_form.add_note("This is a review note.")
+ review_page.click_insights_tab
+ review_page.click_timeline_tab
+ expect(page).to have_text("This is a review note.")
+ end
end
end
end