admin_channel_email_test.rb 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. # flanky
  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. modal_disappear(timeout: 20)
  88. watch_for(
  89. css: '.content.active',
  90. value: mailbox_user,
  91. )
  92. # set invalid folder
  93. click(css: '.content.active .js-editInbound')
  94. modal_ready()
  95. set(
  96. css: '.modal input[name="options::folder"]',
  97. value: 'not_existing_folder',
  98. )
  99. click(css: '.modal .js-inbound button.js-submit')
  100. watch_for(
  101. css: '.modal',
  102. value: 'Mailbox doesn\'t exist',
  103. )
  104. end
  105. # test the creation and cloning of Postmaster filters
  106. # confirm fix for issue #2170 - Cannot clone PostmasterFilter
  107. def test_filter_clone
  108. filter_name = "Test Filter #{rand(999_999)}"
  109. @browser = browser_instance
  110. login(
  111. username: 'master@example.com',
  112. password: 'test',
  113. url: browser_url,
  114. )
  115. tasks_close_all()
  116. click(css: 'a[href="#manage"]')
  117. click(css: '.content.active a[href="#channels/email"]')
  118. click(css: '.content.active a[href="#c-filter"]')
  119. # create a new email filter
  120. click(css: '.content.active a[data-type="new"]')
  121. modal_ready()
  122. set(
  123. css: '.modal input[name="name"]',
  124. value: filter_name,
  125. )
  126. set(
  127. css: '.modal input[name="match::from::value"]',
  128. value: 'target',
  129. )
  130. click(css: '.modal .js-submit')
  131. modal_disappear()
  132. watch_for(
  133. css: '.content.active .table',
  134. value: filter_name,
  135. )
  136. # now clone filter that we just created
  137. click(css: '.content.active .table .dropdown .btn--table')
  138. click(css: '.content.active .table .dropdown .js-clone')
  139. modal_ready()
  140. click(css: '.modal .js-submit')
  141. modal_disappear()
  142. # confirm the clone exists in the table
  143. watch_for(
  144. css: '.content.active .table',
  145. value: "Clone: #{filter_name}",
  146. )
  147. end
  148. end