aaa_getting_started_test.rb 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. require 'browser_test_helper'
  2. class AaaGettingStartedTest < TestCase
  3. def test_a_getting_started
  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. location(url: browser_url)
  13. watch_for(
  14. css: '.setup.wizard',
  15. value: 'setup new system',
  16. )
  17. click(css: '.js-start .btn--primary')
  18. watch_for(
  19. css: '.setup.wizard',
  20. value: 'admin',
  21. )
  22. set(
  23. css: '.js-admin input[name="firstname"]',
  24. value: 'Test Master',
  25. )
  26. set(
  27. css: '.js-admin input[name="lastname"]',
  28. value: 'Agent',
  29. )
  30. set(
  31. css: '.js-admin input[name="email"]',
  32. value: 'master@example.com',
  33. )
  34. set(
  35. css: '.js-admin input[name="firstname"]',
  36. value: 'Test Master',
  37. )
  38. set(
  39. css: '.js-admin input[name="password"]',
  40. value: 'test1234äöüß',
  41. )
  42. set(
  43. css: '.js-admin input[name="password_confirm"]',
  44. value: 'test1234äöüß',
  45. )
  46. click(css: '.js-admin .btn--success')
  47. # getting started - base
  48. watch_for(
  49. css: '.js-base h2',
  50. value: 'Organization',
  51. )
  52. set(
  53. css: '.js-base input[name="organization"]',
  54. value: 'Some Organization',
  55. )
  56. set(
  57. css: '.js-base input[name="url"]',
  58. value: 'some host',
  59. )
  60. click(
  61. css: '.js-base .btn--primary',
  62. )
  63. watch_for(
  64. css: 'body',
  65. value: 'A URL looks like',
  66. )
  67. set(
  68. css: '.js-base input[name="url"]',
  69. value: browser_url,
  70. )
  71. click(
  72. css: '.js-base .btn--primary',
  73. )
  74. # getting started - email notification
  75. watch_for(
  76. css: '.js-outbound h2',
  77. value: 'Email Notification',
  78. )
  79. location_check(
  80. url: '#getting_started/email_notification',
  81. )
  82. click(
  83. css: '.js-outbound .btn--primary',
  84. )
  85. # getting started - create email account
  86. watch_for(
  87. css: '.js-channel h2',
  88. value: 'Connect Channels',
  89. )
  90. location_check(
  91. url: '#getting_started/channel',
  92. )
  93. click(
  94. css: '.js-channel .email .provider_name',
  95. )
  96. set(
  97. css: '.js-intro input[name="realname"]',
  98. value: 'Some Realname',
  99. )
  100. set(
  101. css: '.js-intro input[name="email"]',
  102. value: mailbox_user,
  103. )
  104. set(
  105. css: '.js-intro input[name="password"]',
  106. value: mailbox_password,
  107. )
  108. click(
  109. css: '.js-intro .btn--primary',
  110. )
  111. watch_for(
  112. css: 'body',
  113. value: 'verify',
  114. timeout: 20,
  115. )
  116. watch_for(
  117. css: 'body',
  118. value: 'invite',
  119. timeout: 100,
  120. )
  121. # invite agent1
  122. location_check(
  123. url: '#getting_started/agents',
  124. )
  125. watch_for(
  126. css: '.js-agent input[name="firstname"]',
  127. )
  128. set(
  129. css: '.js-agent input[name="firstname"]',
  130. value: 'Agent 1',
  131. )
  132. set(
  133. css: '.js-agent input[name="lastname"]',
  134. value: 'Test',
  135. )
  136. set(
  137. css: '.js-agent input[name="email"]',
  138. value: 'agent1@example.com',
  139. )
  140. # not needed since we hide group selections if only one group exists
  141. #click(
  142. # css: '.js-agent input[name="group_ids"][value="1"]',
  143. #)
  144. click(
  145. css: '.js-agent .btn--success',
  146. )
  147. watch_for(
  148. css: 'body',
  149. value: 'Invitation sent',
  150. )
  151. location_check(
  152. url: '#getting_started/agents',
  153. )
  154. click(
  155. css: '.js-agent .btn--primary',
  156. )
  157. watch_for(
  158. css: 'body',
  159. value: 'My Stats',
  160. )
  161. location_check(
  162. url: '#clues',
  163. )
  164. clues_close(
  165. optional: false,
  166. )
  167. # verify organization and fqdn
  168. click(
  169. css: 'a[href="#manage"]',
  170. )
  171. click(
  172. css: '.content.active a[href="#settings/branding"]',
  173. )
  174. match(
  175. css: '.content.active input[name="organization"]',
  176. value: 'Some Organization',
  177. )
  178. click(
  179. css: '.content.active a[href="#settings/system"]',
  180. )
  181. fqdn = nil
  182. if browser_url =~ %r{://(.+?)(:.+?|/.+?|)$}
  183. fqdn = $1
  184. end
  185. raise "Unable to get fqdn based on #{browser_url}" if !fqdn
  186. match(
  187. css: '.content.active input[name="fqdn"]',
  188. value: fqdn,
  189. )
  190. end
  191. def test_b_accounts_auto
  192. #return # TODO: temp disable
  193. accounts = []
  194. (1..10).each do |count|
  195. next if !ENV["MAILBOX_AUTO#{count}"]
  196. mailbox_user = ENV["MAILBOX_AUTO#{count}"].split(':')[0]
  197. mailbox_password = ENV["MAILBOX_AUTO#{count}"].split(':')[1]
  198. account = {
  199. realname: 'auto account',
  200. email: mailbox_user,
  201. password: mailbox_password,
  202. }
  203. accounts.push account
  204. end
  205. if accounts.blank?
  206. #raise "Need min. MAILBOX_AUTO1 as ENV variable like export MAILBOX_AUTO1='nicole.braun2015@gmail.com:somepass'"
  207. puts "NOTICE: Need min. MAILBOX_AUTO1 as ENV variable like export MAILBOX_AUTO1='nicole.braun2015@gmail.com:somepass'"
  208. return
  209. end
  210. @browser = browser_instance
  211. login(
  212. username: 'master@example.com',
  213. password: 'test',
  214. url: browser_url,
  215. )
  216. accounts.each do |account|
  217. # getting started - auto mail
  218. location(url: browser_url + '/#getting_started/channel')
  219. click(
  220. css: '.js-channel .email .provider_name',
  221. )
  222. set(
  223. css: '.js-intro input[name="realname"]',
  224. value: account[:realname],
  225. )
  226. set(
  227. css: '.js-intro input[name="email"]',
  228. value: account[:email],
  229. )
  230. set(
  231. css: '.js-intro input[name="password"]',
  232. value: account[:password],
  233. )
  234. click(
  235. css: '.js-intro .btn--primary',
  236. )
  237. watch_for(
  238. css: 'body',
  239. value: 'verify',
  240. timeout: 20,
  241. )
  242. watch_for(
  243. css: 'body',
  244. value: 'invite',
  245. timeout: 100,
  246. )
  247. location_check(
  248. url: '#getting_started/agents',
  249. )
  250. end
  251. end
  252. def test_b_accounts_manual
  253. #return # TODO: temp disable
  254. accounts = []
  255. (1..10).each do |count|
  256. next if !ENV["MAILBOX_MANUAL#{count}"]
  257. mailbox_user = ENV["MAILBOX_MANUAL#{count}"].split(':')[0]
  258. mailbox_password = ENV["MAILBOX_MANUAL#{count}"].split(':')[1]
  259. mailbox_inbound = ENV["MAILBOX_MANUAL#{count}"].split(':')[2]
  260. mailbox_outbound = ENV["MAILBOX_MANUAL#{count}"].split(':')[3]
  261. account = {
  262. realname: 'manual account',
  263. email: mailbox_user,
  264. password: mailbox_password,
  265. inbound: {
  266. 'options::host' => mailbox_inbound,
  267. },
  268. outbound: {
  269. 'options::host' => mailbox_outbound,
  270. },
  271. }
  272. accounts.push account
  273. end
  274. if accounts.blank?
  275. #raise "Need min. MAILBOX_MANUAL1 as ENV variable like export MAILBOX_MANUAL1='nicole.bauer2015@yahoo.de:somepass:imap.mail.yahoo.com:smtp.mail.yahoo.com'"
  276. puts "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'"
  277. return
  278. end
  279. @browser = browser_instance
  280. login(
  281. username: 'master@example.com',
  282. password: 'test',
  283. url: browser_url,
  284. )
  285. accounts.each do |account|
  286. # getting started - manual mail
  287. location(url: browser_url + '/#getting_started/channel')
  288. click(
  289. css: '.js-channel .email .provider_name',
  290. )
  291. set(
  292. css: '.js-intro input[name="realname"]',
  293. value: account[:realname],
  294. )
  295. set(
  296. css: '.js-intro input[name="email"]',
  297. value: account[:email],
  298. )
  299. set(
  300. css: '.js-intro input[name="password"]',
  301. value: account[:password],
  302. )
  303. click(
  304. css: '.js-intro .btn--primary',
  305. )
  306. watch_for(
  307. css: '.js-inbound h2',
  308. value: 'inbound',
  309. timeout: 220,
  310. )
  311. watch_for(
  312. css: '.js-inbound',
  313. value: 'manual',
  314. )
  315. set(
  316. css: '.js-inbound input[name="options::host"]',
  317. value: account[:inbound]['options::host'],
  318. )
  319. click(
  320. css: '.js-inbound .btn--primary',
  321. )
  322. watch_for(
  323. css: '.js-outbound h2',
  324. value: 'outbound',
  325. )
  326. select(
  327. css: '.js-outbound select[name="adapter"]',
  328. value: 'SMTP - configure your own outgoing SMTP settings',
  329. )
  330. set(
  331. css: '.js-outbound input[name="options::host"]',
  332. value: account[:outbound]['options::host'],
  333. )
  334. click(
  335. css: '.js-outbound .btn--primary',
  336. )
  337. watch_for(
  338. css: 'body',
  339. value: 'verify',
  340. )
  341. watch_for(
  342. css: 'body',
  343. value: 'invite',
  344. timeout: 190,
  345. )
  346. location_check(
  347. url: '#getting_started/agents',
  348. )
  349. end
  350. end
  351. end