Make login through form in tests more readable

We're removing the word "email" from the method name because the method
was accepting either an email or a username, and we're using the name of
the label to fill in fields, which is better because it checks that the
label is correctly associated with the field , as shown for instance in
commit 431ebeda8.
This commit is contained in:
Javi Martín
2025-03-13 01:47:56 +01:00
parent fa9ab61f72
commit 8774488650
2 changed files with 7 additions and 8 deletions

View File

@@ -14,18 +14,17 @@ module Users
expect(page).to have_content "Thank you for registering"
end
def login_through_form_with_email_and_password(email = "manuela@consul.dev", password = "judgementday")
visit root_path
click_link "Sign in"
def login_through_form_with(email_or_username, password:)
visit new_user_session_path
fill_in "user_login", with: email
fill_in "user_password", with: password
fill_in "Email or username", with: email_or_username
fill_in "Password", with: password
click_button "Enter"
end
def login_through_form_as(user)
login_through_form_with_email_and_password(user.email, user.password)
login_through_form_with(user.email, password: user.password)
end
def login_through_form_as_officer(officer)

View File

@@ -42,7 +42,7 @@ describe "Account" do
logout
login_through_form_with_email_and_password(user.email, "new_password")
login_through_form_with(user.email, password: "new_password")
expect(page).to have_content "You have been signed in successfully."
end
@@ -63,7 +63,7 @@ describe "Account" do
logout
login_through_form_with_email_and_password(user.username, new_password)
login_through_form_with(user.username, password: new_password)
expect(page).to have_content "You have been signed in successfully."
end