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 @@ ...@@ -10,12 +10,12 @@
%span.append-right-4.js-clone-dropdown-label %span.append-right-4.js-clone-dropdown-label
= _('Clone') = _('Clone')
= sprite_icon("arrow-down", css_class: "icon") = 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 %li.pb-2
%label.label-bold %label.label-bold
= _('Clone with SSH') = _('Clone with SSH')
.input-group .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 .input-group-append
= clipboard_button(target: '#ssh_project_clone', title: _("Copy URL to clipboard"), class: "input-group-text btn-default btn-clipboard") = 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' = render_if_exists 'projects/buttons/geo'
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
%label.label-bold %label.label-bold
= _('Clone with %{http_label}') % { http_label: gitlab_config.protocol.upcase } = _('Clone with %{http_label}') % { http_label: gitlab_config.protocol.upcase }
.input-group .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 .input-group-append
= clipboard_button(target: '#http_project_clone', title: _("Copy URL to clipboard"), class: "input-group-text btn-default btn-clipboard") = 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' = render_if_exists 'projects/buttons/geo'
......
...@@ -273,6 +273,7 @@ module QA ...@@ -273,6 +273,7 @@ module QA
# #
module Component module Component
autoload :ClonePanel, 'qa/page/component/clone_panel' autoload :ClonePanel, 'qa/page/component/clone_panel'
autoload :LegacyClonePanel, 'qa/page/component/legacy_clone_panel'
autoload :Dropzone, 'qa/page/component/dropzone' autoload :Dropzone, 'qa/page/component/dropzone'
autoload :GroupsFilter, 'qa/page/component/groups_filter' autoload :GroupsFilter, 'qa/page/component/groups_filter'
autoload :Select2, 'qa/page/component/select2' autoload :Select2, 'qa/page/component/select2'
......
...@@ -5,26 +5,20 @@ module QA ...@@ -5,26 +5,20 @@ module QA
module Component module Component
module ClonePanel module ClonePanel
def self.included(base) 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_dropdown
element :clone_options_dropdown, '.clone-options-dropdown' # rubocop:disable QA/ElementWithPattern element :clone_options
element :project_repository_location, 'text_field_tag :project_clone' # rubocop:disable QA/ElementWithPattern element :ssh_clone_url
element :http_clone_url
end end
end end
def choose_repository_clone_http def repository_clone_http_location
choose_repository_clone('HTTP', 'http') repository_clone_location(:http_clone_url)
end end
def choose_repository_clone_ssh def repository_clone_ssh_location
# It's not always beginning with ssh:// so detecting with @ repository_clone_location(:ssh_clone_url)
# 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 end
def wait_for_push def wait_for_push
...@@ -34,16 +28,13 @@ module QA ...@@ -34,16 +28,13 @@ module QA
private private
def choose_repository_clone(kind, detect_text) def repository_clone_location(kind)
wait(reload: false) do wait(reload: false) do
click_element :clone_dropdown click_element :clone_dropdown
page.within('.clone-options-dropdown') do within_element :clone_options do
click_link(kind) Git::Location.new(find_element(kind).value)
end end
# Ensure git clone textbox was updated
repository_location.git_uri.include?(detect_text)
end end
end 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 ...@@ -5,7 +5,7 @@ module QA
module Project module Project
module Wiki module Wiki
class Show < Page::Base class Show < Page::Base
include Page::Component::ClonePanel include Page::Component::LegacyClonePanel
view 'app/views/projects/wikis/pages.html.haml' do view 'app/views/projects/wikis/pages.html.haml' do
element :clone_repository_link, 'Clone repository' # rubocop:disable QA/ElementWithPattern element :clone_repository_link, 'Clone repository' # rubocop:disable QA/ElementWithPattern
......
...@@ -14,15 +14,13 @@ module QA ...@@ -14,15 +14,13 @@ module QA
attribute :repository_ssh_location do attribute :repository_ssh_location do
Page::Project::Show.perform do |page| Page::Project::Show.perform do |page|
page.choose_repository_clone_ssh page.repository_clone_ssh_location
page.repository_location
end end
end end
attribute :repository_http_location do attribute :repository_http_location do
Page::Project::Show.perform do |page| Page::Project::Show.perform do |page|
page.choose_repository_clone_http page.repository_clone_http_location
page.repository_location
end end
end end
......
...@@ -20,23 +20,11 @@ module QA ...@@ -20,23 +20,11 @@ module QA
end end
def repository_http_uri def repository_http_uri
@repository_http_uri ||= begin @repository_http_uri ||= project.repository_http_location.uri
project.visit!
Page::Project::Show.act do
choose_repository_clone_http
repository_location.uri
end
end
end end
def repository_ssh_uri def repository_ssh_uri
@repository_ssh_uri ||= begin @repository_ssh_uri ||= project.repository_ssh_location.uri
project.visit!
Page::Project::Show.act do
choose_repository_clone_ssh
repository_location.uri
end
end
end end
end end
end end
......
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
describe 'Merge request squashing' do describe 'Merge request squashing' do
it 'user squashes commits while merging' do it 'user squashes commits while merging' do
Runtime::Browser.visit(:gitlab, Page::Main::Login) 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 = Resource::Project.fabricate! do |project|
project.name = "squash-before-merge" project.name = "squash-before-merge"
...@@ -38,13 +38,12 @@ module QA ...@@ -38,13 +38,12 @@ module QA
Git::Repository.perform do |repository| Git::Repository.perform do |repository|
repository.uri = Page::Project::Show.act do repository.uri = Page::Project::Show.act do
choose_repository_clone_http repository_clone_http_location.uri
repository_location.uri
end end
repository.use_default_credentials repository.use_default_credentials
repository.act { clone } repository.clone
expect(repository.commits.size).to eq 3 expect(repository.commits.size).to eq 3
end end
......
...@@ -4,15 +4,12 @@ module QA ...@@ -4,15 +4,12 @@ module QA
context 'Create' do context 'Create' do
describe 'Git clone over HTTP', :ldap_no_tls do describe 'Git clone over HTTP', :ldap_no_tls do
let(:location) do let(:location) do
Page::Project::Show.act do Page::Project::Show.perform(&:repository_clone_http_location).uri
choose_repository_clone_http
repository_location
end
end end
before do before do
Runtime::Browser.visit(:gitlab, Page::Main::Login) 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| project = Resource::Project.fabricate! do |scenario|
scenario.name = 'project-with-code' scenario.name = 'project-with-code'
...@@ -21,7 +18,7 @@ module QA ...@@ -21,7 +18,7 @@ module QA
project.visit! project.visit!
Git::Repository.perform do |repository| Git::Repository.perform do |repository|
repository.uri = location.uri repository.uri = location
repository.use_default_credentials repository.use_default_credentials
repository.act do repository.act do
...@@ -32,14 +29,15 @@ module QA ...@@ -32,14 +29,15 @@ module QA
push_changes push_changes
end end
end end
Page::Project::Show.perform(&:wait_for_push)
end end
it 'user performs a deep clone' do it 'user performs a deep clone' do
Git::Repository.perform do |repository| Git::Repository.perform do |repository|
repository.uri = location.uri repository.uri = location
repository.use_default_credentials repository.use_default_credentials
repository.act { clone } repository.clone
expect(repository.commits.size).to eq 2 expect(repository.commits.size).to eq 2
end end
...@@ -47,10 +45,10 @@ module QA ...@@ -47,10 +45,10 @@ module QA
it 'user performs a shallow clone' do it 'user performs a shallow clone' do
Git::Repository.perform do |repository| Git::Repository.perform do |repository|
repository.uri = location.uri repository.uri = location
repository.use_default_credentials repository.use_default_credentials
repository.act { shallow_clone } repository.shallow_clone
expect(repository.commits.size).to eq 1 expect(repository.commits.size).to eq 1
expect(repository.commits.first).to include 'Add Readme' 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