FIX: Error with social logins and fullpage signup (#29761)

This commit is contained in:
Jan Cernik 2024-11-14 16:02:17 -03:00 committed by GitHub
parent 91ce470fce
commit 2ac1894292
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 93 additions and 88 deletions

View File

@ -219,9 +219,9 @@ export default class LoginPageController extends Controller {
signup: true,
});
} else {
this.router.transitionTo("signup").then((login) => {
this.router.transitionTo("signup").then((signup) => {
Object.keys(createAccountProps || {}).forEach((key) => {
login.controller.set(key, createAccountProps[key]);
signup.controller.set(key, createAccountProps[key]);
});
});
}

View File

@ -140,9 +140,11 @@ export default {
};
if (siteSettings.experimental_full_page_login) {
router.transitionTo("signup").then((login) => {
router.transitionTo("signup").then((signup) => {
const signupController =
signup.controller || owner.lookup("controller:signup");
Object.keys(createAccountProps || {}).forEach((key) => {
login.controller.set(key, createAccountProps[key]);
signupController.set(key, createAccountProps[key]);
});
});
} else {

View File

@ -1,16 +1,16 @@
# frozen_string_literal: true
shared_context "with omniauth setup" do
shared_context "with omniauth setup" do |signup_page_object, login_page_object|
include OmniauthHelpers
let(:login_modal) { PageObjects::Modals::Login.new }
let(:signup_modal) { PageObjects::Modals::Signup.new }
let(:login_form) { login_page_object }
let(:signup_form) { signup_page_object }
before { OmniAuth.config.test_mode = true }
end
shared_examples "social authentication scenarios" do
include_context "with omniauth setup"
shared_examples "social authentication scenarios" do |signup_page_object, login_page_object|
include_context "with omniauth setup", signup_page_object, login_page_object
context "when user does not exist" do
context "with Facebook" do
@ -21,13 +21,12 @@ shared_examples "social authentication scenarios" do
mock_facebook_auth
visit("/")
login_modal.open
login_modal.click_social_button("facebook")
expect(signup_modal).to be_open
expect(signup_modal).to have_no_password_input
expect(signup_modal).to have_valid_username
expect(signup_modal).to have_valid_email
signup_modal.click_create_account
signup_form.open.click_social_button("facebook")
expect(signup_form).to be_open
expect(signup_form).to have_no_password_input
expect(signup_form).to have_valid_username
expect(signup_form).to have_valid_email
signup_form.click_create_account
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
@ -40,13 +39,12 @@ shared_examples "social authentication scenarios" do
mock_google_auth
visit("/")
login_modal.open
login_modal.click_social_button("google_oauth2")
expect(signup_modal).to be_open
expect(signup_modal).to have_no_password_input
expect(signup_modal).to have_valid_username
expect(signup_modal).to have_valid_email
signup_modal.click_create_account
signup_form.open.click_social_button("google_oauth2")
expect(signup_form).to be_open
expect(signup_form).to have_no_password_input
expect(signup_form).to have_valid_username
expect(signup_form).to have_valid_email
signup_form.click_create_account
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
@ -55,13 +53,12 @@ shared_examples "social authentication scenarios" do
mock_google_auth(verified: false)
visit("/")
login_modal.open
login_modal.click_social_button("google_oauth2")
expect(signup_modal).to be_open
expect(signup_modal).to have_no_password_input
expect(signup_modal).to have_valid_username
expect(signup_modal).to have_valid_email
signup_modal.click_create_account
signup_form.open.click_social_button("google_oauth2")
expect(signup_form).to be_open
expect(signup_form).to have_no_password_input
expect(signup_form).to have_valid_username
expect(signup_form).to have_valid_email
signup_form.click_create_account
expect(page).to have_css(".account-created")
end
end
@ -75,13 +72,12 @@ shared_examples "social authentication scenarios" do
mock_github_auth
visit("/")
login_modal.open
login_modal.click_social_button("github")
expect(signup_modal).to be_open
expect(signup_modal).to have_no_password_input
expect(signup_modal).to have_valid_username
expect(signup_modal).to have_valid_email
signup_modal.click_create_account
signup_form.open.click_social_button("github")
expect(signup_form).to be_open
expect(signup_form).to have_no_password_input
expect(signup_form).to have_valid_username
expect(signup_form).to have_valid_email
signup_form.click_create_account
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
@ -90,13 +86,12 @@ shared_examples "social authentication scenarios" do
mock_github_auth(verified: false)
visit("/")
login_modal.open
login_modal.click_social_button("github")
expect(signup_modal).to be_open
expect(signup_modal).to have_no_password_input
expect(signup_modal).to have_valid_username
expect(signup_modal).to have_valid_email
signup_modal.click_create_account
signup_form.open.click_social_button("github")
expect(signup_form).to be_open
expect(signup_form).to have_no_password_input
expect(signup_form).to have_valid_username
expect(signup_form).to have_valid_email
signup_form.click_create_account
expect(page).to have_css(".account-created")
end
end
@ -110,14 +105,13 @@ shared_examples "social authentication scenarios" do
mock_twitter_auth
visit("/")
login_modal.open
login_modal.click_social_button("twitter")
expect(signup_modal).to be_open
expect(signup_modal).to have_no_password_input
signup_modal.fill_email(OmniauthHelpers::EMAIL)
expect(signup_modal).to have_valid_username
expect(signup_modal).to have_valid_email
signup_modal.click_create_account
signup_form.open.click_social_button("twitter")
expect(signup_form).to be_open
expect(signup_form).to have_no_password_input
signup_form.fill_email(OmniauthHelpers::EMAIL)
expect(signup_form).to have_valid_username
expect(signup_form).to have_valid_email
signup_form.click_create_account
expect(page).to have_css(".account-created")
end
@ -126,14 +120,13 @@ shared_examples "social authentication scenarios" do
mock_twitter_auth(verified: false)
visit("/")
login_modal.open
login_modal.click_social_button("twitter")
expect(signup_modal).to be_open
expect(signup_modal).to have_no_password_input
signup_modal.fill_email(OmniauthHelpers::EMAIL)
expect(signup_modal).to have_valid_username
expect(signup_modal).to have_valid_email
signup_modal.click_create_account
signup_form.open.click_social_button("twitter")
expect(signup_form).to be_open
expect(signup_form).to have_no_password_input
signup_form.fill_email(OmniauthHelpers::EMAIL)
expect(signup_form).to have_valid_username
expect(signup_form).to have_valid_email
signup_form.click_create_account
expect(page).to have_css(".account-created")
end
end
@ -147,13 +140,12 @@ shared_examples "social authentication scenarios" do
mock_discord_auth
visit("/")
login_modal.open
login_modal.click_social_button("discord")
expect(signup_modal).to be_open
expect(signup_modal).to have_no_password_input
expect(signup_modal).to have_valid_username
expect(signup_modal).to have_valid_email
signup_modal.click_create_account
signup_form.open.click_social_button("discord")
expect(signup_form).to be_open
expect(signup_form).to have_no_password_input
expect(signup_form).to have_valid_username
expect(signup_form).to have_valid_email
signup_form.click_create_account
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
@ -170,13 +162,12 @@ shared_examples "social authentication scenarios" do
mock_linkedin_auth
visit("/")
login_modal.open
login_modal.click_social_button("linkedin_oidc")
expect(signup_modal).to be_open
expect(signup_modal).to have_no_password_input
expect(signup_modal).to have_valid_username
expect(signup_modal).to have_valid_email
signup_modal.click_create_account
signup_form.open.click_social_button("linkedin_oidc")
expect(signup_form).to be_open
expect(signup_form).to have_no_password_input
expect(signup_form).to have_valid_username
expect(signup_form).to have_valid_email
signup_form.click_create_account
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
@ -200,8 +191,7 @@ shared_examples "social authentication scenarios" do
mock_facebook_auth
visit("/")
login_modal.open
login_modal.click_social_button("facebook")
signup_form.open.click_social_button("facebook")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
@ -214,8 +204,7 @@ shared_examples "social authentication scenarios" do
mock_google_auth
visit("/")
login_modal.open
login_modal.click_social_button("google_oauth2")
signup_form.open.click_social_button("google_oauth2")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
@ -228,8 +217,7 @@ shared_examples "social authentication scenarios" do
mock_github_auth
visit("/")
login_modal.open
login_modal.click_social_button("github")
signup_form.open.click_social_button("github")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
@ -248,8 +236,7 @@ shared_examples "social authentication scenarios" do
mock_twitter_auth
visit("/")
login_modal.open
login_modal.click_social_button("twitter")
signup_form.open.click_social_button("twitter")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
@ -262,8 +249,7 @@ shared_examples "social authentication scenarios" do
mock_discord_auth
visit("/")
login_modal.open
login_modal.click_social_button("discord")
signup_form.open.click_social_button("discord")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
@ -280,8 +266,7 @@ shared_examples "social authentication scenarios" do
mock_linkedin_auth
visit("/")
login_modal.open
login_modal.click_social_button("linkedin_oidc")
signup_form.open.click_social_button("linkedin_oidc")
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
end
@ -290,10 +275,28 @@ end
describe "Social authentication", type: :system do
context "when desktop" do
include_examples "social authentication scenarios"
include_examples "social authentication scenarios",
PageObjects::Modals::Signup.new,
PageObjects::Modals::Login.new
end
context "when mobile", mobile: true do
include_examples "social authentication scenarios"
include_examples "social authentication scenarios",
PageObjects::Modals::Signup.new,
PageObjects::Modals::Login.new
end
context "when fullpage desktop" do
before { SiteSetting.experimental_full_page_login = true }
include_examples "social authentication scenarios",
PageObjects::Pages::Signup.new,
PageObjects::Pages::Login.new
end
context "when fullpage mobile", mobile: true do
before { SiteSetting.experimental_full_page_login = true }
include_examples "social authentication scenarios",
PageObjects::Pages::Signup.new,
PageObjects::Pages::Login.new
end
end