admin_channel_email_test.rb 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. require 'browser_test_helper'
  2. class AdminChannelEmailTest < TestCase
  3. def test_account_add
  4. if !ENV['MAILBOX_INIT']
  5. #raise "Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'"
  6. puts "NOTICE: Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'"
  7. return
  8. end
  9. mailbox_user = ENV['MAILBOX_INIT'].split(':')[0]
  10. mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
  11. @browser = browser_instance
  12. login(
  13. username: 'master@example.com',
  14. password: 'test',
  15. url: browser_url,
  16. )
  17. tasks_close_all()
  18. click(css: 'a[href="#manage"]')
  19. click(css: '.content.active a[href="#channels/email"]')
  20. # check if postmaster filter are shown
  21. click(css: '.content.active a[href="#c-filter"]')
  22. match(
  23. css: '.content.active #c-filter .overview',
  24. value: 'No Entries',
  25. )
  26. # check if signatures are shown
  27. click(css: '.content.active a[href="#c-signature"]')
  28. match(
  29. css: '.content.active #c-signature .overview',
  30. value: 'default',
  31. )
  32. click(css: '.content.active a[href="#c-account"]')
  33. click(css: '.content.active .js-channelNew')
  34. modal_ready()
  35. set(
  36. css: '.modal input[name="realname"]',
  37. value: 'My System',
  38. )
  39. set(
  40. css: '.modal input[name="email"]',
  41. value: mailbox_user,
  42. )
  43. set(
  44. css: '.modal input[name="password"]',
  45. value: mailbox_password,
  46. )
  47. select(
  48. css: '.modal select[name="group_id"]',
  49. value: 'Users',
  50. )
  51. click(css: '.modal button.js-submit')
  52. sleep 4
  53. watch_for(
  54. css: '.modal',
  55. value: '(already exists|unknown mailbox)',
  56. )
  57. click(css: '.modal .js-close')
  58. # delete all channels
  59. loop do
  60. break if !@browser.find_elements(css: '.content.active .js-channelDelete')[0]
  61. click(css: '.content.active .js-channelDelete')
  62. sleep 2
  63. click(css: '.modal .js-submit')
  64. sleep 2
  65. end
  66. # re-create
  67. click(css: '.content.active .js-channelNew')
  68. modal_ready()
  69. set(
  70. css: '.modal input[name="realname"]',
  71. value: 'My System',
  72. )
  73. set(
  74. css: '.modal input[name="email"]',
  75. value: mailbox_user,
  76. )
  77. set(
  78. css: '.modal input[name="password"]',
  79. value: mailbox_password,
  80. )
  81. select(
  82. css: '.modal select[name="group_id"]',
  83. value: 'Users',
  84. )
  85. click(css: '.modal button.js-submit')
  86. sleep 2
  87. watch_for_disappear(
  88. css: '.modal',
  89. )
  90. sleep 2
  91. exists_not(css: '.modal')
  92. watch_for(
  93. css: '.content.active',
  94. value: mailbox_user,
  95. )
  96. # set invalid folder
  97. click(css: '.content.active .js-editInbound')
  98. modal_ready()
  99. set(
  100. css: '.modal input[name="options::folder"]',
  101. value: 'not_existing_folder',
  102. )
  103. click(css: '.modal .js-inbound button.js-submit')
  104. watch_for(
  105. css: '.modal',
  106. value: 'Mailbox doesn\'t exist',
  107. )
  108. end
  109. # test the creation and cloning of Postmaster filters
  110. # confirm fix for issue #2170 - Cannot clone PostmasterFilter
  111. def test_filter_clone
  112. filter_name = "Test Filter #{rand(999_999)}"
  113. @browser = browser_instance
  114. login(
  115. username: 'master@example.com',
  116. password: 'test',
  117. url: browser_url,
  118. )
  119. tasks_close_all()
  120. click(css: 'a[href="#manage"]')
  121. click(css: '.content.active a[href="#channels/email"]')
  122. click(css: '.content.active a[href="#c-filter"]')
  123. # create a new email filter
  124. click(css: '.content.active a[data-type="new"]')
  125. modal_ready()
  126. set(
  127. css: '.modal input[name="name"]',
  128. value: filter_name,
  129. )
  130. set(
  131. css: '.modal input[name="match::from::value"]',
  132. value: 'target',
  133. )
  134. click(css: '.modal .js-submit')
  135. modal_disappear()
  136. watch_for(
  137. css: '.content.active .table',
  138. value: filter_name,
  139. )
  140. # now clone filter that we just created
  141. click(css: '.content.active .table #tableActions')
  142. click(css: '.content.active .table .dropdown .js-clone')
  143. modal_ready()
  144. click(css: '.modal .js-submit')
  145. modal_disappear()
  146. # confirm the clone exists in the table
  147. watch_for(
  148. css: '.content.active .table',
  149. value: "Clone: #{filter_name}",
  150. )
  151. end
  152. end