discourse/spec/system/page_objects/modals/signup.rb
Osama Sayegh 4f9359d056
FIX: Name field should appear in the signup form for login-required sites (#30634)
Meta topic: https://meta.discourse.org/t/full-name-at-sign-up-went-missing/345662/17?u=osama

The preloaded `site` object for anons on login-required sites is a stripped down version of the full object with just a specific set of attributes and doesn't use the site serializer. This results in the `full_name_required_for_signup` and `full_name_visible_in_signup` attributes not making it to the client app when a login-required site is accessed by an anon, causing the name field in the signup form to not be rendered, even when it's required.

This commit includes those attributes in the stripped down version of the `site` object that's used for anons on login-required sites.
2025-01-08 03:49:34 +03:00

127 lines
2.8 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Modals
class Signup < PageObjects::Modals::Base
def open?
super && has_css?(".modal.create-account")
end
def closed?
super && has_no_css?(".modal.create-account")
end
def open
visit("/signup")
self
end
def open_from_header
find(".sign-up-button").click
end
def click(selector)
if page.has_css?("html.mobile-view", wait: 0)
expect(page).to have_css(".d-modal:not(.is-animating)")
end
find(selector).click
end
def open_login
click("#login-link")
end
def click_create_account
click(".modal.create-account .btn-primary")
end
def has_password_input?
has_css?("#new-account-password")
end
def has_no_password_input?
has_no_css?("#new-account-password")
end
def has_name_input?
has_css?("#new-account-name")
end
def has_no_name_input?
has_no_css?("#new-account-name")
end
def fill_input(selector, text)
if page.has_css?("html.mobile-view", wait: 0)
expect(page).to have_css(".d-modal:not(.is-animating)")
end
find(selector).fill_in(with: text)
end
def fill_email(email)
fill_input("#new-account-email", email)
self
end
def fill_username(username)
fill_input("#new-account-username", username)
self
end
def fill_name(name)
fill_input("#new-account-name", name)
self
end
def fill_password(password)
fill_input("#new-account-password", password)
self
end
def fill_code(code)
fill_input("#inviteCode", code)
self
end
def fill_custom_field(name, value)
find(".user-field-#{name.downcase} input").fill_in(with: value)
self
end
def has_valid_email?
find(".create-account-email").has_css?("#account-email-validation.good")
end
def has_valid_username?
find(".create-account__username").has_css?("#username-validation.good")
end
def has_valid_password?
find(".create-account__password").has_css?("#password-validation.good")
end
def has_valid_fields?
has_valid_email?
has_valid_username?
has_valid_password?
end
def has_disabled_email?
find(".create-account-email").has_css?("input[disabled]")
end
def has_disabled_name?
find(".create-account__fullname").has_css?("input[disabled]")
end
def has_disabled_username?
find(".create-account__username").has_css?("input[disabled]")
end
def click_social_button(provider)
click(".btn-social.#{provider}")
end
end
end
end