Skip to content

Commit

Permalink
Merge pull request #6550 from Ana06/repository_page_tests
Browse files Browse the repository at this point in the history
 Test add repository from distribution and from project
  • Loading branch information
bgeuken committed Dec 10, 2018
2 parents a73bbbd + b41b5d5 commit e6fb2f5
Show file tree
Hide file tree
Showing 4 changed files with 1,414 additions and 18 deletions.
102 changes: 84 additions & 18 deletions src/api/spec/bootstrap/features/webui/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,75 @@

RSpec.feature 'Bootstrap_Repositories', type: :feature, js: true, vcr: true do
let(:admin_user) { create(:admin_user) }
let!(:user) { create(:confirmed_user, login: 'Jane') }
let(:project) { user.home_project }
let!(:repository) { create(:repository) }

describe 'Repositories Flags' do
let!(:user) { create(:confirmed_user, login: 'Jane') }
let(:project) { user.home_project }

include_examples 'bootstrap tests for sections with flag tables'
end

describe 'Repositories' do
before do
login admin_user
end

scenario 'add/delete repository from distribution' do
# Create interconnect
visit(repositories_distributions_path(project: admin_user.home_project))
click_button('Save changes')

visit(repositories_distributions_path(project: admin_user.home_project))
find("label[for='repo_openSUSE_Tumbleweed']").click
expect(page).to have_text("Successfully added repository 'openSUSE_Tumbleweed'")

visit(project_repositories_path(project: admin_user.home_project))

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

within '.repository-card' do
expect(page).to have_link('openSUSE_Tumbleweed')
expect(page).to have_link('Edit Repository')
expect(page).to have_link('Add Repository Path')
expect(page).to have_link('Download Repository')
expect(page).to have_link('Delete Repository')
# Repository path
expect(page).to have_text('openSUSE.org/snapshot')
end

visit(repositories_distributions_path(project: admin_user.home_project))
find("label[for='repo_openSUSE_Tumbleweed']").click
expect(page).to have_text("Successfully removed repository 'openSUSE_Tumbleweed'")

visit(project_repositories_path(project: admin_user.home_project))

expect(page).not_to have_link('openSUSE_Tumbleweed')
end

scenario 'add repository from project' do
visit(project_repositories_path(project: admin_user.home_project))

click_link('Add from a Project')
fill_in('target_project', with: repository.project)
# We need to remove focus from project so that the autocomplete happens
find('#repo_name').click
click_button('Accept')

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

within '.repository-card' do
expect(page).to have_link("#{repository.project}_#{repository}")
expect(page).to have_link('Edit Repository')
expect(page).to have_link('Add Repository Path')
expect(page).to have_link('Download Repository')
expect(page).to have_link('Delete Repository')
# Repository path
expect(page).to have_text("#{repository.project}/#{repository}")
end
end
end

describe 'DoD Repositories' do
let(:project_with_dod_repo) { create(:project) }
let(:repository) { create(:repository, project: project_with_dod_repo) }
Expand All @@ -21,7 +83,7 @@
login admin_user
end

scenario 'adding DoD repositories' do
scenario 'add 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')
Expand All @@ -37,18 +99,20 @@
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('My DoD repository')
expect(page).to have_link('Add Download on Demand Source')
expect(page).to have_link('Delete Repository')
# DoD source
expect(page).to have_text('i586')
expect(page).to have_link('http://somerandomurl.es')
expect(page).to have_text('rpmmd')
expect(page).to have_text('Download on demand sources')
expect(page).to have_link('Edit Download on Demand Source')
expect(page).to have_link('Delete Download on Demand Source')
end
end

scenario 'removing DoD repositories' do
scenario 'delete DoD repositories' do
visit(project_repositories_path(project: project_with_dod_repo))
within '.repository-card' do
click_link(title: 'Delete Repository')
Expand All @@ -65,7 +129,7 @@
expect(project_with_dod_repo.repositories).to be_empty
end

scenario 'editing download repositories' do
scenario 'edit 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
Expand Down Expand Up @@ -93,7 +157,7 @@
expect(download_repository_source.pubkey).to eq('some_key')
end

scenario 'removing download repository sources' do
scenario 'delete 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
Expand Down Expand Up @@ -123,7 +187,7 @@
expect(repository.download_repositories.count).to eq(1)
end

scenario 'adding DoD repositories via meta editor' do
scenario 'add 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)

Expand All @@ -135,13 +199,15 @@
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('Add Download on Demand Source')
expect(page).to have_link('Delete Repository')
# DoD source
expect(page).to have_text('x86_64')
expect(page).to have_link('http://mola.org2')
expect(page).to have_text('rpmmd')
expect(page).to have_text('Download on demand sources')
expect(page).to have_link('Edit Download on Demand Source')
expect(page).to have_link('Delete Download on Demand Source')
end
end
end
Expand Down

0 comments on commit e6fb2f5

Please sign in to comment.