Skip to content

Commit

Permalink
Adapt repositories specs to Bootstrap UI
Browse files Browse the repository at this point in the history
Merge feature specs under spec/features/webui/repositories_spec.rb and
removed unneeded code in controller specs for the Bento UI.
  • Loading branch information
dmarcoux committed Sep 11, 2019
1 parent 3981966 commit 354f497
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 89 deletions.
81 changes: 0 additions & 81 deletions src/api/spec/bootstrap/features/webui/repositories_spec.rb

This file was deleted.

12 changes: 4 additions & 8 deletions src/api/spec/controllers/webui/repositories_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@
end

it { expect(assigns(:error)).to start_with('Repository with name') }
# FIXME: Remove 'have_http_status(:success)' after old webui got dropped
it { expect(response).to have_http_status(:success).or(have_http_status(:redirect)) }
it { expect(response).to have_http_status(:redirect) }
end

context 'with no valid repository type' do
Expand All @@ -219,8 +218,7 @@
end

it { expect(assigns(:error)).to start_with("Couldn't add repository:") }
# FIXME: Remove 'have_http_status(:success)' after old webui got dropped
it { expect(response).to have_http_status(:success).or(have_http_status(:redirect)) }
it { expect(response).to have_http_status(:redirect) }
end

context 'with no valid repository Architecture' do
Expand All @@ -232,8 +230,7 @@
end

it { expect(assigns(:error)).to start_with("Couldn't add repository:") }
# FIXME: Remove 'have_http_status(:success)' after old webui got dropped
it { expect(response).to have_http_status(:success).or(have_http_status(:redirect)) }
it { expect(response).to have_http_status(:redirect) }
end

context 'with valid repository data' do
Expand All @@ -245,8 +242,7 @@
end

it { expect(assigns(:error)).to be_nil }
# FIXME: Remove 'have_http_status(:success)' after old webui got dropped
it { expect(response).to have_http_status(:success).or(have_http_status(:redirect)) }
it { expect(response).to have_http_status(:redirect) }
end
end
end
Expand Down
75 changes: 75 additions & 0 deletions src/api/spec/features/webui/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,79 @@
end
end
end

describe 'Repositories Flags' do
let!(:user) { create(:confirmed_user, :with_home, 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

fake_distribution_body = File.open(Rails.root.join('test/fixtures/backend/distributions.xml')).read

stub_request(:get, 'https://api.opensuse.org/public/distributions.xml').
to_return(status: 200, body: fake_distribution_body, headers: {})
end

scenario 'add/delete repository from distribution' do
# Create interconnect
visit(repositories_distributions_path(project: admin_user.home_project))
click_button('Connect', match: :first)

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)
# Select the first autocomplete result
find('.ui-menu-item-wrapper', match: :first).click
# Remove focus from autocomplete. Needed to trigger update of the other input fields.
find('#target_repo').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
end

0 comments on commit 354f497

Please sign in to comment.