Add test case for reloading the page

pull/7995/head
Oliver Günther 5 years ago
parent 99f6339a65
commit 52f9a61f3f
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 120
      spec/features/admin/enterprise/enterprise_trial_spec.rb

@ -167,51 +167,79 @@ describe 'Enterprise trial management',
expect(page).to have_no_text 'email sent - waiting for confirmation' expect(page).to have_no_text 'email sent - waiting for confirmation'
end end
it 'can request a new trial' do context 'with a waiting request pending' do
proxy.stub('https://augur.openproject-edge.com:443/public/v1/trials', method: 'post') before do
.and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 200, body: created_body.to_json) proxy.stub('https://augur.openproject-edge.com:443/public/v1/trials', method: 'post')
.and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 200, body: created_body.to_json)
proxy.stub("https://augur.openproject-edge.com:443/public/v1/trials/#{trial_id}")
.and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 422, body: waiting_body.to_json) proxy.stub("https://augur.openproject-edge.com:443/public/v1/trials/#{trial_id}")
.and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 422, body: waiting_body.to_json)
find('.button', text: 'Start free trial').click
fill_out_modal find('.button', text: 'Start free trial').click
find('.button:not(:disabled)', text: 'Submit').click fill_out_modal
find('.button:not(:disabled)', text: 'Submit').click
expect(page).to have_text 'foo@foocorp.example'
expect(page).to have_text 'email sent - waiting for confirmation' expect(page).to have_text 'foo@foocorp.example'
expect(page).to have_text 'email sent - waiting for confirmation'
# Stub resend method end
proxy.stub("https://augur.openproject-edge.com:443/public/v1/trials/#{trial_id}/resend")
.and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 200, body: waiting_body.to_json) it 'can get the trial if reloading the page' do
# We need to go to another page to stop the request cycle
find('.op-modal--modal-body #resend-link', text: 'Resend').click visit info_admin_index_path
expect(page).to have_text 'Email has been resent.' # Stub with successful body
# Stub the proxy to a successful return
expect(page).to have_text 'foo@foocorp.example' # which marks the user has confirmed the mail link
expect(page).to have_text 'email sent - waiting for confirmation' proxy.stub("https://augur.openproject-edge.com:443/public/v1/trials/#{trial_id}")
.and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 200, body: confirmed_body.to_json)
# Stub the proxy to a successful return
# which marks the user has confirmed the mail link # Stub the details URL to still return 403
proxy.stub("https://augur.openproject-edge.com:443/public/v1/trials/#{trial_id}") proxy.stub("https://augur.openproject-edge.com:443/public/v1/trials/#{trial_id}/details")
.and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 200, body: confirmed_body.to_json) .and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 403)
# Wait until the next request visit enterprise_path
expect(page).to have_selector '.status--confirmed', text: 'confirmed', wait: 20
expect(page).to have_selector('.attributes-key-value--value-container', text: 'OpenProject Test', wait: 20)
# advance to video expect(page).to have_selector('.attributes-key-value--value-container', text: '01/01/2020')
click_on 'Continue' expect(page).to have_selector('.attributes-key-value--value-container', text: '01/02/2020')
expect(page).to have_selector('.attributes-key-value--value-container', text: '5')
# advance to close # Generated expired token has different mail
click_on 'Continue' expect(page).to have_selector('.attributes-key-value--value-container', text: 'info@openproject.com')
end
expect(page).to have_selector('.flash.notice', text: 'Successful update.', wait: 10)
expect(page).to have_selector('.attributes-key-value--value-container', text: 'OpenProject Test') it 'can confirm that trial regularly' do
expect(page).to have_selector('.attributes-key-value--value-container', text: '01/01/2020') # Stub resend method
expect(page).to have_selector('.attributes-key-value--value-container', text: '01/02/2020') proxy.stub("https://augur.openproject-edge.com:443/public/v1/trials/#{trial_id}/resend")
expect(page).to have_selector('.attributes-key-value--value-container', text: '5') .and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 200, body: waiting_body.to_json)
# Generated expired token has different mail
expect(page).to have_selector('.attributes-key-value--value-container', text: 'info@openproject.com') find('.op-modal--modal-body #resend-link', text: 'Resend').click
expect(page).to have_text 'Email has been resent.'
expect(page).to have_text 'foo@foocorp.example'
expect(page).to have_text 'email sent - waiting for confirmation'
# Stub the proxy to a successful return
# which marks the user has confirmed the mail link
proxy.stub("https://augur.openproject-edge.com:443/public/v1/trials/#{trial_id}")
.and_return(headers: {'Access-Control-Allow-Origin' => '*'}, code: 200, body: confirmed_body.to_json)
# Wait until the next request
expect(page).to have_selector '.status--confirmed', text: 'confirmed', wait: 20
# advance to video
click_on 'Continue'
# advance to close
click_on 'Continue'
expect(page).to have_selector('.flash.notice', text: 'Successful update.', wait: 10)
expect(page).to have_selector('.attributes-key-value--value-container', text: 'OpenProject Test')
expect(page).to have_selector('.attributes-key-value--value-container', text: '01/01/2020')
expect(page).to have_selector('.attributes-key-value--value-container', text: '01/02/2020')
expect(page).to have_selector('.attributes-key-value--value-container', text: '5')
# Generated expired token has different mail
expect(page).to have_selector('.attributes-key-value--value-container', text: 'info@openproject.com')
end
end end
end end

Loading…
Cancel
Save