agent_ticket_actions_level5_test.rb 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. # encoding: utf-8
  2. require 'browser_test_helper'
  3. class AgentTicketActionLevel5Test < TestCase
  4. def test_I
  5. random = 'text_module_test_' + rand(99999999).to_s
  6. random2 = 'text_module_test_' + rand(99999999).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="#manage"]',
  18. },
  19. {
  20. :execute => 'click',
  21. :css => 'a[href="#manage/text_modules"]',
  22. },
  23. {
  24. :execute => 'click',
  25. :css => 'a[data-type="new"]',
  26. },
  27. {
  28. :execute => 'set',
  29. :css => '.modal input[name=name]',
  30. :value => 'some name' + random,
  31. },
  32. {
  33. :execute => 'set',
  34. :css => '.modal input[name="keywords"]',
  35. :value => random,
  36. },
  37. {
  38. :execute => 'set',
  39. :css => '.modal textarea[name="content"]',
  40. :value => 'some content' + random,
  41. },
  42. {
  43. :execute => 'click',
  44. :css => '.modal button.js-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="#manage"]',
  64. },
  65. {
  66. :execute => 'click',
  67. :css => 'a[href="#manage/text_modules"]',
  68. },
  69. {
  70. :execute => 'click',
  71. :css => 'a[data-type="new"]',
  72. },
  73. {
  74. :execute => 'set',
  75. :css => '.modal input[name=name]',
  76. :value => 'some name' + random2,
  77. },
  78. {
  79. :execute => 'set',
  80. :css => '.modal input[name="keywords"]',
  81. :value => random2,
  82. },
  83. {
  84. :execute => 'set',
  85. :css => '.modal textarea[name="content"]',
  86. :value => 'some content' + random2,
  87. },
  88. {
  89. :execute => 'click',
  90. :css => '.modal button.js-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"]',
  114. },
  115. {
  116. :execute => 'wait',
  117. :value => 2,
  118. },
  119. {
  120. :execute => 'set',
  121. :css => '.active [data-name="body"]',
  122. :value => 'test ::' + random,
  123. },
  124. {
  125. :execute => 'wait',
  126. :value => 2,
  127. },
  128. {
  129. :execute => 'match',
  130. :css => 'body',
  131. :value => random,
  132. :match_result => true,
  133. },
  134. {
  135. :execute => 'sendkey',
  136. :value => [:arrow_down,:enter]
  137. },
  138. {
  139. :execute => 'wait',
  140. :value => 1,
  141. },
  142. {
  143. :execute => 'match',
  144. :css => '.active [data-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(99999999).to_s
  155. user_rand = rand(99999999).to_s
  156. login = 'agent-text-module-' + user_rand
  157. firstname = 'Text' + user_rand
  158. lastname = 'Module' + user_rand
  159. email = 'agent-text-module-' + user_rand + '@example.com'
  160. password = 'agentpw'
  161. # user
  162. tests = [
  163. {
  164. :name => 'start',
  165. :instance1 => browser_instance,
  166. :instance2 => browser_instance,
  167. :instance1_username => 'master@example.com',
  168. :instance1_password => 'test',
  169. :instance2_username => 'agent1@example.com',
  170. :instance2_password => 'test',
  171. :action => [
  172. # create ticket
  173. {
  174. :where => :instance2,
  175. :execute => 'close_all_tasks',
  176. },
  177. {
  178. :where => :instance2,
  179. :execute => 'create_ticket',
  180. :subject => 'A',
  181. :customer => '',
  182. :do_not_submit => true,
  183. },
  184. {
  185. :where => :instance2,
  186. :execute => 'create_ticket',
  187. :customer => '',
  188. :subject => 'B',
  189. :do_not_submit => true,
  190. },
  191. # create new text module
  192. {
  193. :where => :instance1,
  194. :execute => 'click',
  195. :css => 'a[href="#manage"]',
  196. },
  197. {
  198. :where => :instance1,
  199. :execute => 'click',
  200. :css => 'a[href="#manage/text_modules"]',
  201. },
  202. {
  203. :where => :instance1,
  204. :execute => 'click',
  205. :css => 'a[data-type="new"]',
  206. },
  207. {
  208. :where => :instance1,
  209. :execute => 'set',
  210. :css => '.modal input[name=name]',
  211. :value => 'some name' + random,
  212. },
  213. {
  214. :where => :instance1,
  215. :execute => 'set',
  216. :css => '.modal input[name="keywords"]',
  217. :value => random,
  218. },
  219. {
  220. :where => :instance1,
  221. :execute => 'set',
  222. :css => '.modal textarea[name="content"]',
  223. :value => 'some content <%= @ticket.customer.lastname %>' + random,
  224. },
  225. {
  226. :where => :instance1,
  227. :execute => 'click',
  228. :css => '.modal button.js-submit',
  229. },
  230. {
  231. :execute => 'wait',
  232. :value => 3,
  233. },
  234. {
  235. :where => :instance1,
  236. :execute => 'match',
  237. :css => 'body',
  238. :value => random,
  239. :match_result => true,
  240. },
  241. ],
  242. },
  243. # create user
  244. {
  245. :name => 'create user',
  246. :action => [
  247. {
  248. :where => :instance1,
  249. :execute => 'create_user',
  250. :login => login,
  251. :firstname => firstname,
  252. :lastname => lastname,
  253. :email => email,
  254. :password => password,
  255. },
  256. ],
  257. },
  258. {
  259. :name => 'check if text module exists in instance2, for ready to use',
  260. :action => [
  261. {
  262. :execute => 'wait',
  263. :value => 4,
  264. },
  265. {
  266. :where => :instance2,
  267. :execute => 'set',
  268. :css => '.active [data-name="body"]',
  269. :value => '::' + random,
  270. },
  271. {
  272. :where => :instance2,
  273. :execute => 'wait',
  274. :value => 2,
  275. },
  276. {
  277. :where => :instance2,
  278. :execute => 'match',
  279. :css => 'body',
  280. :value => random,
  281. :match_result => true,
  282. },
  283. {
  284. :where => :instance2,
  285. :execute => 'sendkey',
  286. :value => [:arrow_down,:enter]
  287. },
  288. {
  289. :where => :instance2,
  290. :execute => 'wait',
  291. :value => 1,
  292. },
  293. {
  294. :where => :instance2,
  295. :execute => 'match',
  296. :css => '.active [data-name="body"]',
  297. :value => 'some content ' + random,
  298. :match_result => true,
  299. },
  300. {
  301. :execute => 'wait',
  302. :value => 3,
  303. },
  304. {
  305. :where => :instance2,
  306. :execute => 'set',
  307. :css => '.active .newTicket input[name="customer_id_completion"]',
  308. :value => 'nicole',
  309. },
  310. {
  311. :execute => 'wait',
  312. :value => 4,
  313. },
  314. {
  315. :where => :instance2,
  316. :execute => 'sendkey',
  317. :value => [:arrow_down,:enter]
  318. },
  319. {
  320. :where => :instance2,
  321. :execute => 'wait',
  322. :value => 1,
  323. },
  324. {
  325. :where => :instance2,
  326. :execute => 'set',
  327. :css => '.active [data-name="body"]',
  328. :value => '::' + random,
  329. },
  330. {
  331. :where => :instance2,
  332. :execute => 'wait',
  333. :value => 1,
  334. },
  335. {
  336. :where => :instance2,
  337. :execute => 'sendkey',
  338. :value => [:arrow_down,:enter]
  339. },
  340. {
  341. :where => :instance2,
  342. :execute => 'wait',
  343. :value => 1,
  344. },
  345. {
  346. :where => :instance2,
  347. :execute => 'match',
  348. :css => '.active [data-name="body"]',
  349. :value => 'some content Braun' + random,
  350. :match_result => true,
  351. },
  352. ],
  353. },
  354. {
  355. :name => 'verify zoom',
  356. :action => [
  357. {
  358. :where => :instance1,
  359. :execute => 'click',
  360. :css => 'a[href="#manage"]',
  361. },
  362. # create ticket
  363. {
  364. :where => :instance2,
  365. :execute => 'create_ticket',
  366. :group => 'Users',
  367. :subject => 'some subject 123äöü',
  368. :body => 'some body 123äöü',
  369. },
  370. # check ticket
  371. {
  372. :where => :instance2,
  373. :execute => 'match',
  374. :css => '.active div.ticket-article',
  375. :value => 'some body 123äöü',
  376. :match_result => true,
  377. },
  378. # check ticket zoom
  379. {
  380. :execute => 'wait',
  381. :value => 4,
  382. },
  383. {
  384. :where => :instance2,
  385. :execute => 'set',
  386. :css => '.active [data-name="body"]',
  387. :value => 'test',
  388. },
  389. {
  390. :execute => 'wait',
  391. :value => 2,
  392. },
  393. {
  394. :where => :instance2,
  395. :execute => 'set',
  396. :css => '.active [data-name="body"]',
  397. :value => '::' + random,
  398. },
  399. {
  400. :execute => 'wait',
  401. :value => 2,
  402. },
  403. {
  404. :where => :instance2,
  405. :execute => 'match',
  406. :css => 'body',
  407. :value => random,
  408. :match_result => true,
  409. },
  410. {
  411. :where => :instance2,
  412. :execute => 'sendkey',
  413. :value => [:arrow_down,:enter]
  414. },
  415. {
  416. :execute => 'wait',
  417. :value => 1,
  418. },
  419. {
  420. :where => :instance2,
  421. :execute => 'match',
  422. :css => '.active [data-name="body"]',
  423. :value => 'some content Braun' + random,
  424. :match_result => true,
  425. },
  426. ],
  427. },
  428. {
  429. :name => 'change customer',
  430. :action => [
  431. {
  432. :where => :instance1,
  433. :execute => 'click',
  434. :css => 'a[href="#manage"]',
  435. },
  436. # create ticket
  437. {
  438. :where => :instance2,
  439. :execute => 'click',
  440. :css => '.content.active .tabsSidebar-tabs [data-tab="customer"]',
  441. },
  442. {
  443. :where => :instance2,
  444. :execute => 'click',
  445. :css => '.content.active .tabsSidebar [data-name="Change Customer"]',
  446. },
  447. {
  448. :execute => 'wait',
  449. :value => 1,
  450. },
  451. {
  452. :where => :instance2,
  453. :execute => 'set',
  454. :css => '.modal [name="customer_id_completion"]',
  455. :value => firstname,
  456. },
  457. {
  458. :execute => 'wait',
  459. :value => 4,
  460. },
  461. {
  462. :where => :instance2,
  463. :execute => 'sendkey',
  464. :value => [:arrow_down,:enter]
  465. },
  466. {
  467. :where => :instance2,
  468. :execute => 'wait',
  469. :value => 1,
  470. },
  471. {
  472. :where => :instance2,
  473. :execute => 'click',
  474. :css => '.modal-content .js-submit',
  475. },
  476. {
  477. :where => :instance2,
  478. :execute => 'wait',
  479. :value => 4,
  480. },
  481. {
  482. :where => :instance2,
  483. :execute => 'set',
  484. :css => '.active [data-name="body"]',
  485. :value => '::' + random,
  486. },
  487. {
  488. :execute => 'wait',
  489. :value => 2,
  490. },
  491. # {
  492. # :where => :instance2,
  493. # :execute => 'match',
  494. # :css => 'body',
  495. # :value => random,
  496. # :match_result => true,
  497. # },
  498. {
  499. :where => :instance2,
  500. :execute => 'sendkey',
  501. :value => [:arrow_down,:enter]
  502. },
  503. {
  504. :execute => 'wait',
  505. :value => 1,
  506. },
  507. {
  508. :where => :instance2,
  509. :execute => 'match',
  510. :css => '.active [data-name="body"]',
  511. :value => 'some content ' + lastname,
  512. :match_result => true,
  513. },
  514. {
  515. :execute => 'wait',
  516. :value => 2,
  517. },
  518. ],
  519. },
  520. ]
  521. browser_double_test(tests)
  522. end
  523. end