mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Rewrite mobile id spec to a test
This commit is contained in:
parent
f757be4f77
commit
f327bdf6b6
2 changed files with 32 additions and 20 deletions
|
@ -1,20 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Mobile ID login', db: true do
|
|
||||||
given!(:api_user) { create(:api_user, identity_code: 1234) }
|
|
||||||
|
|
||||||
background do
|
|
||||||
digidoc_client = instance_double(Digidoc::Client, authenticate: OpenStruct.new(user_id_code: 1234), session_code: 1234)
|
|
||||||
allow(Digidoc::Client).to receive(:new).and_return(digidoc_client)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'login with phone number' do
|
|
||||||
visit registrar_login_path
|
|
||||||
click_on 'login-with-mobile-id-btn'
|
|
||||||
|
|
||||||
fill_in 'user[phone]', with: '1234'
|
|
||||||
click_button 'Login'
|
|
||||||
|
|
||||||
expect(page).to have_text('Confirmation sms was sent to your phone. Verification code is')
|
|
||||||
end
|
|
||||||
end
|
|
32
test/integration/registrar/sign_in_test.rb
Normal file
32
test/integration/registrar/sign_in_test.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class SignInTest < ActionDispatch::IntegrationTest
|
||||||
|
def setup
|
||||||
|
super
|
||||||
|
WebMock.allow_net_connect!
|
||||||
|
|
||||||
|
@user = users(:api_bestnames)
|
||||||
|
@user.identity_code = '1234'
|
||||||
|
@user.save
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_mobile_id_sign_in_page
|
||||||
|
mock_client = Minitest::Mock.new
|
||||||
|
mock_client.expect(:authenticate, OpenStruct.new(user_id_code: '1234'),
|
||||||
|
[{ phone: "+3721234",
|
||||||
|
message_to_display: "Authenticating",
|
||||||
|
service_name: "Testimine" }])
|
||||||
|
mock_client.expect(:session_code, 1234)
|
||||||
|
|
||||||
|
Digidoc::Client.stub(:new, mock_client) do
|
||||||
|
visit registrar_login_path
|
||||||
|
|
||||||
|
click_on 'login-with-mobile-id-btn'
|
||||||
|
|
||||||
|
fill_in 'user[phone]', with: '1234'
|
||||||
|
click_button 'Login'
|
||||||
|
|
||||||
|
assert(page.has_text?('Confirmation sms was sent to your phone. Verification code is'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue