diff options
author | Rémy Coutable <remy@rymai.me> | 2018-12-11 15:47:41 +0300 |
---|---|---|
committer | GitLab Release Tools Bot <robert+release-tools@gitlab.com> | 2018-12-11 22:49:18 +0300 |
commit | 3f4873fe2e0fed40401e82b629efc3f6d70970b1 (patch) | |
tree | cafc4f85b90c61e8c29bfe3b0685fbde64bb3948 /qa | |
parent | 335694861716888672a16868884b311109956b3e (diff) |
Merge branch 'qa-project-ui-updates' into 'master'
Update E2E tests to account for Project overview UI changes
See merge request gitlab-org/gitlab-ce!23366
(cherry picked from commit 1d87276cddbc083c6b5536faf6fdce6c84cc844f)
c61c5cf2 Update E2E tests for Project overview UI changes
ed75b46c Update tests and Resources to use new file button
a1d9a3c3 Visit project page after pushing
7aeddde1 Method go_to_activity isn't private
Diffstat (limited to 'qa')
17 files changed, 195 insertions, 146 deletions
@@ -273,6 +273,7 @@ module QA # module Component autoload :ClonePanel, 'qa/page/component/clone_panel' + autoload :LegacyClonePanel, 'qa/page/component/legacy_clone_panel' autoload :Dropzone, 'qa/page/component/dropzone' autoload :GroupsFilter, 'qa/page/component/groups_filter' autoload :Select2, 'qa/page/component/select2' diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index f4bba3c9560..88ade66f47d 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -132,6 +132,10 @@ module QA Page::Element.new(name).selector_css end + def click_link_with_text(text) + click_link text + end + def self.path raise NotImplementedError end diff --git a/qa/qa/page/component/clone_panel.rb b/qa/qa/page/component/clone_panel.rb index 94e761b0e0c..d37b63c716a 100644 --- a/qa/qa/page/component/clone_panel.rb +++ b/qa/qa/page/component/clone_panel.rb @@ -5,26 +5,20 @@ module QA module Component module ClonePanel def self.included(base) - base.view 'app/views/shared/_clone_panel.html.haml' do + base.view 'app/views/projects/buttons/_clone.html.haml' do element :clone_dropdown - element :clone_options_dropdown, '.clone-options-dropdown' # rubocop:disable QA/ElementWithPattern - element :project_repository_location, 'text_field_tag :project_clone' # rubocop:disable QA/ElementWithPattern + element :clone_options + element :ssh_clone_url + element :http_clone_url end end - def choose_repository_clone_http - choose_repository_clone('HTTP', 'http') + def repository_clone_http_location + repository_clone_location(:http_clone_url) 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) + def repository_clone_ssh_location + repository_clone_location(:ssh_clone_url) end def wait_for_push @@ -34,16 +28,13 @@ module QA private - def choose_repository_clone(kind, detect_text) + def repository_clone_location(kind) wait(reload: false) do click_element :clone_dropdown - page.within('.clone-options-dropdown') do - click_link(kind) + within_element :clone_options do + Git::Location.new(find_element(kind).value) end - - # Ensure git clone textbox was updated - repository_location.git_uri.include?(detect_text) end end end diff --git a/qa/qa/page/component/legacy_clone_panel.rb b/qa/qa/page/component/legacy_clone_panel.rb new file mode 100644 index 00000000000..99132190f3f --- /dev/null +++ b/qa/qa/page/component/legacy_clone_panel.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module QA + module Page + module Component + module LegacyClonePanel + def self.included(base) + base.view 'app/views/shared/_clone_panel.html.haml' do + element :clone_dropdown + element :clone_options_dropdown, '.clone-options-dropdown' # rubocop:disable QA/ElementWithPattern + element :project_repository_location, 'text_field_tag :project_clone' # rubocop:disable QA/ElementWithPattern + 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/menu.rb b/qa/qa/page/project/menu.rb index cb4a10e1b6a..835e1ed00b5 100644 --- a/qa/qa/page/project/menu.rb +++ b/qa/qa/page/project/menu.rb @@ -29,11 +29,9 @@ module QA element :fly_out, "classList.add('fly-out-list')" # rubocop:disable QA/ElementWithPattern end - def click_repository_settings - hover_settings do - within_submenu do - click_link('Repository') - end + def click_ci_cd_pipelines + within_sidebar do + click_element :link_pipelines end end @@ -45,11 +43,9 @@ module QA end end - def click_operations_environments - hover_operations do - within_submenu do - click_element(:operations_environments_link) - end + def click_issues + within_sidebar do + click_link('Issues') end end @@ -61,61 +57,71 @@ module QA end end - def click_operations_kubernetes + def click_merge_requests + within_sidebar do + click_link('Merge Requests') + end + end + + def click_operations_environments hover_operations do within_submenu do - click_link('Kubernetes') + click_element(:operations_environments_link) end end end - def click_ci_cd_pipelines - within_sidebar do - click_element :link_pipelines + def click_operations_kubernetes + hover_operations do + within_submenu do + click_link('Kubernetes') + end end end - def go_to_settings + def click_milestones within_sidebar do - click_on 'Settings' + click_element :milestones_link end end - def click_issues + def click_repository within_sidebar do - click_link('Issues') + click_link('Repository') end end - def go_to_labels - hover_issues do + def click_repository_settings + hover_settings do within_submenu do - click_element(:labels_link) + click_link('Repository') end end end - def click_merge_requests + def click_wiki within_sidebar do - click_link('Merge Requests') + click_link('Wiki') end end - def click_milestones + def go_to_activity within_sidebar do - click_element :milestones_link + click_on 'Activity' end end - def click_wiki - within_sidebar do - click_link('Wiki') + def go_to_labels + hover_issues do + within_submenu do + click_element(:labels_link) + end end end - def click_repository + def go_to_settings within_sidebar do - click_link('Repository') + click_on 'Settings' end end @@ -129,17 +135,17 @@ module QA end end - def hover_settings + def hover_operations within_sidebar do - find('.qa-settings-item').hover + find('.shortcuts-operations').hover yield end end - def hover_operations + def hover_settings within_sidebar do - find('.shortcuts-operations').hover + find('.qa-settings-item').hover yield end @@ -151,12 +157,6 @@ module QA end end - def go_to_activity - within_sidebar do - click_on 'Activity' - end - end - def within_submenu page.within('.fly-out-list') do yield diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb index d6dddf03ffb..99d849db439 100644 --- a/qa/qa/page/project/show.rb +++ b/qa/qa/page/project/show.rb @@ -6,6 +6,11 @@ module QA class Show < Page::Base include Page::Component::ClonePanel + view 'app/views/layouts/header/_new_dropdown.haml' do + element :new_menu_toggle + element :new_issue_link, "link_to _('New issue'), new_project_issue_path(@project)" # rubocop:disable QA/ElementWithPattern + end + view 'app/views/projects/_last_push.html.haml' do element :create_merge_request end @@ -14,14 +19,12 @@ module QA element :project_name end - view 'app/views/layouts/header/_new_dropdown.haml' do - element :new_menu_toggle - element :new_issue_link, "link_to _('New issue'), new_project_issue_path(@project)" # rubocop:disable QA/ElementWithPattern + view 'app/views/projects/_files.html.haml' do + element :tree_holder, '.tree-holder' # rubocop:disable QA/ElementWithPattern end - view 'app/views/shared/_ref_switcher.html.haml' do - element :branches_select - element :branches_dropdown + view 'app/views/projects/buttons/_dropdown.html.haml' do + element :create_new_dropdown end view 'app/views/projects/buttons/_fork.html.haml' do @@ -29,44 +32,50 @@ module QA element :fork_link, "link_to new_project_fork_path(@project)" # rubocop:disable QA/ElementWithPattern end - view 'app/views/projects/_files.html.haml' do - element :tree_holder, '.tree-holder' # rubocop:disable QA/ElementWithPattern + view 'app/views/projects/empty.html.haml' do + element :quick_actions end - view 'app/views/projects/buttons/_dropdown.html.haml' do - element :create_new_dropdown - element :new_file_option + view 'app/views/projects/tree/_tree_content.html.haml' do + element :file_tree end view 'app/views/projects/tree/_tree_header.html.haml' do + element :add_to_tree + element :new_file_option element :web_ide_button end - view 'app/views/projects/tree/_tree_content.html.haml' do - element :file_tree + view 'app/views/shared/_ref_switcher.html.haml' do + element :branches_select + element :branches_dropdown end - def project_name - find('.qa-project-name').text + def create_first_new_file! + within_element(:quick_actions) do + click_link_with_text 'New file' + end end def create_new_file! - click_element :create_new_dropdown + click_element :add_to_tree click_element :new_file_option end + def fork_project + click_on 'Fork' + end + def go_to_file(filename) within_element(:file_tree) do click_on filename end end - def switch_to_branch(branch_name) - find_element(:branches_select).click + def go_to_new_issue + click_element :new_menu_toggle - within_element(:branches_dropdown) do - click_on branch_name - end + click_link 'New issue' end def last_commit_content @@ -81,24 +90,26 @@ module QA click_element :create_merge_request end - def wait_for_import - wait(reload: true) do - has_css?('.tree-holder') - end + def open_web_ide! + click_element :web_ide_button end - def go_to_new_issue - click_element :new_menu_toggle - - click_link 'New issue' + def project_name + find('.qa-project-name').text end - def fork_project - click_on 'Fork' + def switch_to_branch(branch_name) + find_element(:branches_select).click + + within_element(:branches_dropdown) do + click_on branch_name + end end - def open_web_ide! - click_element :web_ide_button + def wait_for_import + wait(reload: true) do + has_css?('.tree-holder') + end end end end diff --git a/qa/qa/page/project/wiki/show.rb b/qa/qa/page/project/wiki/show.rb index a7c4455d080..dffbc5d60a2 100644 --- a/qa/qa/page/project/wiki/show.rb +++ b/qa/qa/page/project/wiki/show.rb @@ -5,7 +5,7 @@ module QA module Project module Wiki class Show < Page::Base - include Page::Component::ClonePanel + include Page::Component::LegacyClonePanel view 'app/views/projects/wikis/pages.html.haml' do element :clone_repository_link, 'Clone repository' # rubocop:disable QA/ElementWithPattern diff --git a/qa/qa/resource/file.rb b/qa/qa/resource/file.rb index effc5a7940b..57e82ac19ad 100644 --- a/qa/qa/resource/file.rb +++ b/qa/qa/resource/file.rb @@ -22,7 +22,7 @@ module QA def fabricate! project.visit! - Page::Project::Show.perform(&:create_new_file!) + Page::Project::Show.perform(&:create_first_new_file!) Page::File::Form.perform do |page| page.add_name(@name) diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb index 7fdf69278f9..1fafbf5d73e 100644 --- a/qa/qa/resource/project.rb +++ b/qa/qa/resource/project.rb @@ -14,15 +14,13 @@ module QA attribute :repository_ssh_location do Page::Project::Show.perform do |page| - page.choose_repository_clone_ssh - page.repository_location + page.repository_clone_ssh_location end end attribute :repository_http_location do Page::Project::Show.perform do |page| - page.choose_repository_clone_http - page.repository_location + page.repository_clone_http_location end end diff --git a/qa/qa/resource/repository/project_push.rb b/qa/qa/resource/repository/project_push.rb index c9fafe3419f..37feab4ad70 100644 --- a/qa/qa/resource/repository/project_push.rb +++ b/qa/qa/resource/repository/project_push.rb @@ -20,23 +20,11 @@ module QA end def repository_http_uri - @repository_http_uri ||= begin - project.visit! - Page::Project::Show.act do - choose_repository_clone_http - repository_location.uri - end - end + @repository_http_uri ||= project.repository_http_location.uri end def repository_ssh_uri - @repository_ssh_uri ||= begin - project.visit! - Page::Project::Show.act do - choose_repository_clone_ssh - repository_location.uri - end - end + @repository_ssh_uri ||= project.repository_ssh_location.uri end end end diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb index 275de3d332c..d4cedc9362d 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb @@ -5,17 +5,17 @@ module QA describe 'Project activity' do it 'user creates an event in the activity page upon Git push' do Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.act { sign_in_using_credentials } + Page::Main::Login.perform(&:sign_in_using_credentials) - Resource::Repository::ProjectPush.fabricate! do |push| + project_push = Resource::Repository::ProjectPush.fabricate! do |push| push.file_name = 'README.md' push.file_content = '# This is a test project' push.commit_message = 'Add README.md' end + project_push.project.visit! - Page::Project::Menu.act { go_to_activity } - - Page::Project::Activity.act { go_to_push_events } + Page::Project::Menu.perform(&:go_to_activity) + Page::Project::Activity.perform(&:go_to_push_events) expect(page).to have_content('pushed new branch master') end diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/squash_merge_request_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/squash_merge_request_spec.rb index 6ff7360c413..4126f967ee2 100644 --- a/qa/qa/specs/features/browser_ui/3_create/merge_request/squash_merge_request_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/squash_merge_request_spec.rb @@ -5,7 +5,7 @@ module QA describe 'Merge request squashing' do it 'user squashes commits while merging' do Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.act { sign_in_using_credentials } + Page::Main::Login.perform(&:sign_in_using_credentials) project = Resource::Project.fabricate! do |project| project.name = "squash-before-merge" @@ -38,13 +38,12 @@ module QA Git::Repository.perform do |repository| repository.uri = Page::Project::Show.act do - choose_repository_clone_http - repository_location.uri + repository_clone_http_location.uri end repository.use_default_credentials - repository.act { clone } + repository.clone expect(repository.commits.size).to eq 3 end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb index 297485dd81e..de5c535c757 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb @@ -7,7 +7,7 @@ module QA def login Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.act { sign_in_using_credentials } + Page::Main::Login.perform(&:sign_in_using_credentials) end before(:all) do @@ -18,7 +18,15 @@ module QA project.description = 'Add file templates via the Files view' end - Page::Main::Menu.act { sign_out } + # There's no 'New File' dropdown when the project is blank, so we first + # add a dummy file so that the dropdown will appear + Resource::File.fabricate! do |file| + file.project = @project + file.name = 'README.md' + file.content = '# Readme' + end + + Page::Main::Menu.perform(&:sign_out) end templates = [ @@ -55,7 +63,7 @@ module QA login @project.visit! - Page::Project::Show.act { create_new_file! } + Page::Project::Show.perform(&:create_new_file!) Page::File::Form.perform do |page| page.select_template template[:file_name], template[:name] end diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb index 6a0add56fe0..571cae4a3c5 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb @@ -4,15 +4,12 @@ module QA context 'Create' do describe 'Git clone over HTTP', :ldap_no_tls do let(:location) do - Page::Project::Show.act do - choose_repository_clone_http - repository_location - end + Page::Project::Show.perform(&:repository_clone_http_location).uri end before do Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.act { sign_in_using_credentials } + Page::Main::Login.perform(&:sign_in_using_credentials) project = Resource::Project.fabricate! do |scenario| scenario.name = 'project-with-code' @@ -21,7 +18,7 @@ module QA project.visit! Git::Repository.perform do |repository| - repository.uri = location.uri + repository.uri = location repository.use_default_credentials repository.act do @@ -32,14 +29,15 @@ module QA push_changes end end + Page::Project::Show.perform(&:wait_for_push) end it 'user performs a deep clone' do Git::Repository.perform do |repository| - repository.uri = location.uri + repository.uri = location repository.use_default_credentials - repository.act { clone } + repository.clone expect(repository.commits.size).to eq 2 end @@ -47,10 +45,10 @@ module QA it 'user performs a shallow clone' do Git::Repository.perform do |repository| - repository.uri = location.uri + repository.uri = location repository.use_default_credentials - repository.act { shallow_clone } + repository.shallow_clone expect(repository.commits.size).to eq 1 expect(repository.commits.first).to include 'Add Readme' diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_spec.rb index 92f596a44d9..ad6426df420 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_spec.rb @@ -7,12 +7,12 @@ module QA Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.act { sign_in_using_credentials } - Resource::Repository::ProjectPush.fabricate! do |push| + project_push = Resource::Repository::ProjectPush.fabricate! do |push| push.file_name = 'README.md' push.file_content = '# This is a test project' push.commit_message = 'Add README.md' end - + project_push.project.visit! Page::Project::Show.act { wait_for_push } expect(page).to have_content('README.md') diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb index 9c764424129..509a639c130 100644 --- a/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb @@ -16,13 +16,14 @@ module QA resource.title = key_title end - Resource::Repository::ProjectPush.fabricate! do |push| + project_push = Resource::Repository::ProjectPush.fabricate! do |push| push.ssh_key = key push.file_name = 'README.md' push.file_content = '# Test Use SSH Key' push.commit_message = 'Add README.md' end + project_push.project.visit! Page::Project::Show.act { wait_for_push } expect(page).to have_content('README.md') diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb index e7374377104..f176ec31abd 100644 --- a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb @@ -7,7 +7,7 @@ module QA def login Runtime::Browser.visit(:gitlab, Page::Main::Login) - Page::Main::Login.act { sign_in_using_credentials } + Page::Main::Login.perform(&:sign_in_using_credentials) end before(:all) do @@ -21,14 +21,14 @@ module QA # Add a file via the regular Files view because the Web IDE isn't # available unless there is a file present - Page::Project::Show.act { create_new_file! } + Page::Project::Show.perform(&:create_first_new_file!) Page::File::Form.perform do |page| page.add_name('dummy') page.add_content('Enable the Web IDE') page.commit_changes end - Page::Main::Menu.act { sign_out } + Page::Main::Menu.perform(&:sign_out) end templates = [ @@ -65,7 +65,7 @@ module QA login @project.visit! - Page::Project::Show.act { open_web_ide! } + Page::Project::Show.perform(&:open_web_ide!) Page::Project::WebIDE::Edit.perform do |page| page.create_new_file_from_template template[:file_name], template[:name] @@ -75,9 +75,7 @@ module QA expect(page).to have_button('Undo') expect(page).to have_content(content[0..100]) - Page::Project::WebIDE::Edit.perform do |page| - page.commit_changes - end + Page::Project::WebIDE::Edit.perform(&:commit_changes) expect(page).to have_content(template[:file_name]) expect(page).to have_content(content[0..100]) |