Commit 88194b81 authored by Robert Speicher's avatar Robert Speicher

Implement Scenario::Gitlab::Sandbox::Prepare

This better separates the concerns of preparing the sandbox namespace
from creating a (sub)group.
parent c2b17da4
......@@ -2,51 +2,60 @@ module QA
module Page
module Dashboard
class Groups < Page::Base
def prepare_sandbox
sandbox_name = Runtime::Namespace.sandbox_name
fill_in 'Filter by name...', with: sandbox_name
def filter_by_name(name)
# NOTE: The filter placeholder on the Subgroups page currently omits
# the ellipsis.
#
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/38807
if page.has_field?('Filter by name...')
fill_in 'Filter by name...', with: name
elsif page.has_field?('Filter by name')
fill_in 'Filter by name', with: name
end
end
if page.has_content?(sandbox_name)
return click_link(sandbox_name)
else
click_on 'New group'
def has_test_namespace?
filter_by_name(Runtime::Namespace.name)
populate_group_form(sandbox_name, "QA sandbox")
end
page.has_link?(Runtime::Namespace.name)
end
def prepare_test_namespace
namespace_name = Runtime::Namespace.name
def has_sandbox?
filter_by_name(Runtime::Namespace.sandbox_name)
if page.has_content?('Subgroups')
click_link 'Subgroups'
page.has_link?(Runtime::Namespace.sandbox_name)
end
if page.has_content?(namespace_name)
return click_link(namespace_name)
end
def go_to_test_namespace
click_link Runtime::Namespace.name
end
def go_to_sandbox
click_link Runtime::Namespace.sandbox_name
end
# NOTE: Inconsistent capitalization here in the UI
def create_group(group_name, group_description)
if page.has_content?('New Subgroup')
click_on 'New Subgroup'
else
click_on 'New group'
end
populate_group_form(
namespace_name,
"QA test run at #{Runtime::Namespace.time}"
)
end
private
def populate_group_form(name, description)
fill_in 'group_path', with: name
fill_in 'group_description', with: description
fill_in 'group_path', with: group_name
fill_in 'group_description', with: group_description
choose 'Private'
click_button 'Create group'
end
def prepare_test_namespace
return click_link(Runtime::Namespace.name) if has_test_namespace?
create_group(
Runtime::Namespace.name,
"QA test run at #{Runtime::Namespace.time}"
)
end
end
end
end
......
......@@ -2,6 +2,10 @@ module QA
module Page
module Group
class Show < Page::Base
def go_to_subgroups
click_link 'Subgroups'
end
def go_to_new_project
click_link 'New Project'
end
......
require 'securerandom'
require_relative '../sandbox/prepare'
module QA
module Scenario
......@@ -12,11 +13,9 @@ module QA
end
def perform
Page::Main::Menu.act { go_to_groups }
Page::Dashboard::Groups.act do
prepare_sandbox
prepare_test_namespace
end
Scenario::Gitlab::Sandbox::Prepare.perform
Page::Dashboard::Groups.act { prepare_test_namespace }
Page::Group::Show.act { go_to_new_project }
Page::Project::New.perform do |page|
......
module QA
module Scenario
module Gitlab
module Sandbox
class Prepare < Scenario::Template
def perform
Page::Main::Menu.act { go_to_groups }
Page::Dashboard::Groups.perform do |page|
if page.has_sandbox?
page.go_to_sandbox
else
page.create_group(Runtime::Namespace.sandbox_name, "QA sandbox")
end
end
Page::Group::Show.act { go_to_subgroups }
end
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment