mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 17:53:55 +08:00
This is a revival of this PR: https://github.com/discourse/discourse/pull/33636 ### Description This PR adds ReCaptcha as a Captcha provider and provides a refactor to allow other Captcha providers to be added more easily. To achieve this, the following changes were introduced: - Provider Pattern Introduction in lib/discourse_hcaptcha/captcha_provider.rb - Controller refactoring, created a new Parent controller, extracted common logic - Serializer for each captcha provider - Implemented base abstract component for FE captcha logic - h-captcha-service is now provider agnostic (captcha-service) and manages both captcha providers - Added connectors to the UI to allow the chosen captcha to be rendered - Added problem check and site settings for the newly introduced ReCaptcha - `before-create-account` valueTransformer is introduced to allow captcha validation (or any other data) without modifying the class. --------- Co-authored-by: Juan Martinez <juan@discourse.org> Co-authored-by: David Taylor <david@taylorhq.com>
142 lines
3.1 KiB
Ruby
Vendored
142 lines
3.1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class Signup < PageObjects::Pages::Base
|
|
def open?
|
|
has_css?(".signup-fullpage")
|
|
end
|
|
|
|
def closed?
|
|
has_no_css?(".signup-fullpage")
|
|
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_no_css(".d-modal.is-animating")
|
|
end
|
|
find(selector).click
|
|
end
|
|
|
|
def open_login
|
|
click("#login-link")
|
|
end
|
|
|
|
def click_create_account
|
|
click(".signup-fullpage .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 has_editable_name_input?
|
|
has_css?("#new-account-name:not([disabled])")
|
|
end
|
|
|
|
def has_disabled_name_input?
|
|
has_css?("#new-account-name[disabled]")
|
|
end
|
|
|
|
def has_no_right_side_column?
|
|
has_no_css?(".login-right-side")
|
|
end
|
|
|
|
def fill_input(selector, text)
|
|
if page.has_css?("html.mobile-view", wait: 0)
|
|
expect(page).to have_no_css(".d-modal.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
|
|
|
|
def has_flash_message?(text)
|
|
has_css?(".alert", text: text)
|
|
end
|
|
end
|
|
end
|
|
end
|