mail_accounts_spec.rb 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. require 'rails_helper'
  2. RSpec.describe 'Mail accounts', type: :system do
  3. def perform_check
  4. # getting started - auto mail
  5. visit 'getting_started/channel'
  6. click('.js-channel .btn.email')
  7. yield
  8. # wait for verification process to finish
  9. expect(page).to have_css('.js-agent h2', text: 'Invite Colleagues', wait: 4.minutes)
  10. expect_current_route 'getting_started/agents'
  11. end
  12. def fill_in_credentials(account)
  13. within('.js-intro') do
  14. fill_in 'realname', with: account[:realname]
  15. fill_in 'email', with: account[:email]
  16. fill_in 'password', with: account[:password]
  17. click_on('Connect')
  18. end
  19. end
  20. scenario 'Auto detectable configurations' do
  21. skip('NOTICE: This test is currently disabled because of collisions with other non Capybara browser tests')
  22. accounts = (1..10).each_with_object([]) do |count, result|
  23. next if !ENV["MAILBOX_AUTO#{count}"]
  24. email, password = ENV["MAILBOX_AUTO#{count}"].split(':')
  25. result.push(
  26. realname: 'auto account',
  27. email: email,
  28. password: password,
  29. )
  30. end
  31. if accounts.blank?
  32. skip("NOTICE: Need min. MAILBOX_AUTO1 as ENV variable like export MAILBOX_AUTO1='nicole.braun2015@gmail.com:somepass'")
  33. end
  34. accounts.each do |account|
  35. perform_check do
  36. fill_in_credentials(account)
  37. end
  38. end
  39. end
  40. scenario 'Manual configurations' do
  41. accounts = (1..10).each_with_object([]) do |count, result|
  42. next if !ENV["MAILBOX_MANUAL#{count}"]
  43. email, password, inbound, outbound = ENV["MAILBOX_MANUAL#{count}"].split(':')
  44. result.push(
  45. realname: 'manual account',
  46. email: email,
  47. password: password,
  48. inbound: {
  49. 'options::host' => inbound,
  50. },
  51. outbound: {
  52. 'options::host' => outbound,
  53. },
  54. )
  55. end
  56. if accounts.blank?
  57. skip("NOTICE: Need min. MAILBOX_MANUAL1 as ENV variable like export MAILBOX_MANUAL1='nicole.bauer2015@yahoo.de:somepass:imap.mail.yahoo.com:smtp.mail.yahoo.com'")
  58. end
  59. accounts.each do |account|
  60. perform_check do
  61. fill_in_credentials(account)
  62. within('.js-inbound') do
  63. expect(page).to have_css('h2', text: 'inbound', wait: 4.minutes)
  64. expect(page).to have_css('body', text: 'manual')
  65. fill_in 'options::host', with: account[:inbound]['options::host']
  66. click_on('Connect')
  67. end
  68. within('.js-outbound') do
  69. expect(page).to have_css('h2', text: 'outbound', wait: 4.minutes)
  70. select('SMTP - configure your own outgoing SMTP settings', from: 'adapter')
  71. fill_in 'options::host', with: account[:outbound]['options::host']
  72. click_on('Connect')
  73. end
  74. end
  75. end
  76. end
  77. end