mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-04 15:13:41 +08:00
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.
26 lines
564 B
Ruby
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
|