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/specs/features/browser_ui | |
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/specs/features/browser_ui')
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb | 77 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb | 87 |
2 files changed, 164 insertions, 0 deletions
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb new file mode 100644 index 00000000000..57892b65e28 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module QA + context :create do + describe 'File templates' do + include Runtime::Fixtures + + def login + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } + end + + before(:all) do + login + + @project = Factory::Resource::Project.fabricate! do |project| + project.name = 'file-template-project' + project.description = 'Add file templates via the Files view' + end + + Page::Menu::Main.act { sign_out } + end + + templates = [ + { + file_name: '.gitignore', + name: 'Android', + api_path: 'gitignores', + api_key: 'Android' + }, + { + file_name: '.gitlab-ci.yml', + name: 'Julia', + api_path: 'gitlab_ci_ymls', + api_key: 'Julia' + }, + { + file_name: 'Dockerfile', + name: 'Python', + api_path: 'dockerfiles', + api_key: 'Python' + }, + { + file_name: 'LICENSE', + name: 'Mozilla Public License 2.0', + api_path: 'licenses', + api_key: 'mpl-2.0' + } + ] + + templates.each do |template| + it "user adds #{template[:file_name]} via file template #{template[:name]}" do + content = fetch_template_from_api(template[:api_path], template[:api_key]) + + login + @project.visit! + + Page::Project::Show.act { create_new_file! } + Page::File::Form.perform do |page| + page.select_template template[:file_name], template[:name] + end + + expect(page).to have_content('Template applied') + expect(page).to have_button('Undo') + expect(page).to have_content(content[0..100]) + + Page::File::Form.perform(&:commit_changes) + + expect(page).to have_content('The file has been successfully created.') + expect(page).to have_content(template[:file_name]) + expect(page).to have_content('Add new file') + expect(page).to have_content(content[0..100]) + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb new file mode 100644 index 00000000000..dc96b19d36d --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true + +module QA + context :create do + describe 'Web IDE file templates' do + include Runtime::Fixtures + + def login + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } + end + + before(:all) do + login + + @project = Factory::Resource::Project.fabricate! do |project| + project.name = 'file-template-project' + project.description = 'Add file templates via the Web IDE' + end + + # 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::File::Form.perform do |page| + page.add_name('dummy') + page.add_content('Enable the Web IDE') + page.commit_changes + end + + Page::Menu::Main.act { sign_out } + end + + templates = [ + { + file_name: '.gitignore', + name: 'Android', + api_path: 'gitignores', + api_key: 'Android' + }, + { + file_name: '.gitlab-ci.yml', + name: 'Julia', + api_path: 'gitlab_ci_ymls', + api_key: 'Julia' + }, + { + file_name: 'Dockerfile', + name: 'Python', + api_path: 'dockerfiles', + api_key: 'Python' + }, + { + file_name: 'LICENSE', + name: 'Mozilla Public License 2.0', + api_path: 'licenses', + api_key: 'mpl-2.0' + } + ] + + templates.each do |template| + it "user adds #{template[:file_name]} via file template #{template[:name]}" do + content = fetch_template_from_api(template[:api_path], template[:api_key]) + + login + @project.visit! + + Page::Project::Show.act { open_web_ide! } + Page::Project::WebIDE::Edit.perform do |page| + page.create_new_file_from_template template[:file_name], template[:name] + + expect(page.has_file?(template[:file_name])).to be_truthy + end + + 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 + + expect(page).to have_content(template[:file_name]) + expect(page).to have_content(content[0..100]) + end + end + end + end +end |