Commit 8e5ada04 authored by Rémy Coutable's avatar Rémy Coutable Committed by Ramya Authappan

Make sure end-to-end tests use unique filenames in template tests

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent f509b553
# frozen_string_literal: true # frozen_string_literal: true
require 'securerandom'
module QA module QA
RSpec.describe 'Create' do RSpec.describe 'Create' do
describe 'File templates' do describe 'File templates' do
...@@ -54,12 +56,14 @@ module QA ...@@ -54,12 +56,14 @@ module QA
expect(form).to have_normalized_ws_text(content[0..100]) expect(form).to have_normalized_ws_text(content[0..100])
form.add_name("#{SecureRandom.hex(8)}/#{template[:file_name]}")
form.commit_changes form.commit_changes
expect(form).to have_content('The file has been successfully created.') aggregate_failures "indications of file created" do
expect(form).to have_content(template[:file_name]) expect(form).to have_content(template[:file_name])
expect(form).to have_content('Add new file')
expect(form).to have_normalized_ws_text(content[0..100]) expect(form).to have_normalized_ws_text(content[0..100])
expect(form).to have_content('Add new file')
end
end end
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
require 'securerandom'
module QA module QA
RSpec.describe 'Manage' do RSpec.describe 'Manage' do
describe 'Group file templates', :requires_admin do describe 'Group file templates', :requires_admin do
...@@ -7,19 +9,19 @@ module QA ...@@ -7,19 +9,19 @@ module QA
templates = [ templates = [
{ {
type: 'Dockerfile', file_name: 'Dockerfile',
template: 'custom_dockerfile', template: 'custom_dockerfile',
file_path: 'Dockerfile/custom_dockerfile.dockerfile', file_path: 'Dockerfile/custom_dockerfile.dockerfile',
content: 'dockerfile template test' content: 'dockerfile template test'
}, },
{ {
type: '.gitignore', file_name: '.gitignore',
template: 'custom_gitignore', template: 'custom_gitignore',
file_path: 'gitignore/custom_gitignore.gitignore', file_path: 'gitignore/custom_gitignore.gitignore',
content: 'gitignore template test' content: 'gitignore template test'
}, },
{ {
type: '.gitlab-ci.yml', file_name: '.gitlab-ci.yml',
template: 'custom_gitlab-ci', template: 'custom_gitlab-ci',
file_path: 'gitlab-ci/custom_gitlab-ci.yml', file_path: 'gitlab-ci/custom_gitlab-ci.yml',
content: content:
...@@ -31,7 +33,7 @@ module QA ...@@ -31,7 +33,7 @@ module QA
CI CI
}, },
{ {
type: 'LICENSE', file_name: 'LICENSE',
template: 'custom_license', template: 'custom_license',
file_path: 'LICENSE/custom_license.txt', file_path: 'LICENSE/custom_license.txt',
content: 'license template test' content: 'license template test'
...@@ -92,7 +94,7 @@ module QA ...@@ -92,7 +94,7 @@ module QA
end end
templates.each do |template| templates.each do |template|
it "creates file via custom #{template[:type]} file template" do it "creates file via custom #{template[:file_name]} file template" do
Flow::Login.sign_in_as_admin Flow::Login.sign_in_as_admin
set_file_template_if_not_already_set set_file_template_if_not_already_set
...@@ -101,18 +103,18 @@ module QA ...@@ -101,18 +103,18 @@ module QA
Page::Project::Show.perform(&:create_new_file!) Page::Project::Show.perform(&:create_new_file!)
Page::File::Form.perform do |form| Page::File::Form.perform do |form|
form.select_template template[:type], template[:template] form.select_template template[:file_name], template[:template]
expect(form).to have_normalized_ws_text(template[:content]) expect(form).to have_normalized_ws_text(template[:content])
form.add_name("#{SecureRandom.hex(8)}/#{template[:file_name]}")
form.commit_changes form.commit_changes
form.finished_loading? form.finished_loading?
aggregate_failures "indications of file created" do aggregate_failures "indications of file created" do
expect(form).to have_content('The file has been successfully created.') expect(form).to have_content(template[:file_name])
expect(form).to have_content(template[:type])
expect(form).to have_content('Add new file')
expect(form).to have_normalized_ws_text(template[:content].chomp) expect(form).to have_normalized_ws_text(template[:content].chomp)
expect(form).to have_content('Add new file')
end end
end end
end end
......
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