summaryrefslogtreecommitdiff
path: root/qa/qa/page/main/sign_up.rb
blob: 7da682976e7cdfdec9681135b711ce567aa77a6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

module QA
  module Page
    module Main
      class SignUp < Page::Base
        view 'app/views/devise/shared/_signup_box.html.haml' do
          element :new_user_first_name_field
          element :new_user_last_name_field
          element :new_user_username_field
          element :new_user_email_field
          element :new_user_password_field
          element :new_user_register_button
        end

        view 'app/views/registrations/welcome/show.html.haml' do
          element :get_started_button
        end

        def sign_up!(user)
          signed_in = retry_until(raise_on_failure: false) do
            fill_element :new_user_first_name_field, user.first_name
            fill_element :new_user_last_name_field, user.last_name
            fill_element :new_user_username_field, user.username
            fill_element :new_user_email_field, user.email
            fill_element :new_user_password_field, user.password

            # Because invisible_captcha would prevent submitting this form
            # within 4 seconds, sleep here. This can be removed once we
            # implement invisible_captcha as an application setting instead
            # of a feature flag, so we can turn it off while testing.
            # Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/284113
            sleep 4

            click_element :new_user_register_button if has_element?(:new_user_register_button)
            click_element :get_started_button if has_element?(:get_started_button)

            Page::Main::Menu.perform(&:has_personal_area?)
          end

          raise "Failed to register and sign in" unless signed_in
        end
      end
    end
  end
end

QA::Page::Main::SignUp.prepend_if_ee('QA::EE::Page::Main::SignUp')