Fix system test by choosing Cancel on basic auth alert

This commit is contained in:
Christophe Bliard
2023-12-15 17:21:00 +01:00
parent 0d4307a3a4
commit 280309d854
3 changed files with 12 additions and 3 deletions
+2 -1
View File
@@ -255,7 +255,8 @@ group :test do
gem 'capybara', '~> 3.39.0'
gem 'capybara-screenshot', '~> 1.0.17'
gem 'cuprite', '~> 0.15.0'
gem 'selenium-webdriver', '~> 4.15.0'
gem 'selenium-devtools'
gem 'selenium-webdriver', '~> 4.15'
gem 'capybara_accessible_selectors', git: 'https://github.com/citizensadvice/capybara_accessible_selectors', branch: 'main'
gem 'fuubar', '~> 2.5.0'
+5 -2
View File
@@ -938,7 +938,9 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
secure_headers (6.5.0)
selenium-webdriver (4.15.0)
selenium-devtools (0.120.0)
selenium-webdriver (~> 4.2)
selenium-webdriver (4.16.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
@@ -1210,7 +1212,8 @@ DEPENDENCIES
rubytree (~> 2.0.0)
sanitize (~> 6.1.0)
secure_headers (~> 6.5.0)
selenium-webdriver (~> 4.15.0)
selenium-devtools
selenium-webdriver (~> 4.15)
semantic (~> 1.6.1)
shoulda-context (~> 2.0)
shoulda-matchers (~> 5.0)
@@ -128,8 +128,13 @@ RSpec.describe 'authorization for BCF api', :js, with_config: { edition: 'bim' }
logout
# A basic auth alert is displayed asking to enter name and password
# Register some basic auth credentials
# A non-matching url is used so that capybara will issue a CancelAuth instead of trying to authenticate
page.driver.browser.register(username: 'foo', password: 'bar', uri: /does_not_match/)
# While not being logged in and without a token, the api cannot be accessed
visit("/api/bcf/2.1/projects/#{project.id}")
# Cancel button of basic auth should have been chosen now
expect(page)
.to have_content(JSON.dump({ message: "You need to be authenticated to access this resource." }))