From c43a6bb3b76c1dd51343488226e5611848348f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Mon, 3 Sep 2018 18:04:40 +0200 Subject: [QA] Move Page::Shared::ClonePanel to Page::Component::ClonePanel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- qa/qa.rb | 7 +++-- qa/qa/page/component/clone_panel.rb | 52 +++++++++++++++++++++++++++++++++++++ qa/qa/page/project/issue/show.rb | 2 ++ qa/qa/page/project/show.rb | 2 +- qa/qa/page/project/wiki/show.rb | 4 ++- qa/qa/page/shared/clone_panel.rb | 50 ----------------------------------- 6 files changed, 61 insertions(+), 56 deletions(-) create mode 100644 qa/qa/page/component/clone_panel.rb delete mode 100644 qa/qa/page/shared/clone_panel.rb (limited to 'qa') diff --git a/qa/qa.rb b/qa/qa.rb index 8e23b444f3b..43313d15645 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + $: << File.expand_path(File.dirname(__FILE__)) Encoding.default_external = 'UTF-8' @@ -212,10 +214,6 @@ module QA end end - module Shared - autoload :ClonePanel, 'qa/page/shared/clone_panel' - end - module Profile autoload :PersonalAccessTokens, 'qa/page/profile/personal_access_tokens' end @@ -249,6 +247,7 @@ module QA # Classes describing components that are used by several pages. # module Component + autoload :ClonePanel, 'qa/page/component/clone_panel' autoload :Dropzone, 'qa/page/component/dropzone' autoload :Select2, 'qa/page/component/select2' end diff --git a/qa/qa/page/component/clone_panel.rb b/qa/qa/page/component/clone_panel.rb new file mode 100644 index 00000000000..8e8ff4e3bb0 --- /dev/null +++ b/qa/qa/page/component/clone_panel.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module QA + module Page + module Component + module ClonePanel + def self.included(base) + base.view 'app/views/shared/_clone_panel.html.haml' do + element :clone_dropdown + element :clone_options_dropdown, '.clone-options-dropdown' + element :project_repository_location, 'text_field_tag :project_clone' + end + end + + def choose_repository_clone_http + choose_repository_clone('HTTP', 'http') + end + + def choose_repository_clone_ssh + # It's not always beginning with ssh:// so detecting with @ + # would be more reliable because ssh would always contain it. + # We can't use .git because HTTP also contain that part. + choose_repository_clone('SSH', '@') + end + + def repository_location + Git::Location.new(find('#project_clone').value) + end + + def wait_for_push + sleep 5 + refresh + end + + private + + def choose_repository_clone(kind, detect_text) + wait(reload: false) do + click_element :clone_dropdown + + page.within('.clone-options-dropdown') do + click_link(kind) + end + + # Ensure git clone textbox was updated + repository_location.git_uri.include?(detect_text) + end + end + end + end + end +end diff --git a/qa/qa/page/project/issue/show.rb b/qa/qa/page/project/issue/show.rb index 5bc0598a524..587a02163b9 100644 --- a/qa/qa/page/project/issue/show.rb +++ b/qa/qa/page/project/issue/show.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Page module Project diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb index c751b472535..07b4d0b745d 100644 --- a/qa/qa/page/project/show.rb +++ b/qa/qa/page/project/show.rb @@ -2,7 +2,7 @@ module QA module Page module Project class Show < Page::Base - include Page::Shared::ClonePanel + include Page::Component::ClonePanel view 'app/views/projects/_last_push.html.haml' do element :create_merge_request diff --git a/qa/qa/page/project/wiki/show.rb b/qa/qa/page/project/wiki/show.rb index 044e514bab3..c47a715687f 100644 --- a/qa/qa/page/project/wiki/show.rb +++ b/qa/qa/page/project/wiki/show.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + module QA module Page module Project module Wiki class Show < Page::Base - include Page::Shared::ClonePanel + include Page::Component::ClonePanel view 'app/views/projects/wikis/pages.html.haml' do element :clone_repository_link, 'Clone repository' diff --git a/qa/qa/page/shared/clone_panel.rb b/qa/qa/page/shared/clone_panel.rb deleted file mode 100644 index 73e3dff956d..00000000000 --- a/qa/qa/page/shared/clone_panel.rb +++ /dev/null @@ -1,50 +0,0 @@ -module QA - module Page - module Shared - module ClonePanel - def self.included(base) - base.view 'app/views/shared/_clone_panel.html.haml' do - element :clone_dropdown - element :clone_options_dropdown, '.clone-options-dropdown' - element :project_repository_location, 'text_field_tag :project_clone' - end - end - - def choose_repository_clone_http - choose_repository_clone('HTTP', 'http') - end - - def choose_repository_clone_ssh - # It's not always beginning with ssh:// so detecting with @ - # would be more reliable because ssh would always contain it. - # We can't use .git because HTTP also contain that part. - choose_repository_clone('SSH', '@') - end - - def repository_location - Git::Location.new(find('#project_clone').value) - end - - def wait_for_push - sleep 5 - refresh - end - - private - - def choose_repository_clone(kind, detect_text) - wait(reload: false) do - click_element :clone_dropdown - - page.within('.clone-options-dropdown') do - click_link(kind) - end - - # Ensure git clone textbox was updated - repository_location.git_uri.include?(detect_text) - end - end - end - end - end -end -- cgit v1.2.3