Commit c61c5cf2 authored by Mark Lapierre's avatar Mark Lapierre

Update E2E tests for Project overview UI changes

Includes updates to how clone URLs are accessed.
parent 3f2418b2
......@@ -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'
......
......@@ -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'
......
......@@ -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
......@@ -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
......
......@@ -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,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
......
......@@ -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'
......
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