Skip to content

Commit 5e231a1

Browse files
joaquintomas2003nicolastemciuc
authored andcommitted
test: assert current paths
1 parent 983d639 commit 5e231a1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

spec/system/manage_webauthn_credentials_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
fill_in "Passkey name", with: "My Passkey"
2727
click_button "Create Passkey"
2828

29+
expect(page).to have_current_path(new_account_passkey_path)
2930
expect(page).to have_content("Passkey created successfully.")
3031
end
3132
end
@@ -42,6 +43,7 @@
4243
fill_in "Passkey name", with: "My Passkey"
4344
click_button "Create Passkey"
4445

46+
expect(page).to have_current_path(new_account_passkey_path)
4547
expect(page).to have_content("Passkey verification failed.")
4648
end
4749
end
@@ -55,6 +57,7 @@
5557
fill_in "Security Key name", with: "My Security Key"
5658
click_button "Create Security Key"
5759

60+
expect(page).to have_current_path(new_account_second_factor_webauthn_credential_path)
5861
expect(page).to have_content("Security Key created successfully.")
5962
end
6063
end
@@ -71,6 +74,7 @@
7174
fill_in "Security Key name", with: "My Security Key"
7275
click_button "Create Security Key"
7376

77+
expect(page).to have_current_path(new_account_second_factor_webauthn_credential_path)
7478
expect(page).to have_content("Webauthn credential verification failed.")
7579
end
7680
end
@@ -93,6 +97,7 @@
9397
click_button "Upgrade to Passkey"
9498
end
9599

100+
expect(page).to have_current_path(root_path)
96101
expect(page).to have_content("Security Key promoted to passkey successfully.")
97102

98103
within passkeys_section do

spec/system/sign_in_with_webauthn_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
authenticator.remove!
1515
end
1616

17+
# rubocop:disable RSpec/MultipleExpectations
1718
describe "sign in using passkeys" do
1819
before do
1920
add_passkey_to_authenticator(authenticator, user)
@@ -23,6 +24,7 @@
2324
visit new_account_session_path
2425
click_button "Log in with passkeys"
2526

27+
expect(page).to have_current_path(root_path)
2628
expect(page).to have_content("Signed in successfully.")
2729
end
2830

@@ -34,14 +36,18 @@
3436

3537
click_button "Log in"
3638

39+
expect(page).to have_current_path(new_account_two_factor_authentication_path)
3740
expect(page).to have_content("Two-factor authentication is required to sign in.")
3841

3942
click_button "Use security key"
4043

44+
expect(page).to have_current_path(root_path)
4145
expect(page).to have_content("Signed in successfully.")
4246
end
4347
end
48+
# rubocop:enable RSpec/MultipleExpectations
4449

50+
# rubocop:disable RSpec/MultipleExpectations
4551
describe "sign in with security keys as second factor" do
4652
before do
4753
add_security_key_to_authenticator(authenticator, user)
@@ -55,10 +61,12 @@
5561

5662
click_button "Log in"
5763

64+
expect(page).to have_current_path(new_account_two_factor_authentication_path)
5865
expect(page).to have_content("Two-factor authentication is required to sign in.")
5966

6067
click_button "Use security key"
6168

69+
expect(page).to have_current_path(root_path)
6270
expect(page).to have_content("Signed in successfully.")
6371
expect(remember_cookie).to be_nil
6472
end
@@ -77,10 +85,12 @@
7785

7886
click_button "Log in"
7987

88+
expect(page).to have_current_path(new_account_two_factor_authentication_path)
8089
expect(page).to have_content("Two-factor authentication is required to sign in.")
8190

8291
click_button "Use security key"
8392

93+
expect(page).to have_current_path(new_account_two_factor_authentication_path)
8494
expect(page).to have_content("Webauthn credential verification failed.")
8595
expect(page).to have_button("Use security key")
8696
end
@@ -96,15 +106,18 @@
96106

97107
click_button "Log in"
98108

109+
expect(page).to have_current_path(new_account_two_factor_authentication_path)
99110
expect(page).to have_content("Two-factor authentication is required to sign in.")
100111

101112
click_button "Use security key"
102113

114+
expect(page).to have_current_path(root_path)
103115
expect(page).to have_content("Signed in successfully.")
104116
expect(remember_cookie).to be_present
105117
end
106118
end
107119
end
120+
# rubocop:enable RSpec/MultipleExpectations
108121

109122
def remember_cookie
110123
page.driver.browser.manage.cookie_named("remember_account_token")

0 commit comments

Comments
 (0)