From ea941b3b11ae3ed626682cfe7bd07beb5c1d2ddc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 30 Mar 2018 13:42:09 +0300 Subject: Update qa to match new admin settings structure Signed-off-by: Dmitriy Zaporozhets --- qa/qa.rb | 5 ++++- qa/qa/factory/settings/hashed_storage.rb | 8 ++++--- qa/qa/page/admin/settings.rb | 26 ---------------------- qa/qa/page/admin/settings/main.rb | 37 +++++++++++++++++++++++++++++++ qa/qa/page/admin/settings/repo_storage.rb | 33 +++++++++++++++++++++++++++ qa/spec/page/validator_spec.rb | 2 +- 6 files changed, 80 insertions(+), 31 deletions(-) delete mode 100644 qa/qa/page/admin/settings.rb create mode 100644 qa/qa/page/admin/settings/main.rb create mode 100644 qa/qa/page/admin/settings/repo_storage.rb diff --git a/qa/qa.rb b/qa/qa.rb index 7220af5088e..846197181b5 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -150,7 +150,10 @@ module QA end module Admin - autoload :Settings, 'qa/page/admin/settings' + module Settings + autoload :RepoStorage, 'qa/page/admin/settings/repo_storage' + autoload :Main, 'qa/page/admin/settings/main' + end end module Mattermost diff --git a/qa/qa/factory/settings/hashed_storage.rb b/qa/qa/factory/settings/hashed_storage.rb index 13ce2435fe4..c9a28ca6e86 100644 --- a/qa/qa/factory/settings/hashed_storage.rb +++ b/qa/qa/factory/settings/hashed_storage.rb @@ -9,9 +9,11 @@ module QA Page::Menu::Main.act { go_to_admin_area } Page::Menu::Admin.act { go_to_settings } - Page::Admin::Settings.act do - enable_hashed_storage - save_settings + Page::Admin::Settings::Main.perform do |setting| + setting.expand_repo_storage do |page| + enable_hashed_storage + save_settings + end end QA::Page::Menu::Main.act { sign_out } diff --git a/qa/qa/page/admin/settings.rb b/qa/qa/page/admin/settings.rb deleted file mode 100644 index 1f646103e7f..00000000000 --- a/qa/qa/page/admin/settings.rb +++ /dev/null @@ -1,26 +0,0 @@ -module QA - module Page - module Admin - class Settings < Page::Base - view 'app/views/admin/application_settings/_form.html.haml' do - element :form_actions, '.form-actions' - element :submit, "submit 'Save'" - element :repository_storage, '%legend Repository Storage' - element :hashed_storage, - 'Create new projects using hashed storage paths' - end - - def enable_hashed_storage - scroll_to 'legend', text: 'Repository Storage' - check 'Create new projects using hashed storage paths' - end - - def save_settings - scroll_to '.form-actions' do - click_button 'Save' - end - end - end - end - end -end diff --git a/qa/qa/page/admin/settings/main.rb b/qa/qa/page/admin/settings/main.rb new file mode 100644 index 00000000000..9b284fe7be1 --- /dev/null +++ b/qa/qa/page/admin/settings/main.rb @@ -0,0 +1,37 @@ +module QA + module Page + module Admin + module Settings + class Main < Page::Base + view 'app/views/admin/application_settings/show.html.haml' do + element :advanced_settings_section, 'Repository storage' + end + + def expand_repo_storage(&block) + expand_section('Repository storage') do + RepoStorage.perform(&block) + end + end + + # Click the Expand button present in the specified section + # + # @param [String] name present in the container in the DOM + def expand_section(name) + page.within('#content-body') do + page.within('section', text: name) do + # Because it is possible to click the button before the JS toggle code is bound + wait(reload: false) do + click_button 'Expand' unless first('button', text: 'Collapse') + + page.has_content?('Collapse') + end + + yield if block_given? + end + end + end + end + end + end + end +end diff --git a/qa/qa/page/admin/settings/repo_storage.rb b/qa/qa/page/admin/settings/repo_storage.rb new file mode 100644 index 00000000000..dc648c77abd --- /dev/null +++ b/qa/qa/page/admin/settings/repo_storage.rb @@ -0,0 +1,33 @@ +module QA + module Page + module Admin + module Settings + class RepoStorage < Page::Base + view 'app/views/admin/application_settings/_repo_storage.html.haml' do + element :submit, "submit 'Save changes'" + element :hashed_storage, + 'Create new projects using hashed storage paths' + end + + def enable_hashed_storage + within_repo_storage do + check 'Create new projects using hashed storage paths' + end + end + + def save_settings + within_repo_storage do + click_button 'Save changes' + end + end + + def within_repo_storage + page.within('.as-repo-storage') do + yield + end + end + end + end + end + end +end diff --git a/qa/spec/page/validator_spec.rb b/qa/spec/page/validator_spec.rb index 02822d7d18f..55957649904 100644 --- a/qa/spec/page/validator_spec.rb +++ b/qa/spec/page/validator_spec.rb @@ -30,7 +30,7 @@ describe QA::Page::Validator do let(:view) { spy('view') } before do - allow(QA::Page::Admin::Settings) + allow(QA::Page::Admin::Settings::Main) .to receive(:views).and_return([view]) end -- cgit v1.2.1