-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Flaky test on locales spec (#499)
* fix: Try to fix flaky by authenticating user on each step * lint: Quick fixes
- Loading branch information
Showing
1 changed file
with
29 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -4,10 +4,12 @@ | |
|
||
describe "Locales", type: :system do | ||
describe "switching locales" do | ||
let(:organization) { create(:organization, available_locales: %w(fr en)) } | ||
let(:organization) { create(:organization, available_locales: %w(fr en), default_locale: "en") } | ||
let(:user) { create(:user, :confirmed, locale: "en", organization: organization) } | ||
|
||
before do | ||
switch_to_host(organization.host) | ||
login_as user, scope: :user | ||
visit decidim.root_path | ||
end | ||
|
||
|
@@ -37,40 +39,45 @@ | |
expect(page).to have_content("Accueil") | ||
end | ||
|
||
it "displays devise messages with the right locale when not authenticated" do | ||
within_language_menu do | ||
click_link "Français" | ||
end | ||
context "when not authenticated" do | ||
let(:user) { nil } | ||
|
||
visit decidim_admin.root_path | ||
it "displays devise messages with the right locale when not authenticated" do | ||
within_language_menu do | ||
click_link "Français" | ||
end | ||
|
||
expect(page).to have_content("Vous devez vous identifier ou vous créer un compte avant de continuer") | ||
end | ||
visit decidim_admin.root_path | ||
|
||
it "displays devise messages with the right locale when authentication fails" do | ||
within_language_menu do | ||
click_link "Français" | ||
expect(page).to have_content("Vous devez vous identifier ou vous créer un compte avant de continuer") | ||
end | ||
end | ||
|
||
context "when authentication fails" do | ||
let(:user) { nil } | ||
|
||
it "displays devise messages with the right locale" do | ||
within_language_menu do | ||
click_link "Français" | ||
end | ||
|
||
find(".sign-in-link").click | ||
find(".sign-in-link").click | ||
|
||
fill_in "session_user_email", with: "[email protected]" | ||
fill_in "session_user_password", with: "toto" | ||
fill_in "session_user_email", with: "[email protected]" | ||
fill_in "session_user_password", with: "toto" | ||
|
||
click_button "S'identifier" | ||
click_button "S'identifier" | ||
|
||
expect(page).to have_content("Email ou mot de passe invalide") | ||
expect(page).to have_content("Email ou mot de passe invalide") | ||
end | ||
end | ||
|
||
context "with a signed in user" do | ||
let(:user) { create(:user, :confirmed, locale: "fr", organization: organization) } | ||
|
||
before do | ||
login_as user, scope: :user | ||
visit decidim.root_path | ||
end | ||
|
||
it "uses the user's locale" do | ||
it "displays content based on user's locale" do | ||
expect(page).not_to have_content("Sign in") | ||
expect(page).not_to have_content("S'identifier") | ||
expect(page).to have_content("Accueil") | ||
end | ||
end | ||
|