2018-11-06 17:07:44 +01:00
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
2018-12-12 00:59:49 +01:00
|
|
|
|
feature 'Signing up:' do
|
2018-11-08 15:02:41 +01:00
|
|
|
|
let(:user_email) { generate :user_email }
|
2019-06-20 00:36:50 +02:00
|
|
|
|
let(:user_password) { 'démarches-simplifiées-pwd' }
|
2019-08-23 15:32:33 +02:00
|
|
|
|
let(:procedure) { create :simple_procedure, :with_service }
|
2018-11-08 15:02:41 +01:00
|
|
|
|
|
2018-11-06 17:07:44 +01:00
|
|
|
|
scenario 'a new user can sign-up' do
|
2019-08-23 15:32:33 +02:00
|
|
|
|
visit commencer_path(path: procedure.path)
|
|
|
|
|
click_on 'Créer un compte demarches-simplifiees.fr'
|
2018-11-06 17:07:44 +01:00
|
|
|
|
|
2018-11-08 15:02:41 +01:00
|
|
|
|
sign_up_with user_email, user_password
|
|
|
|
|
expect(page).to have_content "nous avons besoin de vérifier votre adresse #{user_email}"
|
2018-11-06 17:07:44 +01:00
|
|
|
|
|
2018-11-08 15:02:41 +01:00
|
|
|
|
click_confirmation_link_for user_email
|
2018-11-06 17:07:44 +01:00
|
|
|
|
expect(page).to have_content 'Votre compte a été activé'
|
2019-08-23 15:32:33 +02:00
|
|
|
|
expect(page).to have_current_path commencer_path(path: procedure.path)
|
2018-11-06 17:07:44 +01:00
|
|
|
|
end
|
|
|
|
|
|
2019-12-02 17:16:18 +01:00
|
|
|
|
context 'when the user makes a typo in their email address' do
|
2019-12-02 15:27:02 +01:00
|
|
|
|
let(:procedure) { create :simple_procedure, :with_service }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
visit commencer_path(path: procedure.path)
|
|
|
|
|
click_on 'Créer un compte demarches-simplifiees.fr'
|
|
|
|
|
expect(page).to have_selector('.suspect-email', visible: false)
|
2019-12-02 17:16:18 +01:00
|
|
|
|
fill_in 'Email', with: 'bidou@yahoo.rf'
|
|
|
|
|
fill_in 'Mot de passe', with: '12345'
|
2019-12-02 15:27:02 +01:00
|
|
|
|
end
|
|
|
|
|
|
2019-12-02 17:16:18 +01:00
|
|
|
|
scenario 'they can accept the suggestion', js: true do
|
2019-12-02 15:27:02 +01:00
|
|
|
|
expect(page).to have_selector('.suspect-email', visible: true)
|
|
|
|
|
click_on 'Oui'
|
2019-12-02 17:16:18 +01:00
|
|
|
|
expect(page).to have_field("Email", :with => 'bidou@yahoo.fr')
|
2019-12-02 15:27:02 +01:00
|
|
|
|
expect(page).to have_selector('.suspect-email', visible: false)
|
|
|
|
|
end
|
|
|
|
|
|
2019-12-02 17:16:18 +01:00
|
|
|
|
scenario 'they can discard the suggestion', js: true do
|
2019-12-02 15:27:02 +01:00
|
|
|
|
expect(page).to have_selector('.suspect-email', visible: true)
|
|
|
|
|
click_on 'Non'
|
|
|
|
|
expect(page).to have_field("Email", :with => 'bidou@yahoo.rf')
|
|
|
|
|
expect(page).to have_selector('.suspect-email', visible: false)
|
|
|
|
|
end
|
2019-12-02 17:16:42 +01:00
|
|
|
|
|
|
|
|
|
scenario 'they can fix the typo themselves', js: true do
|
|
|
|
|
expect(page).to have_selector('.suspect-email', visible: true)
|
|
|
|
|
fill_in 'Email', with: 'bidou@yahoo.fr'
|
|
|
|
|
blur
|
|
|
|
|
expect(page).to have_selector('.suspect-email', visible: false)
|
|
|
|
|
end
|
2019-12-02 15:27:02 +01:00
|
|
|
|
end
|
|
|
|
|
|
2019-08-23 15:32:33 +02:00
|
|
|
|
scenario 'a new user can’t sign-up with too short password when visiting a procedure' do
|
|
|
|
|
visit commencer_path(path: procedure.path)
|
|
|
|
|
click_on 'Créer un compte demarches-simplifiees.fr'
|
2018-12-12 00:59:49 +01:00
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path new_user_registration_path
|
|
|
|
|
sign_up_with user_email, '1234567'
|
|
|
|
|
expect(page).to have_current_path user_registration_path
|
|
|
|
|
expect(page).to have_content 'Le mot de passe est trop court'
|
|
|
|
|
|
|
|
|
|
# Then with a good password
|
|
|
|
|
sign_up_with user_email, user_password
|
|
|
|
|
expect(page).to have_current_path new_user_confirmation_path user: { email: user_email }
|
|
|
|
|
expect(page).to have_content "nous avons besoin de vérifier votre adresse #{user_email}"
|
|
|
|
|
end
|
|
|
|
|
|
2018-11-06 17:07:44 +01:00
|
|
|
|
context 'when visiting a procedure' do
|
2019-01-14 16:26:53 +01:00
|
|
|
|
let(:procedure) { create :simple_procedure, :with_service }
|
2018-11-06 17:07:44 +01:00
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
visit commencer_path(path: procedure.path)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'a new user can sign-up and fill the procedure' do
|
|
|
|
|
click_on 'Créer un compte'
|
2019-01-16 11:57:58 +01:00
|
|
|
|
expect(page).to have_current_path new_user_registration_path
|
2019-11-26 15:05:33 +01:00
|
|
|
|
expect(page).to have_procedure_description(procedure)
|
2018-11-06 17:07:44 +01:00
|
|
|
|
|
2018-11-08 15:02:41 +01:00
|
|
|
|
sign_up_with user_email, user_password
|
|
|
|
|
expect(page).to have_content "nous avons besoin de vérifier votre adresse #{user_email}"
|
2018-11-06 17:07:44 +01:00
|
|
|
|
|
2018-11-08 15:02:41 +01:00
|
|
|
|
click_confirmation_link_for user_email
|
2019-01-16 16:16:15 +01:00
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path(commencer_path(path: procedure.path))
|
2018-11-06 17:07:44 +01:00
|
|
|
|
expect(page).to have_content 'Votre compte a été activé'
|
2019-01-16 16:16:15 +01:00
|
|
|
|
click_on 'Commencer la démarche'
|
|
|
|
|
|
2019-01-16 11:57:58 +01:00
|
|
|
|
expect(page).to have_current_path identite_dossier_path(procedure.reload.dossiers.last)
|
2019-11-26 15:05:33 +01:00
|
|
|
|
expect(page).to have_procedure_description(procedure)
|
2018-11-06 17:07:44 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
2018-11-08 15:02:41 +01:00
|
|
|
|
|
|
|
|
|
context 'when a user is not confirmed yet' do
|
|
|
|
|
before do
|
2019-08-23 15:32:33 +02:00
|
|
|
|
visit commencer_path(path: procedure.path)
|
|
|
|
|
click_on 'Créer un compte demarches-simplifiees.fr'
|
2018-11-08 15:02:41 +01:00
|
|
|
|
|
|
|
|
|
sign_up_with user_email, user_password
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Ideally, when signing-in with an unconfirmed account,
|
|
|
|
|
# the user would be redirected to the "resend email confirmation" page.
|
|
|
|
|
#
|
|
|
|
|
# However the check for unconfirmed accounts is made by Warden every time a page is loaded –
|
|
|
|
|
# and much earlier than SessionsController#create.
|
|
|
|
|
#
|
|
|
|
|
# For now only test the default behavior (an error message is displayed).
|
|
|
|
|
scenario 'they get an error message' do
|
|
|
|
|
visit root_path
|
|
|
|
|
click_on 'Connexion'
|
|
|
|
|
|
|
|
|
|
sign_in_with user_email, user_password
|
|
|
|
|
expect(page).to have_content 'Vous devez confirmer votre adresse email pour continuer'
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-11-06 17:07:44 +01:00
|
|
|
|
end
|