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.gjsindex 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")+ }}+ ><ahref="#"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")+ }}+ ><ahref="#"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.gjsindex 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.rbnew file mode 100644index 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+enddiff --git a/spec/system/page_objects/pages/review.rb b/spec/system/page_objects/pages/review.rbindex 4c66bff6b28..aac27b17c24 100644--- a/spec/system/page_objects/pages/review.rb+++ b/spec/system/page_objects/pages/review.rb@@ -154,6 +154,14 @@ module PageObjectsPageObjects::Components::Review::TopicLink.newend+ def click_timeline_tab+ find(".action-list li.timeline").click+ end++ def click_insights_tab+ find(".action-list li.insights").click+ end+privatedef reviewable_action_dropdowndiff --git a/spec/system/viewing_reviewable_spec.rb b/spec/system/viewing_reviewable_spec.rbindex 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 dofab!(: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" dobefore do@@ -105,6 +106,15 @@ describe "Viewing reviewable item", type: :system do# TODO: Add test for watched words highlightingend++ 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.")+ endendendend