add end to end test
This commit is contained in:
parent
bb83fd2f18
commit
46fd15416b
3 changed files with 58 additions and 9 deletions
|
@ -7,6 +7,6 @@
|
||||||
= hidden_field_tag :merge_token, merge_token
|
= hidden_field_tag :merge_token, merge_token
|
||||||
= hidden_field_tag :email, email
|
= hidden_field_tag :email, email
|
||||||
= label_tag :password, 'Mot de passe (8 caractères minimum)'
|
= label_tag :password, 'Mot de passe (8 caractères minimum)'
|
||||||
= password_field_tag :password, nil, autocomplete: 'current-password'
|
= password_field_tag :password, nil, autocomplete: 'current-password', id: 'password-for-another-account'
|
||||||
= button_tag 'revenir en arrière', type: 'button', class: 'button secondary', onclick: 'DS.showNewAccount(event);'
|
= button_tag 'revenir en arrière', type: 'button', class: 'button secondary', onclick: 'DS.showNewAccount(event);'
|
||||||
= submit_tag 'Fusionner les comptes', class: 'button primary'
|
= submit_tag 'Fusionner les comptes', class: 'button primary'
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
%label Ce compte #{@fci.email_france_connect} vous appartient-il ?
|
%label Ce compte #{@fci.email_france_connect} vous appartient-il ?
|
||||||
%fieldset.radios
|
%fieldset.radios
|
||||||
%label{ onclick: "DS.showFusion(event);" }
|
%label{ onclick: "DS.showFusion(event);" }
|
||||||
= radio_button_tag :value, true, false, autocomplete: "off"
|
= radio_button_tag :value, true, false, autocomplete: "off", id: 'it-is-mine'
|
||||||
Oui
|
Oui
|
||||||
|
|
||||||
%label{ onclick: "DS.showNewAccount(event);" }
|
%label{ onclick: "DS.showNewAccount(event);" }
|
||||||
= radio_button_tag :value, false, false, autocomplete: "off"
|
= radio_button_tag :value, false, false, autocomplete: "off", id: 'it-is-not-mine'
|
||||||
Non
|
Non
|
||||||
|
|
||||||
.fusion.hidden
|
.fusion.hidden
|
||||||
|
|
|
@ -34,18 +34,67 @@ feature 'France Connect Particulier Connexion' do
|
||||||
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier).and_return(france_connect_information)
|
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier).and_return(france_connect_information)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is the first connexion' do
|
context 'when no user is linked' do
|
||||||
let(:france_connect_information) { build(:france_connect_information, user_info) }
|
let(:france_connect_information) { build(:france_connect_information, user_info) }
|
||||||
|
|
||||||
before { page.find('.france-connect-login-button').click }
|
context 'and no user has the same email' do
|
||||||
|
before { page.find('.france-connect-login-button').click }
|
||||||
|
|
||||||
scenario 'he is redirected to user dossiers page' do
|
scenario 'he is redirected to user dossiers page' do
|
||||||
expect(page).to have_content('Dossiers')
|
expect(page).to have_content('Dossiers')
|
||||||
expect(User.find_by(email: email)).not_to be nil
|
expect(User.find_by(email: email)).not_to be nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'and an user exists with the same email' do
|
||||||
|
let!(:user) { create(:user, email: email, password: 'my-s3cure-p4ssword') }
|
||||||
|
|
||||||
|
before do
|
||||||
|
page.find('.france-connect-login-button').click
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'he is redirected to the merge page' do
|
||||||
|
expect(page).to have_content('Fusion des comptes')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'it merges its account' do
|
||||||
|
page.find('#it-is-mine').click
|
||||||
|
fill_in 'password', with: 'my-s3cure-p4ssword'
|
||||||
|
click_on 'Fusionner les comptes'
|
||||||
|
|
||||||
|
expect(page).to have_content('Dossiers')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'it uses another email that belongs to nobody' do
|
||||||
|
page.find('#it-is-not-mine').click
|
||||||
|
fill_in 'email', with: 'new_email@a.com'
|
||||||
|
click_on 'Utiliser ce mail'
|
||||||
|
|
||||||
|
expect(page).to have_content('Dossiers')
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'and the user wants an email that belongs to another account', js: true do
|
||||||
|
let!(:another_user) { create(:user, email: 'an_existing_email@a.com', password: 'my-s3cure-p4ssword') }
|
||||||
|
|
||||||
|
scenario 'it uses another email that belongs to another account' do
|
||||||
|
page.find('#it-is-not-mine').click
|
||||||
|
fill_in 'email', with: 'an_existing_email@a.com'
|
||||||
|
click_on 'Utiliser ce mail'
|
||||||
|
|
||||||
|
expect(page).to have_css('#password-for-another-account', visible: true)
|
||||||
|
|
||||||
|
within '.new-account-password-confirmation' do
|
||||||
|
fill_in 'password', with: 'my-s3cure-p4ssword'
|
||||||
|
click_on 'Fusionner les comptes'
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_content('Dossiers')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when is not the first connexion' do
|
context 'when a user is linked' do
|
||||||
let!(:france_connect_information) do
|
let!(:france_connect_information) do
|
||||||
create(:france_connect_information, :with_user, user_info.merge(created_at: Time.zone.parse('12/12/2012'), updated_at: Time.zone.parse('12/12/2012')))
|
create(:france_connect_information, :with_user, user_info.merge(created_at: Time.zone.parse('12/12/2012'), updated_at: Time.zone.parse('12/12/2012')))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue