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 ...@@ -2,51 +2,60 @@ module QA
module Page module Page
module Dashboard module Dashboard
class Groups < Page::Base class Groups < Page::Base
def prepare_sandbox def filter_by_name(name)
sandbox_name = Runtime::Namespace.sandbox_name # NOTE: The filter placeholder on the Subgroups page currently omits
# the ellipsis.
fill_in 'Filter by name...', with: sandbox_name #
# 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) def has_test_namespace?
return click_link(sandbox_name) filter_by_name(Runtime::Namespace.name)
else
click_on 'New group'
populate_group_form(sandbox_name, "QA sandbox") page.has_link?(Runtime::Namespace.name)
end
end end
def prepare_test_namespace def has_sandbox?
namespace_name = Runtime::Namespace.name filter_by_name(Runtime::Namespace.sandbox_name)
if page.has_content?('Subgroups') page.has_link?(Runtime::Namespace.sandbox_name)
click_link 'Subgroups' end
if page.has_content?(namespace_name) def go_to_test_namespace
return click_link(namespace_name) click_link Runtime::Namespace.name
end 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' click_on 'New Subgroup'
else else
click_on 'New group' click_on 'New group'
end end
populate_group_form( fill_in 'group_path', with: group_name
namespace_name, fill_in 'group_description', with: group_description
"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
choose 'Private' choose 'Private'
click_button 'Create group' click_button 'Create group'
end 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 end
end end
......
...@@ -2,6 +2,10 @@ module QA ...@@ -2,6 +2,10 @@ module QA
module Page module Page
module Group module Group
class Show < Page::Base class Show < Page::Base
def go_to_subgroups
click_link 'Subgroups'
end
def go_to_new_project def go_to_new_project
click_link 'New Project' click_link 'New Project'
end end
......
require 'securerandom' require 'securerandom'
require_relative '../sandbox/prepare'
module QA module QA
module Scenario module Scenario
...@@ -12,11 +13,9 @@ module QA ...@@ -12,11 +13,9 @@ module QA
end end
def perform def perform
Page::Main::Menu.act { go_to_groups } Scenario::Gitlab::Sandbox::Prepare.perform
Page::Dashboard::Groups.act do
prepare_sandbox Page::Dashboard::Groups.act { prepare_test_namespace }
prepare_test_namespace
end
Page::Group::Show.act { go_to_new_project } Page::Group::Show.act { go_to_new_project }
Page::Project::New.perform do |page| 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