After a `visit`, we were checking for content or filling in fields that
were already there before the `visit`, so we weren't 100% sure that the
request had finished before the test continued.
In the case of the verification tests, we were clicking the submit
buttons over and over without and then checking or interacting with
elements that were already there. Even though the button was disabled
between requests, meaning there wouldn't be simultaneous requests, it
was possible to interact with a form field before waiting for the
request to finish.
Some of these tests have recently failed on our CI, and it might be
because of that:
```
1) Admin budgets Edit Changing name for current locale will update the
slug if budget is in draft phase
Failure/Error: raise ex, cause: cause
Selenium::WebDriver::Error::UnknownError:
unknown error: unhandled inspector error: {"code":-32000,
"message":"Node with given id does not belong to the document"}
(Session info: chrome=134.0.6998.35)
1) Budgets creation wizard Creation of a multiple-headings budget by
steps
Failure/Error: expect(page).to have_content "Heading created
successfully!"
Selenium::WebDriver::Error::UnknownError:
unknown error: unhandled inspector error: {"code":-32000,
"message":"Node with given id does not belong to the document"}
(Session info: chrome=134.0.6998.35)
1) Custom information texts Show custom texts instead of default ones
Failure/Error: raise ex, cause: cause
Selenium::WebDriver::Error::UnknownError:
unknown error: unhandled inspector error: {"code":-32000,
"message":"Node with given id does not belong to the document"}
(Session info: chrome=134.0.6998.35)
1) Users Regular authentication Sign in Avoid username-email collisions
Failure/Error: raise ex, cause: cause
Selenium::WebDriver::Error::UnknownError:
unknown error: unhandled inspector error: {"code":-32000,
"message":"Node with given id does not belong to the document"}
(Session info: chrome=134.0.6998.35)
2) Verify Letter Code verification 6 tries allowed
Failure/Error: raise ex, cause: cause
Selenium::WebDriver::Error::UnknownError:
unknown error: unhandled inspector error: {"code":-32000,
"message":"Node with given id does not belong to the document"}
(Session info: chrome=134.0.6998.35)
2) Valuation budget investments Valuate Finish valuation
Failure/Error: raise ex, cause: cause
Selenium::WebDriver::Error::UnknownError:
unknown error: unhandled inspector error: {"code":-32000,
"message":"Node with given id does not belong to the document"}
(Session info: chrome=134.0.6998.35)
1) Users Delete a level 2 user account from document verification page
Failure/Error: raise ex, cause: cause
Selenium::WebDriver::Error::UnknownError:
unknown error: unhandled inspector error: {"code":-32000,
"message":"Node with given id does not belong to the document"}
(Session info: chrome=134.0.6998.35)
```
140 lines
4.7 KiB
Ruby
140 lines
4.7 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "Verify Letter" do
|
|
scenario "Request a letter" do
|
|
user = create(:user, residence_verified_at: Time.current,
|
|
confirmed_phone: "611111111")
|
|
|
|
login_as(user)
|
|
visit new_letter_path
|
|
|
|
click_link "Send me a letter with the code"
|
|
|
|
expect(page).to have_content "Thank you for requesting your maximum security code " \
|
|
"(only required for the final votes). In a few days " \
|
|
"we will send it to the address featuring in the data " \
|
|
"we have on file."
|
|
|
|
user.reload
|
|
|
|
expect(user.letter_requested_at).to be
|
|
expect(user.letter_verification_code).to be
|
|
end
|
|
|
|
scenario "Deny access unless verified residence" do
|
|
user = create(:user)
|
|
|
|
login_as(user)
|
|
visit new_letter_path
|
|
|
|
expect(page).to have_content "You have not yet confirmed your residency"
|
|
expect(page).to have_current_path(new_residence_path)
|
|
end
|
|
|
|
scenario "Deny access unless verified phone/email" do
|
|
user = create(:user, residence_verified_at: Time.current)
|
|
|
|
login_as(user)
|
|
visit new_letter_path
|
|
|
|
expect(page).to have_content "You have not yet entered the confirmation code"
|
|
expect(page).to have_current_path(new_sms_path)
|
|
end
|
|
|
|
context "Code verification" do
|
|
scenario "Valid verification user logged in" do
|
|
user = create(:user, residence_verified_at: Time.current,
|
|
confirmed_phone: "611111111",
|
|
letter_verification_code: "123456")
|
|
|
|
login_as(user)
|
|
visit edit_letter_path
|
|
|
|
fill_in "verification_letter_email", with: user.email
|
|
fill_in "verification_letter_password", with: user.password
|
|
fill_in "verification_letter_verification_code", with: user.letter_verification_code
|
|
click_button "Verify my account"
|
|
|
|
expect(page).to have_content "Code correct. Your account is now verified"
|
|
expect(page).to have_current_path(account_path)
|
|
end
|
|
|
|
scenario "Valid verification of user failing to add trailing zeros" do
|
|
user = create(:user, residence_verified_at: Time.current,
|
|
confirmed_phone: "611111111",
|
|
letter_verification_code: "012345")
|
|
|
|
login_as(user)
|
|
visit edit_letter_path
|
|
|
|
fill_in "verification_letter_email", with: user.email
|
|
fill_in "verification_letter_password", with: user.password
|
|
fill_in "verification_letter_verification_code", with: "12345"
|
|
click_button "Verify my account"
|
|
|
|
expect(page).to have_content "Account verified"
|
|
expect(page).to have_current_path(account_path)
|
|
end
|
|
|
|
scenario "Valid verification user not logged in" do
|
|
user = create(:user, residence_verified_at: Time.current,
|
|
confirmed_phone: "611111111",
|
|
letter_verification_code: "123456")
|
|
|
|
visit edit_letter_path
|
|
|
|
fill_in "verification_letter_email", with: user.email
|
|
fill_in "verification_letter_password", with: user.password
|
|
fill_in "verification_letter_verification_code", with: user.letter_verification_code
|
|
click_button "Verify my account"
|
|
|
|
expect(page).to have_content "Code correct. Your account is now verified"
|
|
expect(page).to have_current_path(account_path)
|
|
end
|
|
|
|
scenario "Error messages on authentication" do
|
|
visit edit_letter_path
|
|
|
|
click_button "Verify my account"
|
|
|
|
expect(page).to have_content "Invalid email or password."
|
|
end
|
|
|
|
scenario "Error messages on verification" do
|
|
user = create(:user, residence_verified_at: Time.current,
|
|
confirmed_phone: "611111111")
|
|
|
|
visit edit_letter_path
|
|
fill_in "verification_letter_email", with: user.email
|
|
fill_in "verification_letter_password", with: user.password
|
|
click_button "Verify my account"
|
|
|
|
expect(page).to have_content "can't be blank"
|
|
end
|
|
|
|
scenario "6 tries allowed" do
|
|
user = create(:user, residence_verified_at: Time.current,
|
|
confirmed_phone: "611111111",
|
|
letter_verification_code: "123456")
|
|
|
|
visit edit_letter_path
|
|
|
|
5.times do |n|
|
|
fill_in "Email", with: user.email
|
|
fill_in "Password", with: user.password
|
|
fill_in "Code you received in letter", with: "1"
|
|
click_button "Verify my account"
|
|
|
|
expect(page).to have_field "Password", with: ""
|
|
expect(page).to have_content "Verification code incorrect"
|
|
end
|
|
|
|
fill_in "Password", with: user.password
|
|
click_button "Verify my account"
|
|
|
|
expect(page).to have_content "You have reached the maximum number of attempts. Please try again later."
|
|
expect(page).to have_current_path(account_path)
|
|
end
|
|
end
|
|
end
|