diff options
author | Mark Lapierre <mlapierre@gitlab.com> | 2018-09-26 15:15:35 -0400 |
---|---|---|
committer | Mark Lapierre <mlapierre@gitlab.com> | 2018-10-09 11:17:02 -0400 |
commit | d36055cbef1e5f2e9ffe1b0b9c1ad32e85bb5248 (patch) | |
tree | 98762181835df5d65c26a17af846593c1e6712e4 /qa/qa/page/project | |
parent | eeb0baff480a5b4275fb152920e5b81b1a2cda3c (diff) | |
download | gitlab-ce-d36055cbef1e5f2e9ffe1b0b9c1ad32e85bb5248.tar.gz |
Add tests of adding file templates
Adds tests that adds new files via file templates via the Files view
and the Web IDE.
Includes changes to page objects and associated code
Fetches template content from the API rather than hardcoding strings
that will need to be updated if the templates change. Some of the
content is stored as flat files but we can't use them because they're
not included in the docker images gitlab-qa uses.
Diffstat (limited to 'qa/qa/page/project')
-rw-r--r-- | qa/qa/page/project/show.rb | 20 | ||||
-rw-r--r-- | qa/qa/page/project/web_ide/edit.rb | 79 |
2 files changed, 95 insertions, 4 deletions
diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb index 267e7bbc249..2e7be1deb27 100644 --- a/qa/qa/page/project/show.rb +++ b/qa/qa/page/project/show.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module QA module Page module Project @@ -31,16 +33,22 @@ module QA element :tree_holder, '.tree-holder' end - view 'app/presenters/project_presenter.rb' do - element :new_file_button, "_('New file')," + view 'app/views/projects/buttons/_dropdown.html.haml' do + element :create_new_dropdown + element :new_file_option + end + + view 'app/views/projects/tree/_tree_header.html.haml' do + element :web_ide_button end def project_name find('.qa-project-name').text end - def go_to_new_file! - click_on 'New file' + def create_new_file! + click_element :create_new_dropdown + click_element :new_file_option end def switch_to_branch(branch_name) @@ -78,6 +86,10 @@ module QA def fork_project click_on 'Fork' end + + def open_web_ide! + click_element :web_ide_button + end end end end diff --git a/qa/qa/page/project/web_ide/edit.rb b/qa/qa/page/project/web_ide/edit.rb new file mode 100644 index 00000000000..23e580b81b6 --- /dev/null +++ b/qa/qa/page/project/web_ide/edit.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +module QA + module Page + module Project + module WebIDE + class Edit < Page::Base + include Page::Component::DropdownFilter + + view 'app/assets/javascripts/ide/components/ide_tree.vue' do + element :new_file + end + + view 'app/assets/javascripts/ide/components/ide_tree_list.vue' do + element :file_list + end + + view 'app/assets/javascripts/ide/components/new_dropdown/modal.vue' do + element :full_file_path + element :template_list + end + + view 'app/assets/javascripts/ide/components/file_templates/bar.vue' do + element :file_templates_bar + element :file_template_dropdown + end + + view 'app/assets/javascripts/ide/components/file_templates/dropdown.vue' do + element :dropdown_filter_input + end + + view 'app/assets/javascripts/ide/components/commit_sidebar/form.vue' do + element :begin_commit_button + element :commit_button + end + + def has_file?(file_name) + within_element(:file_list) do + page.has_content? file_name + end + end + + def create_new_file_from_template(file_name, template) + click_element :new_file + within_element(:template_list) do + begin + click_on file_name + rescue Capybara::ElementNotFound + raise ElementNotFound, %Q(Couldn't find file template named "#{file_name}". Please confirm that it is a valid option.) + end + end + + wait(reload: false) do + within_element(:file_templates_bar) do + click_element :file_template_dropdown + fill_element :dropdown_filter_input, template + + begin + click_on template + rescue Capybara::ElementNotFound + raise ElementNotFound, %Q(Couldn't find template "#{template}" for #{file_name}. Please confirm that it exists in the list of templates.) + end + end + end + end + + def commit_changes + click_element :begin_commit_button + click_element :commit_button + + wait(reload: false) do + page.has_content?('Your changes have been committed') + end + end + end + end + end + end +end |