aaa_getting_started_test.rb 8.7 KB

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