text_module_test.rb 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class TextModuleTest < TestCase
  4. def test_I
  5. random = 'text_module_test_' + rand(999999).to_s
  6. random2 = 'text_module_test_' + rand(999999).to_s
  7. # user
  8. tests = [
  9. {
  10. :name => 'add #1',
  11. :action => [
  12. {
  13. :execute => 'close_all_tasks',
  14. },
  15. {
  16. :execute => 'click',
  17. :css => 'a[href="#admin"]',
  18. },
  19. {
  20. :execute => 'click',
  21. :css => 'a[href="#text_modules"]',
  22. },
  23. {
  24. :execute => 'click',
  25. :css => 'a[data-type="new"]',
  26. },
  27. {
  28. :execute => 'set',
  29. :css => 'input[name=name]',
  30. :value => 'some name' + random,
  31. },
  32. {
  33. :execute => 'set',
  34. :css => 'input[name="keywords"]',
  35. :value => random,
  36. },
  37. {
  38. :execute => 'set',
  39. :css => 'textarea[name="content"]',
  40. :value => 'some content' + random,
  41. },
  42. {
  43. :execute => 'click',
  44. :css => '.modal button.submit',
  45. },
  46. {
  47. :execute => 'wait',
  48. :value => 3,
  49. },
  50. {
  51. :execute => 'match',
  52. :css => 'body',
  53. :value => random,
  54. :match_result => true,
  55. },
  56. ],
  57. },
  58. {
  59. :name => 'add #2',
  60. :action => [
  61. {
  62. :execute => 'click',
  63. :css => 'a[href="#admin"]',
  64. },
  65. {
  66. :execute => 'click',
  67. :css => 'a[href="#text_modules"]',
  68. },
  69. {
  70. :execute => 'click',
  71. :css => 'a[data-type="new"]',
  72. },
  73. {
  74. :execute => 'set',
  75. :css => 'input[name=name]',
  76. :value => 'some name' + random2,
  77. },
  78. {
  79. :execute => 'set',
  80. :css => 'input[name="keywords"]',
  81. :value => random2,
  82. },
  83. {
  84. :execute => 'set',
  85. :css => 'textarea[name="content"]',
  86. :value => 'some content' + random2,
  87. },
  88. {
  89. :execute => 'click',
  90. :css => '.modal button.submit',
  91. },
  92. {
  93. :execute => 'wait',
  94. :value => 3,
  95. },
  96. {
  97. :execute => 'match',
  98. :css => 'body',
  99. :value => random2,
  100. :match_result => true,
  101. },
  102. ],
  103. },
  104. {
  105. :name => 'verify usage',
  106. :action => [
  107. {
  108. :execute => 'click',
  109. :css => 'a[href="#new"]',
  110. },
  111. {
  112. :execute => 'click',
  113. :css => 'a[href="#ticket_create/call_outbound"]',
  114. },
  115. {
  116. :execute => 'wait',
  117. :value => 2,
  118. },
  119. {
  120. :execute => 'set',
  121. :css => '.active textarea[name=body]',
  122. :value => '::' + random,
  123. },
  124. {
  125. :execute => 'wait',
  126. :value => 1,
  127. },
  128. {
  129. :execute => 'match',
  130. :css => 'body',
  131. :value => random,
  132. :match_result => true,
  133. },
  134. {
  135. :execute => 'click',
  136. :css => '.-sew-list-item.selected',
  137. },
  138. {
  139. :execute => 'wait',
  140. :value => 1,
  141. },
  142. {
  143. :execute => 'match',
  144. :css => '.active textarea[name=body]',
  145. :value => 'some content' + random,
  146. :match_result => true,
  147. },
  148. ],
  149. },
  150. ]
  151. browser_signle_test_with_login(tests, { :username => 'master@example.com' })
  152. end
  153. def test_II
  154. random = 'text_II_module_test_' + rand(999999).to_s
  155. # user
  156. tests = [
  157. {
  158. :name => 'start',
  159. :instance1 => browser_instance,
  160. :instance2 => browser_instance,
  161. :instance1_username => 'master@example.com',
  162. :instance1_password => 'test',
  163. :instance2_username => 'agent1@example.com',
  164. :instance2_password => 'test',
  165. :action => [
  166. # create ticket
  167. {
  168. :where => :instance2,
  169. :execute => 'close_all_tasks',
  170. },
  171. {
  172. :where => :instance2,
  173. :execute => 'click',
  174. :css => '.taskbar-new a[href="#new"]',
  175. },
  176. {
  177. :where => :instance2,
  178. :execute => 'click',
  179. :css => '.taskbar-new a[href="#ticket_create/call_inbound"]',
  180. },
  181. {
  182. :where => :instance2,
  183. :execute => 'set',
  184. :css => '.active input[name=subject]',
  185. :value => 'A',
  186. },
  187. {
  188. :where => :instance2,
  189. :execute => 'click',
  190. :css => '.taskbar-new a[href="#new"]',
  191. },
  192. {
  193. :where => :instance2,
  194. :execute => 'click',
  195. :css => '.taskbar-new a[href="#ticket_create/call_outbound"]',
  196. },
  197. {
  198. :where => :instance2,
  199. :execute => 'set',
  200. :css => '.active input[name=subject]',
  201. :value => 'B',
  202. },
  203. # create new text module
  204. {
  205. :where => :instance1,
  206. :execute => 'click',
  207. :css => 'a[href="#admin"]',
  208. },
  209. {
  210. :where => :instance1,
  211. :execute => 'click',
  212. :css => 'a[href="#text_modules"]',
  213. },
  214. {
  215. :where => :instance1,
  216. :execute => 'click',
  217. :css => 'a[data-type="new"]',
  218. },
  219. {
  220. :where => :instance1,
  221. :execute => 'set',
  222. :css => 'input[name=name]',
  223. :value => 'some name' + random,
  224. },
  225. {
  226. :where => :instance1,
  227. :execute => 'set',
  228. :css => 'input[name="keywords"]',
  229. :value => random,
  230. },
  231. {
  232. :where => :instance1,
  233. :execute => 'set',
  234. :css => 'textarea[name="content"]',
  235. :value => 'some content <%= @ticket.customer.lastname %>' + random,
  236. },
  237. {
  238. :where => :instance1,
  239. :execute => 'click',
  240. :css => '.modal button.submit',
  241. },
  242. {
  243. :execute => 'wait',
  244. :value => 3,
  245. },
  246. {
  247. :where => :instance1,
  248. :execute => 'match',
  249. :css => 'body',
  250. :value => random,
  251. :match_result => true,
  252. },
  253. ],
  254. },
  255. {
  256. :name => 'check if text module exists in instance2, for ready to use',
  257. :action => [
  258. {
  259. :execute => 'wait',
  260. :value => 4,
  261. },
  262. {
  263. :where => :instance2,
  264. :execute => 'set',
  265. :css => '.active textarea[name=body]',
  266. :value => '::' + random,
  267. },
  268. {
  269. :where => :instance2,
  270. :execute => 'wait',
  271. :value => 1,
  272. },
  273. {
  274. :where => :instance2,
  275. :execute => 'match',
  276. :css => 'body',
  277. :value => random,
  278. :match_result => true,
  279. },
  280. {
  281. :where => :instance2,
  282. :execute => 'click',
  283. :css => '.-sew-list-item.selected',
  284. },
  285. {
  286. :where => :instance2,
  287. :execute => 'wait',
  288. :value => 1,
  289. },
  290. {
  291. :where => :instance2,
  292. :execute => 'match',
  293. :css => '.active textarea[name=body]',
  294. :value => 'some content ' + random,
  295. :match_result => true,
  296. },
  297. {
  298. :execute => 'wait',
  299. :value => 3,
  300. },
  301. {
  302. :where => :instance2,
  303. :execute => 'set',
  304. :css => '.active .ticket_create input[name="customer_id_autocompletion"]',
  305. :value => 'nicole',
  306. },
  307. {
  308. :execute => 'wait',
  309. :value => 4,
  310. },
  311. {
  312. :where => :instance2,
  313. :execute => 'sendkey',
  314. :css => '.active .ticket_create input[name="customer_id_autocompletion"]',
  315. :value => :arrow_down,
  316. },
  317. {
  318. :where => :instance2,
  319. :execute => 'sendkey',
  320. :css => '.active .ticket_create input[name="customer_id_autocompletion"]',
  321. :value => :tab,
  322. },
  323. {
  324. :where => :instance2,
  325. :execute => 'wait',
  326. :value => 1,
  327. },
  328. {
  329. :where => :instance2,
  330. :execute => 'set',
  331. :css => '.active textarea[name=body]',
  332. :value => '::' + random,
  333. },
  334. {
  335. :where => :instance2,
  336. :execute => 'wait',
  337. :value => 1,
  338. },
  339. {
  340. :where => :instance2,
  341. :execute => 'click',
  342. :css => '.-sew-list-item.selected',
  343. },
  344. {
  345. :where => :instance2,
  346. :execute => 'wait',
  347. :value => 1,
  348. },
  349. {
  350. :where => :instance2,
  351. :execute => 'match',
  352. :css => '.active textarea[name=body]',
  353. :value => 'some content Braun' + random,
  354. :match_result => true,
  355. },
  356. ],
  357. },
  358. {
  359. :name => 'verify zoom',
  360. :action => [
  361. # create ticket
  362. {
  363. :where => :instance2,
  364. :execute => 'create_ticket',
  365. :group => 'Users',
  366. :subject => 'some subject 123äöü',
  367. :body => 'some body 123äöü',
  368. },
  369. # check ticket
  370. {
  371. :where => :instance2,
  372. :execute => 'match',
  373. :css => '.active div.article',
  374. :value => 'some body 123äöü',
  375. :match_result => true,
  376. },
  377. # check ticket zoom
  378. {
  379. :execute => 'wait',
  380. :value => 4,
  381. },
  382. {
  383. :where => :instance2,
  384. :execute => 'set',
  385. :css => '.active textarea[name=body]',
  386. :value => 'test',
  387. },
  388. {
  389. :execute => 'wait',
  390. :value => 4,
  391. },
  392. {
  393. :where => :instance2,
  394. :execute => 'set',
  395. :css => '.active textarea[name=body]',
  396. :value => '::' + random,
  397. },
  398. {
  399. :execute => 'wait',
  400. :value => 1,
  401. },
  402. {
  403. :where => :instance2,
  404. :execute => 'match',
  405. :css => 'body',
  406. :value => random,
  407. :match_result => true,
  408. },
  409. {
  410. :where => :instance2,
  411. :execute => 'click',
  412. :css => '.-sew-list-item.selected',
  413. },
  414. {
  415. :execute => 'wait',
  416. :value => 1,
  417. },
  418. {
  419. :where => :instance2,
  420. :execute => 'match',
  421. :css => '.active textarea[name=body]',
  422. :value => 'some content Braun' + random,
  423. :match_result => true,
  424. },
  425. ],
  426. },
  427. ]
  428. browser_double_test(tests)
  429. end
  430. end