Commit ed75b46c authored by Mark Lapierre's avatar Mark Lapierre

Update tests and Resources to use new file button

The 'Create new' dropdown is no longer available on a blank project
so use the 'New file' button instead.
parent c61c5cf2
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
.prepend-top-20 .prepend-top-20
%nav.project-buttons %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-left= icon('angle-left')
.fade-right= icon('angle-right') .fade-right= icon('angle-right')
.nav-links.scrolling-tabs.quick-links .nav-links.scrolling-tabs.quick-links
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
- if can_collaborate || can_create_mr_from_fork - if can_collaborate || can_create_mr_from_fork
%li.breadcrumb-item %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('plus', size: 16, css_class: 'float-left')
= sprite_icon('arrow-down', size: 16, css_class: 'float-left') = sprite_icon('arrow-down', size: 16, css_class: 'float-left')
- if on_top_of_branch? - if on_top_of_branch?
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
%li.dropdown-header %li.dropdown-header
#{ _('This directory') } #{ _('This directory') }
%li %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') } #{ _('New file') }
%li %li
= link_to '#modal-upload-blob', { 'data-target' => '#modal-upload-blob', 'data-toggle' => 'modal' } do = link_to '#modal-upload-blob', { 'data-target' => '#modal-upload-blob', 'data-toggle' => 'modal' } do
......
...@@ -132,6 +132,10 @@ module QA ...@@ -132,6 +132,10 @@ module QA
Page::Element.new(name).selector_css Page::Element.new(name).selector_css
end end
def click_link_with_text(text)
click_link text
end
def self.path def self.path
raise NotImplementedError raise NotImplementedError
end end
......
...@@ -6,6 +6,11 @@ module QA ...@@ -6,6 +6,11 @@ module QA
class Show < Page::Base class Show < Page::Base
include Page::Component::ClonePanel 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 view 'app/views/projects/_last_push.html.haml' do
element :create_merge_request element :create_merge_request
end end
...@@ -14,14 +19,12 @@ module QA ...@@ -14,14 +19,12 @@ module QA
element :project_name element :project_name
end end
view 'app/views/layouts/header/_new_dropdown.haml' do view 'app/views/projects/_files.html.haml' do
element :new_menu_toggle element :tree_holder, '.tree-holder' # rubocop:disable QA/ElementWithPattern
element :new_issue_link, "link_to _('New issue'), new_project_issue_path(@project)" # rubocop:disable QA/ElementWithPattern
end end
view 'app/views/shared/_ref_switcher.html.haml' do view 'app/views/projects/buttons/_dropdown.html.haml' do
element :branches_select element :create_new_dropdown
element :branches_dropdown
end end
view 'app/views/projects/buttons/_fork.html.haml' do view 'app/views/projects/buttons/_fork.html.haml' do
...@@ -29,44 +32,50 @@ module QA ...@@ -29,44 +32,50 @@ module QA
element :fork_link, "link_to new_project_fork_path(@project)" # rubocop:disable QA/ElementWithPattern element :fork_link, "link_to new_project_fork_path(@project)" # rubocop:disable QA/ElementWithPattern
end end
view 'app/views/projects/_files.html.haml' do view 'app/views/projects/empty.html.haml' do
element :tree_holder, '.tree-holder' # rubocop:disable QA/ElementWithPattern element :quick_actions
end end
view 'app/views/projects/buttons/_dropdown.html.haml' do view 'app/views/projects/tree/_tree_content.html.haml' do
element :create_new_dropdown element :file_tree
element :new_file_option
end end
view 'app/views/projects/tree/_tree_header.html.haml' do view 'app/views/projects/tree/_tree_header.html.haml' do
element :add_to_tree
element :new_file_option
element :web_ide_button element :web_ide_button
end end
view 'app/views/projects/tree/_tree_content.html.haml' do view 'app/views/shared/_ref_switcher.html.haml' do
element :file_tree element :branches_select
element :branches_dropdown
end end
def project_name def create_first_new_file!
find('.qa-project-name').text within_element(:quick_actions) do
click_link_with_text 'New file'
end
end end
def create_new_file! def create_new_file!
click_element :create_new_dropdown click_element :add_to_tree
click_element :new_file_option click_element :new_file_option
end end
def fork_project
click_on 'Fork'
end
def go_to_file(filename) def go_to_file(filename)
within_element(:file_tree) do within_element(:file_tree) do
click_on filename click_on filename
end end
end end
def switch_to_branch(branch_name) def go_to_new_issue
find_element(:branches_select).click click_element :new_menu_toggle
within_element(:branches_dropdown) do click_link 'New issue'
click_on branch_name
end
end end
def last_commit_content def last_commit_content
...@@ -81,24 +90,26 @@ module QA ...@@ -81,24 +90,26 @@ module QA
click_element :create_merge_request click_element :create_merge_request
end end
def wait_for_import def open_web_ide!
wait(reload: true) do click_element :web_ide_button
has_css?('.tree-holder')
end
end end
def go_to_new_issue def project_name
click_element :new_menu_toggle find('.qa-project-name').text
click_link 'New issue'
end end
def fork_project def switch_to_branch(branch_name)
click_on 'Fork' find_element(:branches_select).click
within_element(:branches_dropdown) do
click_on branch_name
end
end end
def open_web_ide! def wait_for_import
click_element :web_ide_button wait(reload: true) do
has_css?('.tree-holder')
end
end end
end end
end end
......
...@@ -22,7 +22,7 @@ module QA ...@@ -22,7 +22,7 @@ module QA
def fabricate! def fabricate!
project.visit! project.visit!
Page::Project::Show.perform(&:create_new_file!) Page::Project::Show.perform(&:create_first_new_file!)
Page::File::Form.perform do |page| Page::File::Form.perform do |page|
page.add_name(@name) page.add_name(@name)
......
...@@ -7,7 +7,7 @@ module QA ...@@ -7,7 +7,7 @@ module QA
def login def login
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)
end end
before(:all) do before(:all) do
...@@ -18,7 +18,15 @@ module QA ...@@ -18,7 +18,15 @@ module QA
project.description = 'Add file templates via the Files view' project.description = 'Add file templates via the Files view'
end 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 end
templates = [ templates = [
...@@ -55,7 +63,7 @@ module QA ...@@ -55,7 +63,7 @@ module QA
login login
@project.visit! @project.visit!
Page::Project::Show.act { create_new_file! } Page::Project::Show.perform(&:create_new_file!)
Page::File::Form.perform do |page| Page::File::Form.perform do |page|
page.select_template template[:file_name], template[:name] page.select_template template[:file_name], template[:name]
end end
......
...@@ -7,7 +7,7 @@ module QA ...@@ -7,7 +7,7 @@ module QA
def login def login
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)
end end
before(:all) do before(:all) do
...@@ -21,14 +21,14 @@ module QA ...@@ -21,14 +21,14 @@ module QA
# Add a file via the regular Files view because the Web IDE isn't # Add a file via the regular Files view because the Web IDE isn't
# available unless there is a file present # 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::File::Form.perform do |page|
page.add_name('dummy') page.add_name('dummy')
page.add_content('Enable the Web IDE') page.add_content('Enable the Web IDE')
page.commit_changes page.commit_changes
end end
Page::Main::Menu.act { sign_out } Page::Main::Menu.perform(&:sign_out)
end end
templates = [ templates = [
...@@ -65,7 +65,7 @@ module QA ...@@ -65,7 +65,7 @@ module QA
login login
@project.visit! @project.visit!
Page::Project::Show.act { open_web_ide! } Page::Project::Show.perform(&:open_web_ide!)
Page::Project::WebIDE::Edit.perform do |page| Page::Project::WebIDE::Edit.perform do |page|
page.create_new_file_from_template template[:file_name], template[:name] page.create_new_file_from_template template[:file_name], template[:name]
...@@ -75,9 +75,7 @@ module QA ...@@ -75,9 +75,7 @@ module QA
expect(page).to have_button('Undo') expect(page).to have_button('Undo')
expect(page).to have_content(content[0..100]) expect(page).to have_content(content[0..100])
Page::Project::WebIDE::Edit.perform do |page| Page::Project::WebIDE::Edit.perform(&:commit_changes)
page.commit_changes
end
expect(page).to have_content(template[:file_name]) expect(page).to have_content(template[:file_name])
expect(page).to have_content(content[0..100]) 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