2024-05-17 22:56:43 +08:00
|
|
|
# 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")
|
|
|
|
end
|
|
|
|
|
|
|
|
def open_from_header
|
|
|
|
find(".sign-up-button").click
|
|
|
|
end
|
|
|
|
|
2024-05-23 21:01:05 +08:00
|
|
|
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
|
|
|
|
|
2024-05-17 22:56:43 +08:00
|
|
|
def open_login
|
2024-05-23 21:01:05 +08:00
|
|
|
click("#login-link")
|
2024-05-17 22:56:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_create_account
|
2024-05-23 21:01:05 +08:00
|
|
|
click(".modal.create-account .btn-primary")
|
2024-05-17 22:56:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_password_input?
|
|
|
|
has_css?("#new-account-password")
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_password_input?
|
|
|
|
has_no_css?("#new-account-password")
|
|
|
|
end
|
|
|
|
|
2024-05-23 21:01:05 +08:00
|
|
|
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
|
|
|
|
|
2024-05-17 22:56:43 +08:00
|
|
|
def fill_email(email)
|
2024-05-23 21:01:05 +08:00
|
|
|
fill_input("#new-account-email", email)
|
2024-05-17 22:56:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def fill_username(username)
|
2024-05-23 21:01:05 +08:00
|
|
|
fill_input("#new-account-username", username)
|
2024-05-17 22:56:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def fill_name(name)
|
2024-05-23 21:01:05 +08:00
|
|
|
fill_input("#new-account-name", name)
|
2024-05-17 22:56:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def fill_password(password)
|
2024-05-23 21:01:05 +08:00
|
|
|
fill_input("#new-account-password", password)
|
2024-05-17 22:56:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def fill_code(code)
|
2024-05-23 21:01:05 +08:00
|
|
|
fill_input("#inviteCode", code)
|
2024-05-17 22:56:43 +08:00
|
|
|
end
|
|
|
|
|
2024-05-23 19:18:25 +08:00
|
|
|
def fill_custom_field(name, value)
|
|
|
|
find(".user-field-#{name.downcase} input").fill_in(with: value)
|
|
|
|
end
|
|
|
|
|
2024-05-17 22:56:43 +08:00
|
|
|
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
|
|
|
|
|
2024-05-23 21:01:05 +08:00
|
|
|
def click_social_button(provider)
|
|
|
|
click(".btn-social.#{provider}")
|
2024-05-17 22:56:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|