blob: 05f114acbc57719a498afa34655b19222f2fac51 (
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
49
50
51
52
53
54
|
# frozen_string_literal: true
module QA
module Flow
module Login
module_function
def while_signed_in(as: nil, address: :gitlab, admin: false)
sign_in(as: as, address: address, admin: admin)
result = yield
Page::Main::Menu.perform(&:sign_out)
result
end
def while_signed_in_as_admin(address: :gitlab)
while_signed_in(address: address, admin: true) do
yield
end
end
def sign_in(as: nil, address: :gitlab, skip_page_validation: false, admin: false)
Page::Main::Login.perform { |p| p.redirect_to_login_page(address) }
unless Page::Main::Login.perform(&:on_login_page?)
Page::Main::Menu.perform(&:sign_out) if Page::Main::Menu.perform(&:signed_in?)
end
Page::Main::Login.perform do |login|
if admin
login.sign_in_using_admin_credentials
else
login.sign_in_using_credentials(user: as, skip_page_validation: skip_page_validation)
end
end
end
def sign_in_as_admin(address: :gitlab)
sign_in(as: Runtime::User.admin, address: address, admin: true)
end
def sign_in_unless_signed_in(user: nil, address: :gitlab)
if user
sign_in(as: user, address: address) unless Page::Main::Menu.perform do |menu|
menu.signed_in_as_user?(user)
end
else
sign_in(address: address) unless Page::Main::Menu.perform(&:signed_in?)
end
end
end
end
end
|