ticket_selector.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. window.onload = function() {
  2. var ticketData = {
  3. "number": "72008",
  4. "title": "asdfasdf",
  5. "group_id": 1,
  6. "owner_id": 6,
  7. "updated_by_id": 6,
  8. "created_by_id": 6,
  9. "customer_id": 6,
  10. "state_id": 4,
  11. "priority_id": 2,
  12. "created_at": "2017-02-09T09:16:56.192Z",
  13. "updated_at": "2017-02-09T09:16:56.192Z",
  14. "pending_time": "2017-02-09T09:16:56.192Z",
  15. "aaaaa": "1234568791",
  16. "anrede": "Herr",
  17. "asdf": "",
  18. "organization_id": 6,
  19. "organization": {
  20. "name": "harald test gmbh",
  21. "domain": "www.harald-ist-cool.de",
  22. "shared": true,
  23. "note": "<div>harald test gmbh</div>",
  24. "member_ids": [
  25. 6,
  26. 2
  27. ],
  28. "active": true,
  29. "created_at": "2017-02-09T09:16:56.192Z",
  30. "updated_at": "2017-02-09T09:16:56.192Z",
  31. "domain_assignment": false,
  32. "updated_by_id": 6,
  33. "created_by_id": 6,
  34. "id": 6
  35. },
  36. "group": {
  37. "name": "Users",
  38. "assignment_timeout": null,
  39. "follow_up_possible": "reject",
  40. "follow_up_assignment": true,
  41. "email_address_id": 1,
  42. "signature_id": 1,
  43. "note": "Standard Group/Pool for Tickets.",
  44. "active": true,
  45. "updated_at": "2017-01-18T13:45:30.528Z",
  46. "id": 1
  47. },
  48. "owner": {
  49. "login": "-",
  50. "firstname": "-",
  51. "lastname": "",
  52. "email": "",
  53. "web": "",
  54. "password": "",
  55. "phone": "",
  56. "fax": "",
  57. "mobile": "",
  58. "street": "",
  59. "zip": "",
  60. "city": "",
  61. "country": "",
  62. "organization_id": null,
  63. "department": "",
  64. "note": "",
  65. "role_ids": [],
  66. "group_ids": [],
  67. "active": false,
  68. "updated_at": "2016-08-02T14:25:24.053Z",
  69. "address": "",
  70. "vip": false,
  71. "anrede": null,
  72. "asdf": null,
  73. "id": 1
  74. },
  75. "state": {
  76. "name": "closed",
  77. "note": null,
  78. "active": true,
  79. "id": 4
  80. },
  81. "priority": {
  82. "name": "2 normal",
  83. "note": null,
  84. "active": true,
  85. "updated_at": "2016-08-02T14:25:24.677Z",
  86. "id": 2
  87. },
  88. "article": {
  89. "from": "Test Master Agent",
  90. "to": "agent1@example.com",
  91. "cc": "agent1+cc@example.com",
  92. "body": "asdfasdfasdf<br><br><div data-signature=\"true\" data-signature-id=\"1\"> Test Master Agent<br><br>--<br> Super Support - Waterford Business Park<br> 5201 Blue Lagoon Drive - 8th Floor &amp; 9th Floor - Miami, 33126 USA<br> Email: hot@example.com - Web: http://www.example.com/<br>--</div>",
  93. "content_type": "text/html",
  94. "ticket_id": "2",
  95. "type_id": 1,
  96. "sender_id": 1,
  97. "internal": false,
  98. "in_reply_to": "<20170217100622.2.152971@zammad.example.com>",
  99. "form_id": "326044216"
  100. },
  101. "customer": {
  102. "login": "hc@zammad.com",
  103. "firstname": "Harald",
  104. "lastname": "Customer",
  105. "email": "hc@zammad.com",
  106. "web": "zammad.com",
  107. "password": "",
  108. "phone": "1234567894",
  109. "fax": "",
  110. "mobile": "",
  111. "street": "",
  112. "zip": "",
  113. "city": "",
  114. "country": "",
  115. "organization_id": 6,
  116. "created_by_id": 6,
  117. "updated_by_id": 6,
  118. "department": "",
  119. "note": "",
  120. "role_ids": [
  121. 3
  122. ],
  123. "group_ids": [],
  124. "active": true,
  125. "created_at": "2017-02-09T09:16:56.192Z",
  126. "updated_at": "2017-02-09T09:16:56.192Z",
  127. "address": "Walter-Gropius-Straße 17, 80807 München, Germany",
  128. "web": "www.harald-ist-cool.de",
  129. "vip": false,
  130. "id": 434
  131. },
  132. "escalation_at": "2017-02-09T09:16:56.192Z",
  133. "last_contact_agent_at": "2017-02-09T09:16:56.192Z",
  134. "last_contact_agent_at": "2017-02-09T09:16:56.192Z",
  135. "last_contact_at": "2017-02-09T09:16:56.192Z",
  136. "last_contact_customer_at": "2017-02-09T09:16:56.192Z",
  137. "first_response_at": "2017-02-09T09:16:56.192Z",
  138. "close_at": "2017-02-09T09:16:56.192Z",
  139. "id": 8
  140. };
  141. var sessionData = {
  142. "login": "hh@zammad.com",
  143. "firstname": "Harald",
  144. "lastname": "Habebe",
  145. "email": "hh@zammad.com",
  146. "web": "",
  147. "password": "",
  148. "phone": "",
  149. "fax": "",
  150. "mobile": "",
  151. "street": "",
  152. "zip": "",
  153. "city": "",
  154. "country": "",
  155. "organization_id": 6,
  156. "department": "",
  157. "note": "",
  158. "role_ids": [
  159. 1,
  160. 2,
  161. 5,
  162. 6,
  163. 4
  164. ],
  165. "group_ids": [
  166. 1
  167. ],
  168. "active": true,
  169. "updated_at": "2017-02-09T09:17:04.770Z",
  170. "address": "",
  171. "vip": false,
  172. "anrede": "",
  173. "asdf": "",
  174. "id": 6
  175. };
  176. /*
  177. * ------------------------------------------------------------------------
  178. * Test functions
  179. * ------------------------------------------------------------------------
  180. */
  181. var testContains = function (key, value, ticket) {
  182. setting = {
  183. "condition": {
  184. [key]: {
  185. "operator": "contains",
  186. "value": value
  187. },
  188. }
  189. };
  190. result = App.Ticket.selector(ticket, setting['condition'] );
  191. equal(result, true, result);
  192. setting = {
  193. "condition": {
  194. [key]: {
  195. "operator": "contains not",
  196. "value": value
  197. },
  198. }
  199. };
  200. result = App.Ticket.selector(ticket, setting['condition'] );
  201. equal(result, false, result);
  202. };
  203. var testIs = function (key, value, ticket) {
  204. setting = {
  205. "condition": {
  206. [key]: {
  207. "operator": "is",
  208. "value": value
  209. },
  210. }
  211. };
  212. result = App.Ticket.selector(ticket, setting['condition'] );
  213. equal(result, true, result);
  214. setting = {
  215. "condition": {
  216. [key]: {
  217. "operator": "is not",
  218. "value": value
  219. },
  220. }
  221. };
  222. result = App.Ticket.selector(ticket, setting['condition'] );
  223. equal(result, false, result);
  224. };
  225. var testPreConditionUser = function (key, specificValue, ticket, session) {
  226. App.Session.set(sessionData);
  227. setting = {
  228. "condition": {
  229. [key]: {
  230. "operator": "is",
  231. "pre_condition": "current_user.id",
  232. "value": "",
  233. "value_completion": ""
  234. },
  235. }
  236. };
  237. result = App.Ticket.selector(ticket, setting['condition'] );
  238. equal(result, true, result);
  239. setting = {
  240. "condition": {
  241. [key]: {
  242. "operator": "is not",
  243. "pre_condition": "current_user.id",
  244. "value": "",
  245. "value_completion": ""
  246. },
  247. }
  248. };
  249. result = App.Ticket.selector(ticket, setting['condition'] );
  250. equal(result, false, result);
  251. setting = {
  252. "condition": {
  253. [key]: {
  254. "operator": "is",
  255. "pre_condition": "specific",
  256. "value": specificValue,
  257. "value_completion": "Nicole Braun <nicole.braun@zammad.org>"
  258. }
  259. }
  260. };
  261. result = App.Ticket.selector(ticket, setting['condition'] );
  262. equal(result, true, result);
  263. setting = {
  264. "condition": {
  265. [key]: {
  266. "operator": "is not",
  267. "pre_condition": "specific",
  268. "value": specificValue,
  269. "value_completion": "Nicole Braun <nicole.braun@zammad.org>"
  270. }
  271. }
  272. };
  273. result = App.Ticket.selector(ticket, setting['condition'] );
  274. equal(result, false, result);
  275. setting = {
  276. "condition": {
  277. [key]: {
  278. "operator": "is not",
  279. "pre_condition": "specific",
  280. "value": specificValue,
  281. "value_completion": "Nicole Braun <nicole.braun@zammad.org>"
  282. }
  283. }
  284. };
  285. result = App.Ticket.selector(ticket, setting['condition'] );
  286. equal(result, false, result);
  287. setting = {
  288. "condition": {
  289. [key]: {
  290. "operator": "is",
  291. "pre_condition": "not_set",
  292. }
  293. }
  294. };
  295. result = App.Ticket.selector(ticket, setting['condition'] );
  296. equal(result, false, result);
  297. setting = {
  298. "condition": {
  299. [key]: {
  300. "operator": "is not",
  301. "pre_condition": "not_set",
  302. }
  303. }
  304. };
  305. result = App.Ticket.selector(ticket, setting['condition'] );
  306. equal(result, true, result);
  307. };
  308. var testPreConditionOrganization = function (key, specificValue, ticket, session) {
  309. App.Session.set(sessionData);
  310. setting = {
  311. "condition": {
  312. [key]: {
  313. "operator": "is",
  314. "pre_condition": "current_user.organization_id",
  315. "value": "",
  316. "value_completion": ""
  317. },
  318. }
  319. };
  320. result = App.Ticket.selector(ticket, setting['condition'] );
  321. equal(result, true, result);
  322. setting = {
  323. "condition": {
  324. [key]: {
  325. "operator": "is not",
  326. "pre_condition": "current_user.organization_id",
  327. "value": "",
  328. "value_completion": ""
  329. },
  330. }
  331. };
  332. result = App.Ticket.selector(ticket, setting['condition'] );
  333. equal(result, false, result);
  334. setting = {
  335. "condition": {
  336. [key]: {
  337. "operator": "is",
  338. "pre_condition": "specific",
  339. "value": specificValue,
  340. "value_completion": "Nicole Braun <nicole.braun@zammad.org>"
  341. }
  342. }
  343. };
  344. result = App.Ticket.selector(ticket, setting['condition'] );
  345. equal(result, true, result);
  346. setting = {
  347. "condition": {
  348. [key]: {
  349. "operator": "is not",
  350. "pre_condition": "specific",
  351. "value": specificValue,
  352. "value_completion": "Nicole Braun <nicole.braun@zammad.org>"
  353. }
  354. }
  355. };
  356. result = App.Ticket.selector(ticket, setting['condition'] );
  357. equal(result, false, result);
  358. setting = {
  359. "condition": {
  360. [key]: {
  361. "operator": "is not",
  362. "pre_condition": "specific",
  363. "value": specificValue,
  364. "value_completion": "Nicole Braun <nicole.braun@zammad.org>"
  365. }
  366. }
  367. };
  368. result = App.Ticket.selector(ticket, setting['condition'] );
  369. equal(result, false, result);
  370. setting = {
  371. "condition": {
  372. [key]: {
  373. "operator": "is",
  374. "pre_condition": "not_set",
  375. }
  376. }
  377. };
  378. result = App.Ticket.selector(ticket, setting['condition'] );
  379. equal(result, false, result);
  380. setting = {
  381. "condition": {
  382. [key]: {
  383. "operator": "is not",
  384. "pre_condition": "not_set",
  385. }
  386. }
  387. };
  388. result = App.Ticket.selector(ticket, setting['condition'] );
  389. equal(result, true, result);
  390. };
  391. var testTime = function (key, value, ticket) {
  392. valueDate = new Date(value);
  393. compareDate = new Date( valueDate.setHours( valueDate.getHours() - 1 ) ).toISOString();
  394. setting = {
  395. "condition": {
  396. [key]: {
  397. "operator": "after (absolute)",
  398. "value": compareDate
  399. },
  400. }
  401. };
  402. result = App.Ticket.selector(ticket, setting['condition'] );
  403. equal(result, true, result);
  404. valueDate = new Date(value);
  405. compareDate = new Date( valueDate.setHours( valueDate.getHours() + 1 ) ).toISOString();
  406. setting = {
  407. "condition": {
  408. [key]: {
  409. "operator": "after (absolute)",
  410. "value": compareDate
  411. },
  412. }
  413. };
  414. result = App.Ticket.selector(ticket, setting['condition'] );
  415. equal(result, false, result);
  416. valueDate = new Date(value);
  417. compareDate = new Date( valueDate.setHours( valueDate.getHours() - 1 ) ).toISOString();
  418. setting = {
  419. "condition": {
  420. [key]: {
  421. "operator": "before (absolute)",
  422. "value": compareDate
  423. },
  424. }
  425. };
  426. result = App.Ticket.selector(ticket, setting['condition'] );
  427. equal(result, false, result);
  428. valueDate = new Date(value);
  429. compareDate = new Date( valueDate.setHours( valueDate.getHours() + 1 ) ).toISOString();
  430. setting = {
  431. "condition": {
  432. [key]: {
  433. "operator": "before (absolute)",
  434. "value": compareDate
  435. },
  436. }
  437. };
  438. result = App.Ticket.selector(ticket, setting['condition'] );
  439. equal(result, true, result);
  440. valueDate = new Date(value);
  441. compareDate = new Date( valueDate.setHours( valueDate.getHours() + 2 ) ).toISOString();
  442. setting = {
  443. "condition": {
  444. [key]: {
  445. "operator": "before (relative)",
  446. "value": 1,
  447. "range": "hour"
  448. },
  449. }
  450. };
  451. result = App.Ticket.selector(ticket, setting['condition'] );
  452. equal(result, true, result);
  453. };
  454. var testTimeBeforeRelative = function (key, value, range, expectedResult, ticket) {
  455. setting = {
  456. "condition": {
  457. [key]: {
  458. "operator": "before (relative)",
  459. "value": value,
  460. "range": range
  461. },
  462. }
  463. };
  464. result = App.Ticket.selector(ticket, setting['condition'] );
  465. equal(result, expectedResult, result);
  466. };
  467. var testTimeAfterRelative = function (key, value, range, expectedResult, ticket) {
  468. setting = {
  469. "condition": {
  470. [key]: {
  471. "operator": "after (relative)",
  472. "value": value,
  473. "range": range
  474. },
  475. }
  476. };
  477. result = App.Ticket.selector(ticket, setting['condition'] );
  478. equal(result, expectedResult, result);
  479. };
  480. var testTimeWithinNextRelative = function (key, value, range, expectedResult, ticket) {
  481. setting = {
  482. "condition": {
  483. [key]: {
  484. "operator": "within next (relative)",
  485. "value": value,
  486. "range": range
  487. },
  488. }
  489. };
  490. result = App.Ticket.selector(ticket, setting['condition'] );
  491. equal(result, expectedResult, result);
  492. };
  493. var testTimeWithinLastRelative = function (key, value, range, expectedResult, ticket) {
  494. setting = {
  495. "condition": {
  496. [key]: {
  497. "operator": "within last (relative)",
  498. "value": value,
  499. "range": range
  500. },
  501. }
  502. };
  503. result = App.Ticket.selector(ticket, setting['condition'] );
  504. equal(result, expectedResult, result);
  505. };
  506. /*
  507. * ------------------------------------------------------------------------
  508. * Field tests
  509. * ------------------------------------------------------------------------
  510. */
  511. test("ticket number", function() {
  512. ticket = new App.Ticket();
  513. ticket.load(ticketData);
  514. testContains('ticket.number', '72', ticket);
  515. });
  516. test("ticket title", function() {
  517. ticket = new App.Ticket();
  518. ticket.load(ticketData);
  519. testContains('ticket.title', 'asd', ticket);
  520. });
  521. test("ticket customer_id", function() {
  522. ticket = new App.Ticket();
  523. ticket.load(ticketData);
  524. App.Session.set(sessionData);
  525. testPreConditionUser('ticket.customer_id', '6', ticket, sessionData);
  526. });
  527. test("ticket organization_id", function() {
  528. ticket = new App.Ticket();
  529. ticket.load(ticketData);
  530. testPreConditionUser('ticket.organization_id', '6', ticket, sessionData);
  531. });
  532. test("ticket group_id", function() {
  533. ticket = new App.Ticket();
  534. ticket.load(ticketData);
  535. testIs('ticket.group_id', ['1'], ticket, sessionData);
  536. });
  537. test("ticket owner_id", function() {
  538. ticket = new App.Ticket();
  539. ticket.load(ticketData);
  540. App.Session.set(sessionData);
  541. testPreConditionUser('ticket.owner_id', '6', ticket, sessionData);
  542. });
  543. test("ticket state_id", function() {
  544. ticket = new App.Ticket();
  545. ticket.load(ticketData);
  546. testIs('ticket.state_id', ['4'], ticket, sessionData);
  547. });
  548. test("ticket pending_time", function() {
  549. ticket = new App.Ticket();
  550. ticket.load(ticketData);
  551. testTime('ticket.pending_time', ticket.pending_time, ticket);
  552. // -------------------------
  553. // BEFORE TIME
  554. // -------------------------
  555. // hour
  556. ticket.pending_time = new Date().toISOString();
  557. testTimeBeforeRelative('ticket.pending_time', 1, 'hour', false, ticket);
  558. compareDate = new Date();
  559. compareDate.setTime( compareDate.getTime() - 60 * 60 * 2 * 1000 );
  560. ticket.pending_time = compareDate.toISOString();
  561. testTimeBeforeRelative('ticket.pending_time', 1, 'hour', true, ticket);
  562. // day
  563. ticket.pending_time = new Date().toISOString();
  564. testTimeBeforeRelative('ticket.pending_time', 1, 'day', false, ticket);
  565. compareDate = new Date();
  566. compareDate.setTime( compareDate.getTime() - 60 * 60 * 48 * 1000 );
  567. ticket.pending_time = compareDate.toISOString();
  568. testTimeBeforeRelative('ticket.pending_time', 1, 'day', true, ticket);
  569. // year
  570. ticket.pending_time = new Date().toISOString();
  571. testTimeBeforeRelative('ticket.pending_time', 1, 'year', false, ticket);
  572. compareDate = new Date();
  573. compareDate.setTime( compareDate.getTime() - 60 * 60 * 365 * 2 * 1000 );
  574. ticket.pending_time = compareDate.toISOString();
  575. testTimeBeforeRelative('ticket.pending_time', 1, 'year', true, ticket);
  576. // -------------------------
  577. // AFTER TIME
  578. // -------------------------
  579. // hour
  580. ticket.pending_time = new Date().toISOString();
  581. testTimeAfterRelative('ticket.pending_time', 1, 'hour', false, ticket);
  582. compareDate = new Date();
  583. compareDate.setTime( compareDate.getTime() + 60 * 60 * 2 * 1000 );
  584. ticket.pending_time = compareDate.toISOString();
  585. testTimeAfterRelative('ticket.pending_time', 1, 'hour', true, ticket);
  586. // day
  587. ticket.pending_time = new Date().toISOString();
  588. testTimeAfterRelative('ticket.pending_time', 1, 'day', false, ticket);
  589. compareDate = new Date();
  590. compareDate.setTime( compareDate.getTime() + 60 * 60 * 48 * 1000 );
  591. ticket.pending_time = compareDate.toISOString();
  592. testTimeAfterRelative('ticket.pending_time', 1, 'day', true, ticket);
  593. // year
  594. ticket.pending_time = new Date().toISOString();
  595. testTimeAfterRelative('ticket.pending_time', 1, 'year', false, ticket);
  596. compareDate = new Date();
  597. compareDate.setTime( compareDate.getTime() + 60 * 60 * 365 * 2 * 1000 );
  598. ticket.pending_time = compareDate.toISOString();
  599. testTimeAfterRelative('ticket.pending_time', 1, 'year', true, ticket);
  600. // -------------------------
  601. // WITHIN LAST TIME
  602. // -------------------------
  603. // hour
  604. compareDate = new Date();
  605. compareDate.setTime( compareDate.getTime() - 60 * 60 * 0.5 * 1000 );
  606. ticket.pending_time = compareDate.toISOString();
  607. testTimeWithinLastRelative('ticket.pending_time', 1, 'hour', true, ticket);
  608. compareDate = new Date();
  609. compareDate.setTime( compareDate.getTime() - 60 * 60 * 2 * 1000 );
  610. ticket.pending_time = compareDate.toISOString();
  611. testTimeWithinLastRelative('ticket.pending_time', 1, 'hour', false, ticket);
  612. // -------------------------
  613. // WITHIN NEXT TIME
  614. // -------------------------
  615. // hour
  616. compareDate = new Date();
  617. compareDate.setTime( compareDate.getTime() + 60 * 60 * 0.5 * 1000 );
  618. ticket.pending_time = compareDate.toISOString();
  619. testTimeWithinNextRelative('ticket.pending_time', 1, 'hour', true, ticket);
  620. compareDate = new Date();
  621. compareDate.setTime( compareDate.getTime() + 60 * 60 * 2 * 1000 );
  622. ticket.pending_time = compareDate.toISOString();
  623. testTimeWithinNextRelative('ticket.pending_time', 1, 'hour', false, ticket);
  624. });
  625. test("ticket priority_id", function() {
  626. ticket = new App.Ticket();
  627. ticket.load(ticketData);
  628. testIs('ticket.priority_id', ['2'], ticket, sessionData);
  629. });
  630. test("ticket escalation_at", function() {
  631. ticket = new App.Ticket();
  632. ticket.load(ticketData);
  633. testTime('ticket.escalation_at', ticket.escalation_at, ticket);
  634. });
  635. test("ticket last_contact_agent_at", function() {
  636. ticket = new App.Ticket();
  637. ticket.load(ticketData);
  638. testTime('ticket.last_contact_agent_at', ticket.last_contact_agent_at, ticket);
  639. });
  640. test("ticket last_contact_at", function() {
  641. ticket = new App.Ticket();
  642. ticket.load(ticketData);
  643. testTime('ticket.last_contact_at', ticket.last_contact_at, ticket);
  644. });
  645. test("ticket last_contact_customer_at", function() {
  646. ticket = new App.Ticket();
  647. ticket.load(ticketData);
  648. testTime('ticket.last_contact_customer_at', ticket.last_contact_customer_at, ticket);
  649. });
  650. test("ticket first_response_at", function() {
  651. ticket = new App.Ticket();
  652. ticket.load(ticketData);
  653. testTime('ticket.first_response_at', ticket.first_response_at, ticket);
  654. });
  655. test("ticket close_at", function() {
  656. ticket = new App.Ticket();
  657. ticket.load(ticketData);
  658. testTime('ticket.close_at', ticket.close_at, ticket);
  659. });
  660. test("ticket created_by_id", function() {
  661. ticket = new App.Ticket();
  662. ticket.load(ticketData);
  663. App.Session.set(sessionData);
  664. testPreConditionUser('ticket.created_by_id', '6', ticket, sessionData);
  665. });
  666. test("ticket created_at", function() {
  667. ticket = new App.Ticket();
  668. ticket.load(ticketData);
  669. testTime('ticket.created_at', ticket.created_at, ticket);
  670. });
  671. test("ticket updated_at", function() {
  672. ticket = new App.Ticket();
  673. ticket.load(ticketData);
  674. testTime('ticket.updated_at', ticket.updated_at, ticket);
  675. });
  676. test("ticket updated_by_id", function() {
  677. ticket = new App.Ticket();
  678. ticket.load(ticketData);
  679. App.Session.set(sessionData);
  680. testPreConditionUser('ticket.updated_by_id', '6', ticket, sessionData);
  681. });
  682. test("article from", function() {
  683. ticket = new App.Ticket();
  684. ticket.load(ticketData);
  685. testContains('article.from', 'Master', ticket);
  686. });
  687. test("article to", function() {
  688. ticket = new App.Ticket();
  689. ticket.load(ticketData);
  690. testContains('article.to', 'agent1', ticket);
  691. });
  692. test("article cc", function() {
  693. ticket = new App.Ticket();
  694. ticket.load(ticketData);
  695. testContains('article.cc', 'agent1+cc', ticket);
  696. });
  697. test("article subject", function() {
  698. ticket = new App.Ticket();
  699. ticket.load(ticketData);
  700. testContains('article.subject', 'asdf', ticket);
  701. });
  702. test("article type_id", function() {
  703. ticket = new App.Ticket();
  704. ticket.load(ticketData);
  705. testIs('article.type_id', ['1'], ticket);
  706. });
  707. test("article sender_id", function() {
  708. ticket = new App.Ticket();
  709. ticket.load(ticketData);
  710. testIs('article.sender_id', ['1'], ticket);
  711. });
  712. test("article internal", function() {
  713. ticket = new App.Ticket();
  714. ticket.load(ticketData);
  715. testIs('article.internal', ['false'], ticket);
  716. });
  717. test("article created_by_id", function() {
  718. ticket = new App.Ticket();
  719. ticket.load(ticketData);
  720. testPreConditionUser('article.created_by_id', '6', ticket, sessionData);
  721. });
  722. test("customer login", function() {
  723. ticket = new App.Ticket();
  724. ticket.load(ticketData);
  725. testContains('customer.login', 'hc', ticket);
  726. });
  727. test("customer firstname", function() {
  728. ticket = new App.Ticket();
  729. ticket.load(ticketData);
  730. testContains('customer.firstname', 'Harald', ticket);
  731. });
  732. test("customer lastname", function() {
  733. ticket = new App.Ticket();
  734. ticket.load(ticketData);
  735. testContains('customer.lastname', 'Customer', ticket);
  736. });
  737. test("customer email", function() {
  738. ticket = new App.Ticket();
  739. ticket.load(ticketData);
  740. testContains('customer.email', 'hc', ticket);
  741. });
  742. test("customer organization_id", function() {
  743. ticket = new App.Ticket();
  744. ticket.load(ticketData);
  745. testPreConditionOrganization('customer.organization_id', '6', ticket, sessionData);
  746. });
  747. test("customer created_by_id", function() {
  748. ticket = new App.Ticket();
  749. ticket.load(ticketData);
  750. testPreConditionUser('customer.created_by_id', '6', ticket, sessionData);
  751. });
  752. test("customer created_at", function() {
  753. ticket = new App.Ticket();
  754. ticket.load(ticketData);
  755. testTime('customer.created_at', ticket.customer.created_at, ticket);
  756. });
  757. test("customer updated_by_id", function() {
  758. ticket = new App.Ticket();
  759. ticket.load(ticketData);
  760. testPreConditionUser('customer.updated_by_id', '6', ticket, sessionData);
  761. });
  762. test("customer missing_field", function() {
  763. ticket = new App.Ticket();
  764. ticket.load(ticketData);
  765. testContains('customer.missing_field', '', ticket);
  766. });
  767. test("customer web", function() {
  768. ticket = new App.Ticket();
  769. ticket.load(ticketData);
  770. testContains('customer.web', 'cool', ticket);
  771. });
  772. test("organization name", function() {
  773. ticket = new App.Ticket();
  774. ticket.load(ticketData);
  775. testContains('organization.name', 'gmbh', ticket);
  776. });
  777. test("organization shared", function() {
  778. ticket = new App.Ticket();
  779. ticket.load(ticketData);
  780. testIs('organization.shared', true, ticket);
  781. });
  782. test("organization created_by_id", function() {
  783. ticket = new App.Ticket();
  784. ticket.load(ticketData);
  785. testPreConditionUser('organization.created_by_id', 6, ticket);
  786. });
  787. test("organization updated_by_id", function() {
  788. ticket = new App.Ticket();
  789. ticket.load(ticketData);
  790. testPreConditionUser('organization.updated_by_id', 6, ticket);
  791. });
  792. test("organization created_at", function() {
  793. ticket = new App.Ticket();
  794. ticket.load(ticketData);
  795. testTime('organization.created_at', ticket.organization.created_at, ticket);
  796. });
  797. test("organization updated_at", function() {
  798. ticket = new App.Ticket();
  799. ticket.load(ticketData);
  800. testTime('organization.updated_at', ticket.organization.updated_at, ticket);
  801. });
  802. test("organization domain_assignment", function() {
  803. ticket = new App.Ticket();
  804. ticket.load(ticketData);
  805. testIs('organization.domain_assignment', false, ticket);
  806. });
  807. test("organization domain", function() {
  808. ticket = new App.Ticket();
  809. ticket.load(ticketData);
  810. testContains('organization.domain', 'cool', ticket);
  811. });
  812. }