discourse/spec/system/page_objects/components/language_switcher.rb
Natalie Tay 736f23173e
FIX: User options take precedence over show-original anon cookie (#39520)
Repro:
  1. anonymous user browsing
  2. sets content language switcher to "Japanese"
  3. sees japanese
  4. clicks on "show original" in the post
  5. sees original
  6. logs in to their account
7. (their account should see Japanese - UNCHECKED user pref "Show
original content instead of translated content.")
  8. BUG: but they see original because of the anon cookie
  
This PR fixes the bug by only using the user option if they're logged
in.
2026-04-25 00:44:20 +08:00

26 lines
564 B
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class LanguageSwitcher < PageObjects::Components::Base
SELECTOR = "button[data-identifier='language-switcher']"
def initialize
@menu = PageObjects::Components::DMenu.new(SELECTOR)
end
def visible?
page.has_css?(SELECTOR)
end
def not_visible?
page.has_no_css?(SELECTOR)
end
def select_language(locale)
@menu.expand
@menu.option("[data-menu-option-id='#{locale}']").click
end
end
end
end