admin_channel_email_test.rb 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class AdminChannelEmailTest < TestCase
  4. def test_account_add
  5. if !ENV['MAILBOX_INIT']
  6. #raise "Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'"
  7. puts "NOTICE: Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'"
  8. return
  9. end
  10. mailbox_user = ENV['MAILBOX_INIT'].split(':')[0]
  11. mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
  12. @browser = browser_instance
  13. login(
  14. username: 'master@example.com',
  15. password: 'test',
  16. url: browser_url,
  17. )
  18. tasks_close_all()
  19. click(css: 'a[href="#manage"]')
  20. click(css: '.content.active a[href="#channels/email"]')
  21. # check if postmaster filter are shown
  22. click(css: '.content.active a[href="#c-filter"]')
  23. match(
  24. css: '.content.active #c-filter .overview',
  25. value: 'No Entries',
  26. )
  27. # check if signatures are shown
  28. click(css: '.content.active a[href="#c-signature"]')
  29. match(
  30. css: '.content.active #c-signature .overview',
  31. value: 'default',
  32. )
  33. click(css: '.content.active a[href="#c-account"]')
  34. click(css: '.content.active .js-channelNew')
  35. modal_ready()
  36. set(
  37. css: '.modal input[name="realname"]',
  38. value: 'My System',
  39. )
  40. set(
  41. css: '.modal input[name="email"]',
  42. value: mailbox_user,
  43. )
  44. set(
  45. css: '.modal input[name="password"]',
  46. value: mailbox_password,
  47. )
  48. select(
  49. css: '.modal select[name="group_id"]',
  50. value: 'Users',
  51. )
  52. click(css: '.modal button.js-submit')
  53. sleep 4
  54. watch_for(
  55. css: '.modal',
  56. value: '(already exists|unknown mailbox)',
  57. )
  58. click(css: '.modal .js-close')
  59. # delete all channels
  60. loop do
  61. break if !@browser.find_elements(css: '.content.active .js-channelDelete')[0]
  62. click(css: '.content.active .js-channelDelete')
  63. sleep 2
  64. click(css: '.modal .js-submit')
  65. sleep 2
  66. end
  67. # re-create
  68. click(css: '.content.active .js-channelNew')
  69. modal_ready()
  70. set(
  71. css: '.modal input[name="realname"]',
  72. value: 'My System',
  73. )
  74. set(
  75. css: '.modal input[name="email"]',
  76. value: mailbox_user,
  77. )
  78. set(
  79. css: '.modal input[name="password"]',
  80. value: mailbox_password,
  81. )
  82. select(
  83. css: '.modal select[name="group_id"]',
  84. value: 'Users',
  85. )
  86. click(css: '.modal button.js-submit')
  87. sleep 2
  88. watch_for_disappear(
  89. css: '.modal',
  90. )
  91. sleep 2
  92. exists_not(css: '.modal')
  93. watch_for(
  94. css: '.content.active',
  95. value: mailbox_user,
  96. )
  97. # set invalid folder
  98. click(css: '.content.active .js-editInbound')
  99. modal_ready()
  100. set(
  101. css: '.modal input[name="options::folder"]',
  102. value: 'not_existing_folder',
  103. )
  104. click(css: '.modal .js-inbound button.js-submit')
  105. watch_for(
  106. css: '.modal',
  107. value: 'Mailbox doesn\'t exist',
  108. )
  109. end
  110. end