Skip to content

Commit

Permalink
Add Repository page tests for Bootstrap
Browse files Browse the repository at this point in the history
DoD repositories tests in projects_spec.rb were also moved to
repositories_spec.rb.

Some title attributes were also corrected

Co-authored-by: Ana María Martínez Gómez <ammartinez@suse.de>
  • Loading branch information
DavidKang and Ana06 committed Dec 10, 2018
1 parent d4851ca commit cc4688b
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
= dod_element.url
(#{dod_element.repotype})
- if User.current.can_modify?(project)
= link_to('#', title: 'Edit DoD Source', data: { toggle: 'modal', target: "#edit-dod-source-modal-#{dod_element.id}" }) do
= link_to('#', title: 'Edit Download on Demand Source', data: { toggle: 'modal', target: "#edit-dod-source-modal-#{dod_element.id}" }) do
%i.fas.fa-edit.text-secondary
= link_to('#', title: 'Delete Download on Demand Source',
data: { toggle: 'modal', target: "#delete-dod-source-modal-#{dod_element.id}" }) do
Expand All @@ -20,7 +20,7 @@
.row
- if User.current.can_modify?(project)
.col
= link_to('#', title: 'Add DoD Source', data: { toggle: 'modal', target: "#add-dod-source-modal-#{repository.id}" }) do
= link_to('#', title: 'Add Download on Demand Source', data: { toggle: 'modal', target: "#add-dod-source-modal-#{repository.id}" }) do
%i.fas.fa-plus-circle.text-primary
.col
= link_to('#', title: 'Delete Repository', data: { toggle: 'modal', target: "#delete-repository-#{repository.id}" }) do
Expand Down
32 changes: 0 additions & 32 deletions src/api/spec/bootstrap/features/webui/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,4 @@
expect(find(:css, '#description-text')).to have_text(very_long_description)
end
end

describe 'DoD Repositories' do
let(:project_with_dod_repo) { create(:project) }
let(:repository) { create(:repository, project: project_with_dod_repo) }
let!(:download_repository) { create(:download_repository, repository: repository) }

before do
login admin_user
end

scenario 'adding DoD repositories via meta editor' do
fixture_file = File.read(Rails.root + 'test/fixtures/backend/download_on_demand/project_with_dod.xml').
gsub('user5', admin_user.login)

visit(project_meta_path(project: admin_user.home_project_name))
page.evaluate_script("editors[0].setValue(\"#{fixture_file.gsub("\n", '\n')}\");")
click_button('Save')
expect(page).to have_css('#flash', text: 'Config successfully saved!')

visit(project_repositories_path(project: admin_user.home_project_name))
within '.repository-container' do
expect(page).to have_link('standard')
expect(page).to have_link('Delete repository')
expect(page).to have_text('Download on demand sources')
expect(page).to have_link('Add')
expect(page).to have_link('Edit')
expect(page).to have_link('Delete')
expect(page).to have_link('http://mola.org2')
expect(page).to have_text('rpmmd')
end
end
end
end
142 changes: 142 additions & 0 deletions src/api/spec/bootstrap/features/webui/repositories_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
require 'browser_helper'

RSpec.feature 'Bootstrap_Repositories', type: :feature, js: true, vcr: true do
let(:admin_user) { create(:admin_user) }

describe 'DoD Repositories' do
let(:project_with_dod_repo) { create(:project) }
let(:repository) { create(:repository, project: project_with_dod_repo) }
let!(:repo_arch) { create(:repository_architecture, repository: repository, architecture: Architecture.find_by_name('armv7l')) }
let!(:download_repository_source) { create(:download_repository, repository: repository) }
let!(:download_repository_source_2) { create(:download_repository, repository: repository, arch: 'armv7l') }
let(:dod_repository) { download_repository_source.repository }

before do
login admin_user
end

scenario 'adding DoD repositories' do
visit(project_repositories_path(project: admin_user.home_project_name))
click_link('Add DoD Repository')
fill_in('Repository name', with: 'My DoD repository')
select('i586', from: 'Architecture')
select('rpmmd', from: 'Type')
fill_in('Url', with: 'http://somerandomurl.es')
fill_in('Arch. Filter', with: 'i586, noarch')
fill_in('Master Url', with: 'http://somerandomurl2.es')
fill_in('SSL Fingerprint', with: '293470239742093')
fill_in('Public Key', with: 'JLKSDJFSJ83U4902RKLJSDFLJF2J9IJ23OJFKJFSDF')
click_button('Accept')

expect(page).to have_css('.repository-card')

within '.repository-card' do
expect(page).to have_text('My DoD repository')
expect(page).to have_link(title: 'Delete Repository')
expect(page).to have_text('Download on demand sources')
expect(page).to have_link(title: 'Add Download on Demand Source')
expect(page).to have_link(title: 'Edit Download on Demand Source')
expect(page).to have_link(title: 'Delete Download on Demand Source')
expect(page).to have_link('http://somerandomurl.es')
expect(page).to have_text('rpmmd')
end
end

scenario 'removing DoD repositories' do
visit(project_repositories_path(project: project_with_dod_repo))
within '.repository-card' do
click_link(title: 'Delete Repository')
end

expect(find("#delete-repository-#{dod_repository.id}")).
to have_text("Please confirm deletion of '#{dod_repository}' repository")

within("#delete-repository-#{dod_repository.id} .modal-footer") do
click_button('Delete')
end

expect(page).to have_text 'Successfully removed repository'
expect(project_with_dod_repo.repositories).to be_empty
end

scenario 'editing download repositories' do
visit(project_repositories_path(project: project_with_dod_repo))
within '.repository-card' do
find("[data-target='#edit-dod-source-modal-#{download_repository_source}']").click
end

within("#edit-dod-source-modal-#{download_repository_source}") do
select('i586', from: 'Architecture')
select('deb', from: 'Type')
fill_in('Url', with: 'http://some_random_url_2.es')
fill_in('Arch. Filter', with: 'i586, noarch')
fill_in('Master Url', with: 'http://some_other_url.es')
fill_in('SSL Fingerprint', with: 'test')
fill_in('Public Key', with: 'some_key')
click_button('Accept')
end

download_repository_source.reload

expect(download_repository_source.arch).to eq('i586')
expect(download_repository_source.repotype).to eq('deb')
expect(download_repository_source.url).to eq('http://some_random_url_2.es')
expect(download_repository_source.archfilter).to eq('i586, noarch')
expect(download_repository_source.masterurl).to eq('http://some_other_url.es')
expect(download_repository_source.mastersslfingerprint).to eq('test')
expect(download_repository_source.pubkey).to eq('some_key')
end

scenario 'removing download repository sources' do
visit(project_repositories_path(project: project_with_dod_repo))
within '.repository-card' do
find("[data-target='#delete-dod-source-modal-#{download_repository_source}']").click
end

expect(find("#delete-dod-source-modal-#{download_repository_source}")).
to have_text("Please confirm deletion of '#{download_repository_source.arch}' Download on Demand")

within("#delete-dod-source-modal-#{download_repository_source} .modal-footer") do
click_button('Delete')
end
expect(page).to have_text 'Successfully removed Download on Demand'
expect(repository.download_repositories.count).to eq(1)

within '.repository-card' do
find("[data-target='#delete-dod-source-modal-#{download_repository_source_2}']").click
end

expect(find("#delete-dod-source-modal-#{download_repository_source_2}")).
to have_text("Please confirm deletion of '#{download_repository_source_2.arch}' Download on Demand")

within("#delete-dod-source-modal-#{download_repository_source_2} .modal-footer") do
click_button('Delete')
end

expect(page).to have_text "Download on Demand can't be removed: DoD Repositories must have at least one repository."
expect(repository.download_repositories.count).to eq(1)
end

scenario 'adding DoD repositories via meta editor' do
fixture_file = File.read(Rails.root + 'test/fixtures/backend/download_on_demand/project_with_dod.xml').
gsub('user5', admin_user.login)

visit(project_meta_path(project: admin_user.home_project_name))
page.evaluate_script("editors[0].setValue(\"#{fixture_file.gsub("\n", '\n')}\");")
click_button('Save')
expect(page).to have_css('#flash', text: 'Config successfully saved!')

visit(project_repositories_path(project: admin_user.home_project_name))
within '.repository-card' do
expect(page).to have_link('standard')
expect(page).to have_link(title: 'Delete Repository')
expect(page).to have_text('Download on demand sources')
expect(page).to have_link(title: 'Add Download on Demand Source')
expect(page).to have_link(title: 'Edit Download on Demand Source')
expect(page).to have_link(title: 'Delete Download on Demand Source')
expect(page).to have_link('http://mola.org2')
expect(page).to have_text('rpmmd')
end
end
end
end
7 changes: 6 additions & 1 deletion src/api/spec/features/webui/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
end

scenario "create subproject with checked 'disable publishing' checkbox" do
skip_if_bootstrap

login user
visit project_subprojects_path(project: user.home_project)

Expand Down Expand Up @@ -176,6 +178,10 @@
end

describe 'repositories tab' do
before do
skip_if_bootstrap
end

include_examples 'tests for sections with flag tables'

describe 'DoD repositories' do
Expand Down Expand Up @@ -270,7 +276,6 @@
end

scenario 'adding DoD repositories via meta editor' do
skip_if_bootstrap
fixture_file = File.read(Rails.root + 'test/fixtures/backend/download_on_demand/project_with_dod.xml').
gsub('user5', admin_user.login)

Expand Down

0 comments on commit cc4688b

Please sign in to comment.