main
1# frozen_string_literal: true
2
3require 'rails_helper'
4
5describe "when logging in directly in to the application", js: true do
6 describe "when MFA is disabled", js: true do
7 let(:user) { create(:user) }
8
9 it 'redirects the user to the dashboard' do
10 visit root_path
11 fill_in "user_email", with: user.email
12 fill_in "user_password", with: user.password
13 click_button I18n.t('sessions.new.login')
14
15 expect(page).to have_content('Dashboard')
16 end
17 end
18
19 describe "when MFA is enabled", js: true do
20 let(:user) { create(:user, :mfa_configured) }
21
22 it 'prompts for a TOTP code then redirect to the dashboard' do
23 visit root_path
24 fill_in "user_email", with: user.email
25 fill_in "user_password", with: user.password
26 click_button I18n.t('sessions.new.login')
27
28 fill_in "mfa_code", with: user.mfa.current_totp
29 click_button I18n.t('sessions.new.login')
30
31 expect(page).to have_content('Dashboard')
32 end
33 end
34end