A platform for community discussion. Free, open, simple.
FIX: correctly allow to translate my messages (#33586)
Joffrey JAFFEUX226bc5c35968
diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-messages-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-messages-section-link.jsindex 70f018095d8..6a7067fb451 100644--- a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-messages-section-link.js+++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-messages-section-link.js@@ -15,12 +15,14 @@ export default class MyMessagesSectionLink extends BaseSectionLink {}get title() {- return i18n("sidebar.sections.community.links.my_messages.content");+ return i18n("sidebar.sections.community.links.my_messages.title");}get text() {return i18n(- `sidebar.sections.community.links.${this.overridenName.toLowerCase()}.content`,+ `sidebar.sections.community.links.${this.overridenName+ .toLowerCase()+ .replace(" ", "_")}.content`,{ defaultValue: this.overridenName });}diff --git a/spec/system/page_objects/components/navigation_menu/sidebar.rb b/spec/system/page_objects/components/navigation_menu/sidebar.rbindex 0c6ade79739..650918fc615 100644--- a/spec/system/page_objects/components/navigation_menu/sidebar.rb+++ b/spec/system/page_objects/components/navigation_menu/sidebar.rb@@ -78,10 +78,10 @@ module PageObjectsI18n.t("js.sidebar.sections.community.links.my_messages.content")end- def has_my_messages_link?+ def has_my_messages_link?(text = my_messages)page.has_css?(".sidebar-section-link[data-link-name='#{my_messages.downcase.parameterize}']",- text: my_messages,+ text:,)enddiff --git a/spec/system/viewing_sidebar_spec.rb b/spec/system/viewing_sidebar_spec.rbindex 03e4c9bdab2..0be823abfb0 100644--- a/spec/system/viewing_sidebar_spec.rb+++ b/spec/system/viewing_sidebar_spec.rb@@ -3,7 +3,7 @@describe "Viewing sidebar", type: :system dolet(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }- context "as logged in user", type: :system do+ context "as logged in user" dofab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }fab!(:category_sidebar_section_link) { Fabricate(:category_sidebar_section_link, user: user) }@@ -36,7 +36,7 @@ describe "Viewing sidebar", type: :system doendend- describe "Community sidebar section", type: :system do+ describe "Community sidebar section" dofab!(:user) { Fabricate(:user, locale: "pl_PL") }fab!(:translation_override) doTranslationOverride.create!(@@ -180,6 +180,22 @@ describe "Viewing sidebar", type: :system dovisit("/")expect(sidebar).to have_no_my_messages_linkend++ context "with translation override" do+ fab!(:translation_override) do+ TranslationOverride.create!(+ locale: "en",+ translation_key: "js.sidebar.sections.community.links.my_messages.content",+ value: "Overrided",+ )+ end++ it "is translated" do+ sign_in(admin)+ visit("/")+ expect(sidebar).to have_my_messages_link("Overrided")+ end+ endendit "shouldn't display the panel header for the main sidebar" do@@ -189,7 +205,7 @@ describe "Viewing sidebar", type: :system doendend- context "as anonymous user", type: :system do+ context "as anonymous user" dodescribe "My messages sidebar link" doit "shouldn't show for anonymous user" dovisit("/")