From a6ac872b86561db1e8f66d1bc0239fa6123dd9a1 Mon Sep 17 00:00:00 2001
From: Grzegorz Bizon <grzesiek.bizon@gmail.com>
Date: Fri, 21 Jul 2017 12:10:54 +0200
Subject: [PATCH] Fix new project selectors in GitLab QA

---
 qa/qa.rb                                 |  9 ++++++++-
 qa/qa/page/{main => dashboard}/groups.rb |  6 ++++--
 qa/qa/page/group/show.rb                 | 11 +++++++++++
 qa/qa/page/main/menu.rb                  |  7 -------
 qa/qa/scenario/gitlab/project/create.rb  |  4 ++--
 5 files changed, 25 insertions(+), 12 deletions(-)
 rename qa/qa/page/{main => dashboard}/groups.rb (73%)
 create mode 100644 qa/qa/page/group/show.rb

diff --git a/qa/qa.rb b/qa/qa.rb
index bdfb8237995..db9d8c42fde 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -48,7 +48,14 @@ module QA
     module Main
       autoload :Entry, 'qa/page/main/entry'
       autoload :Menu, 'qa/page/main/menu'
-      autoload :Groups, 'qa/page/main/groups'
+    end
+
+    module Dashboard
+      autoload :Groups, 'qa/page/dashboard/groups'
+    end
+
+    module Group
+      autoload :Show, 'qa/page/group/show'
     end
 
     module Project
diff --git a/qa/qa/page/main/groups.rb b/qa/qa/page/dashboard/groups.rb
similarity index 73%
rename from qa/qa/page/main/groups.rb
rename to qa/qa/page/dashboard/groups.rb
index 169c5ebc967..3690f40dcfe 100644
--- a/qa/qa/page/main/groups.rb
+++ b/qa/qa/page/dashboard/groups.rb
@@ -1,9 +1,11 @@
 module QA
   module Page
-    module Main
+    module Dashboard
       class Groups < Page::Base
         def prepare_test_namespace
-          return if page.has_content?(Runtime::Namespace.name)
+          if page.has_content?(Runtime::Namespace.name)
+            return click_link(Runtime::Namespace.name)
+          end
 
           click_on 'New group'
 
diff --git a/qa/qa/page/group/show.rb b/qa/qa/page/group/show.rb
new file mode 100644
index 00000000000..296c311d7c6
--- /dev/null
+++ b/qa/qa/page/group/show.rb
@@ -0,0 +1,11 @@
+module QA
+  module Page
+    module Group
+      class Show < Page::Base
+        def go_to_new_project
+          click_link 'New Project'
+        end
+      end
+    end
+  end
+end
diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb
index f7c2086d0dd..7ce4e9009f5 100644
--- a/qa/qa/page/main/menu.rb
+++ b/qa/qa/page/main/menu.rb
@@ -14,13 +14,6 @@ module QA
           within_user_menu { click_link 'Admin area' }
         end
 
-        def go_to_new_project
-          within_user_menu do
-            find('.header-new-dropdown-toggle').click
-            click_link('New project')
-          end
-        end
-
         def sign_out
           within_user_menu do
             find('.header-user-dropdown-toggle').click
diff --git a/qa/qa/scenario/gitlab/project/create.rb b/qa/qa/scenario/gitlab/project/create.rb
index 99d0fc42a94..b860701c304 100644
--- a/qa/qa/scenario/gitlab/project/create.rb
+++ b/qa/qa/scenario/gitlab/project/create.rb
@@ -13,8 +13,8 @@ module QA
 
           def perform
             Page::Main::Menu.act { go_to_groups }
-            Page::Main::Groups.act { prepare_test_namespace }
-            Page::Main::Menu.act { go_to_new_project }
+            Page::Dashboard::Groups.act { prepare_test_namespace }
+            Page::Group::Show.act { go_to_new_project }
 
             Page::Project::New.perform do |page|
               page.choose_test_namespace
-- 
GitLab