Commit 1d87276c authored by Rémy Coutable's avatar Rémy Coutable

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
parents 7e4fcfb0 7aeddde1
......@@ -10,12 +10,12 @@
%span.append-right-4.js-clone-dropdown-label
= _('Clone')
= sprite_icon("arrow-down", css_class: "icon")
%form.p-3.dropdown-menu.dropdown-menu-right.dropdown-menu-large.dropdown-menu-selectable.clone-options-dropdown
%form.p-3.dropdown-menu.dropdown-menu-right.dropdown-menu-large.dropdown-menu-selectable.clone-options-dropdown.qa-clone-options
%li.pb-2
%label.label-bold
= _('Clone with SSH')
.input-group
= text_field_tag :ssh_project_clone, project.ssh_url_to_repo, class: "js-select-on-focus form-control", readonly: true, aria: { label: 'Project clone URL' }
= text_field_tag :ssh_project_clone, project.ssh_url_to_repo, class: "js-select-on-focus form-control qa-ssh-clone-url", readonly: true, aria: { label: 'Project clone URL' }
.input-group-append
= clipboard_button(target: '#ssh_project_clone', title: _("Copy URL to clipboard"), class: "input-group-text btn-default btn-clipboard")
= render_if_exists 'projects/buttons/geo'
......@@ -23,7 +23,7 @@
%label.label-bold
= _('Clone with %{http_label}') % { http_label: gitlab_config.protocol.upcase }
.input-group
= text_field_tag :http_project_clone, project.http_url_to_repo, class: "js-select-on-focus form-control", readonly: true, aria: { label: 'Project clone URL' }
= text_field_tag :http_project_clone, project.http_url_to_repo, class: "js-select-on-focus form-control qa-http-clone-url", readonly: true, aria: { label: 'Project clone URL' }
.input-group-append
= clipboard_button(target: '#http_project_clone', title: _("Copy URL to clipboard"), class: "input-group-text btn-default btn-clipboard")
= render_if_exists 'projects/buttons/geo'
......
......@@ -32,7 +32,7 @@
.prepend-top-20
%nav.project-buttons
.scrolling-tabs-container.inner-page-scroll-tabs.is-smaller
.scrolling-tabs-container.inner-page-scroll-tabs.is-smaller.qa-quick-actions
.fade-left= icon('angle-left')
.fade-right= icon('angle-right')
.nav-links.scrolling-tabs.quick-links
......
......@@ -20,7 +20,7 @@
- if can_collaborate || can_create_mr_from_fork
%li.breadcrumb-item
%a.btn.add-to-tree{ addtotree_toggle_attributes }
%a.btn.add-to-tree.qa-add-to-tree{ addtotree_toggle_attributes }
= sprite_icon('plus', size: 16, css_class: 'float-left')
= sprite_icon('arrow-down', size: 16, css_class: 'float-left')
- if on_top_of_branch?
......@@ -30,7 +30,7 @@
%li.dropdown-header
#{ _('This directory') }
%li
= link_to project_new_blob_path(@project, @id) do
= link_to project_new_blob_path(@project, @id), class: 'qa-new-file-option' do
#{ _('New file') }
%li
= link_to '#modal-upload-blob', { 'data-target' => '#modal-upload-blob', 'data-toggle' => 'modal' } do
......
......@@ -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'
......
......@@ -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
......
......@@ -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
......
# 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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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'
......
......@@ -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')
......
......@@ -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')
......
......@@ -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])
......
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