aaa_getting_started_test.rb 8.8 KB

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