File obs-server-2.9-0037-webui-ci-Adapt-tests-to-update-Capybara.patch of Package obs-server
From 0ff6d85018b7e8ce690a16d4e7a80776a7e65058 Mon Sep 17 00:00:00 2001
From: Eduardo Navarro <enavarro@suse.com>
Date: Mon, 14 May 2018 17:12:29 +0200
Subject: [PATCH] [webui][ci] Adapt tests to update Capybara
Upgrading Capybara from version 2.18.0 to 3.1.0 results in a more picky
treatment of strings, spaces and tabs.
- Updates the tests to make the rspec suite passing with the new Capybara version.
- Fix the request/show view, preventing use of unnecessary spaces.
---
src/api/app/views/webui/request/show.html.erb | 3 +--
src/api/spec/features/webui/attributes_spec.rb | 10 ++++++----
src/api/spec/features/webui/requests_spec.rb | 6 +++---
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/api/app/views/webui/request/show.html.erb b/src/api/app/views/webui/request/show.html.erb
index 78430fc76a..012059f8f6 100644
--- a/src/api/app/views/webui/request/show.html.erb
+++ b/src/api/app/views/webui/request/show.html.erb
@@ -64,8 +64,7 @@
<% end -%>
<% @other_open_reviews.each do |review| %>
<li>
- <%= sprite_tag('exclamation') %> Open review for
- <%= render :partial => 'reviewer', :locals => { :review => review } %>
+ <%= sprite_tag('exclamation') %> Open review for <%= render :partial => 'reviewer', :locals => { :review => review } %>
</li>
<% end %>
<% end %>
diff --git a/src/api/spec/features/webui/attributes_spec.rb b/src/api/spec/features/webui/attributes_spec.rb
index dbc7392d94..2500d1ba6c 100644
--- a/src/api/spec/features/webui/attributes_spec.rb
+++ b/src/api/spec/features/webui/attributes_spec.rb
@@ -34,7 +34,9 @@ RSpec.feature 'Attributes', type: :feature, js: true do
expect(page).to have_content('Attribute was successfully updated.')
visit index_attribs_path(project: user.home_project_name)
- expect(page).to have_content("#{attribute_type.namespace}:#{attribute_type.name} test 2, test 1")
+ tr_tds = page.all('tr.attribute-values:nth-child(3) td').map(&:text)
+ expect(tr_tds[0]).to eq("#{attribute_type.namespace}:#{attribute_type.name}")
+ expect(tr_tds[1]).to eq('test 2, test 1')
end
describe 'with values that are not allowed' do
@@ -94,9 +96,9 @@ RSpec.feature 'Attributes', type: :feature, js: true do
expect(page).to have_content('Attribute was successfully updated.')
visit index_attribs_path(project: user.home_project_name, package: package.name)
- within('tr.attribute-values') do
- expect(page).to have_content("#{attribute_type.namespace}:#{attribute_type.name} test 2, test 1")
- end
+ tr_tds = page.all('tr.attribute-values:nth-child(2) td').map(&:text)
+ expect(tr_tds[0]).to eq("#{attribute_type.namespace}:#{attribute_type.name}")
+ expect(tr_tds[1]).to eq('test 2, test 1')
end
end
end
diff --git a/src/api/spec/features/webui/requests_spec.rb b/src/api/spec/features/webui/requests_spec.rb
index 1de334e920..7e797f6d55 100644
--- a/src/api/spec/features/webui/requests_spec.rb
+++ b/src/api/spec/features/webui/requests_spec.rb
@@ -94,8 +94,8 @@ RSpec.feature 'Requests', type: :feature, js: true do
fill_in 'description', with: 'I can produce bugs too.'
expect { click_button 'Ok' }.to change { BsRequest.count }.by 1
- expect(page).to have_text("#{submitter.realname} (#{submitter.login}) wants the role maintainer \
- for package #{target_project} / #{target_package}")
+ expect(page).to have_text("#{submitter.realname} (#{submitter.login}) wants the role maintainer " \
+ "for package #{target_project} / #{target_package}")
expect(page).to have_css('#description-text', text: 'I can produce bugs too.')
expect(page).to have_text('In state new')
end
@@ -127,7 +127,7 @@ RSpec.feature 'Requests', type: :feature, js: true do
find(:id, 'review_type').select('User')
fill_in 'review_user', with: reviewer.login
click_button 'Ok'
- expect(page).to have_text("Open review for #{reviewer.login}")
+ expect(page).to have_text(/Open review for\s+#{reviewer.login}/)
expect(page).to have_text('Request 1 (review)')
expect(Review.all.count).to eq(1)
logout
--
2.20.1