-
Notifications
You must be signed in to change notification settings - Fork 52
DEV: Prevent multiple instances of same locale cookie due to path #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "\u{1F36A}"
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,84 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| RSpec.describe "Anonymous user language switcher", type: :system do | ||
| fab!(:japanese_user) { Fabricate(:user, locale: "ja") } | ||
| SWITCHER_SELECTOR = "button[data-identifier='discourse-translator_language-switcher']" | ||
|
|
||
| it "shows the correct language based on the selected language and login status" do | ||
| SWITCHER_SELECTOR = "button[data-identifier='discourse-translator_language-switcher']" | ||
| let(:topic_page) { PageObjects::Pages::Topic.new } | ||
|
|
||
| visit("/") | ||
| expect(page).not_to have_css(SWITCHER_SELECTOR) | ||
| fab!(:japanese_user) { Fabricate(:user, locale: "ja") } | ||
| fab!(:topic) do | ||
| topic = Fabricate(:topic, title: "Life strategies from The Art of War") | ||
| topic.set_detected_locale("en") | ||
| topic.set_translation("ja", "孫子兵法からの人生戦略") | ||
| topic.set_translation("es", "Estrategias de vida de El arte de la guerra") | ||
| topic | ||
| end | ||
|
|
||
| it "only shows the language switcher based on what is in target languages" do | ||
| SiteSetting.translator_enabled = true | ||
| SiteSetting.allow_user_locale = true | ||
| SiteSetting.set_locale_from_cookie = true | ||
| SiteSetting.automatic_translation_backfill_rate = 1 | ||
| SiteSetting.automatic_translation_target_languages = "es|ja" | ||
| SiteSetting.experimental_anon_language_switcher = true | ||
| visit("/") | ||
|
|
||
| expect(page).to have_css(SWITCHER_SELECTOR) | ||
| expect(find(".nav-item_latest")).to have_content("Latest") | ||
|
|
||
| switcher = PageObjects::Components::DMenu.new(SWITCHER_SELECTOR) | ||
| switcher.expand | ||
| expect(switcher).to have_content("日本語") | ||
| expect(switcher).to have_content("Español") | ||
|
|
||
| SiteSetting.automatic_translation_target_languages = "es" | ||
| SiteSetting.experimental_anon_language_switcher = true | ||
| visit("/") | ||
|
|
||
| switcher.expand | ||
| expect(switcher).not_to have_content("日本語") | ||
| switcher.click_button("Español") | ||
| expect(find(".nav-item_latest")).to have_content("Recientes") | ||
| end | ||
|
|
||
| sign_in(japanese_user) | ||
| visit("/") | ||
| expect(find(".nav-item_latest")).to have_content("最新") | ||
| describe "with Spanish and Japanese" do | ||
| before do | ||
| SiteSetting.translator_enabled = true | ||
| SiteSetting.allow_user_locale = true | ||
| SiteSetting.set_locale_from_cookie = true | ||
| SiteSetting.automatic_translation_backfill_rate = 1 | ||
| SiteSetting.automatic_translation_target_languages = "es|ja" | ||
| SiteSetting.experimental_anon_language_switcher = true | ||
| end | ||
|
|
||
| it "shows the correct language based on the selected language and login status" do | ||
| visit("/") | ||
| expect(find(".nav-item_latest")).to have_content("Latest") | ||
|
|
||
| switcher = PageObjects::Components::DMenu.new(SWITCHER_SELECTOR) | ||
nattsw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| switcher.expand | ||
| switcher.click_button("Español") | ||
| expect(find(".nav-item_latest")).to have_content("Recientes") | ||
|
|
||
| sign_in(japanese_user) | ||
| visit("/") | ||
| expect(find(".nav-item_latest")).to have_content("最新") | ||
| end | ||
|
|
||
| it "shows the most recently selected language" do | ||
| visit("/") | ||
|
|
||
| switcher = PageObjects::Components::DMenu.new(SWITCHER_SELECTOR) | ||
| switcher.expand | ||
| switcher.click_button("Español") | ||
| expect(find(".nav-item_latest")).to have_content("Recientes") | ||
|
|
||
| topic_page.visit_topic(topic) | ||
| topic_page.has_topic_title?("Estrategias de vida de El arte de la guerra") | ||
|
|
||
| switcher.expand | ||
| switcher.click_button("日本語") | ||
| topic_page.visit_topic(topic) | ||
| topic_page.has_topic_title?("孫子兵法からの人生戦略") | ||
|
|
||
| visit("/") | ||
| expect(find(".nav-item_latest")).to have_content("最新") | ||
| end | ||
| end | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.