admin_object_manager_test.rb 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. require 'browser_test_helper'
  3. class AdminObjectManagerTest < TestCase
  4. def test_basic_a
  5. @browser = browser_instance
  6. login(
  7. username: 'admin@example.com',
  8. password: 'test',
  9. url: browser_url,
  10. )
  11. tasks_close_all
  12. # already existing
  13. object_manager_attribute_create(
  14. data: {
  15. name: 'customer_id',
  16. display: 'Customer Should Not Creatable',
  17. data_type: 'Text',
  18. },
  19. error: 'already exists'
  20. )
  21. # invalid name
  22. object_manager_attribute_create(
  23. data: {
  24. name: 'some_other_id',
  25. display: 'Should Not Creatable',
  26. data_type: 'Text',
  27. },
  28. error: 'are not allowed'
  29. )
  30. # invalid name
  31. object_manager_attribute_create(
  32. data: {
  33. name: 'some_other_ids',
  34. display: 'Should Not Creatable',
  35. data_type: 'Text',
  36. },
  37. error: 'are not allowed'
  38. )
  39. # invalid name
  40. object_manager_attribute_create(
  41. data: {
  42. name: 'some spaces',
  43. display: 'Should Not Creatable',
  44. data_type: 'Text',
  45. },
  46. error: 'are not allowed'
  47. )
  48. # valid name
  49. object_manager_attribute_create(
  50. data: {
  51. name: 'browser_test1',
  52. display: 'Browser Test 1',
  53. data_type: 'Text',
  54. },
  55. )
  56. watch_for(
  57. css: '.content.active',
  58. value: 'Database Update required',
  59. )
  60. click(css: '.content.active .tab-pane.active div.js-execute')
  61. watch_for(
  62. css: '.modal',
  63. value: 'restart',
  64. )
  65. watch_for_disappear(
  66. css: '.modal',
  67. timeout: 7.minutes,
  68. )
  69. sleep 5
  70. watch_for(
  71. css: '.content.active',
  72. )
  73. # create new ticket
  74. ticket_create(
  75. data: {
  76. customer: 'nico',
  77. group: 'Users',
  78. priority: '2 normal',
  79. state: 'open',
  80. title: 'ticket attribute test #1',
  81. body: 'ticket attribute test #1',
  82. },
  83. # custom_data_select: {
  84. # key1: 'some value',
  85. # },
  86. custom_data_input: {
  87. browser_test1: 'some value öäüß',
  88. },
  89. disable_group_check: true,
  90. )
  91. # update ticket
  92. ticket_update(
  93. data: {},
  94. # custom_data_select: {
  95. # key1: 'some value',
  96. # },
  97. custom_data_input: {
  98. browser_test1: 'some value ABC',
  99. },
  100. )
  101. # discard new attribute
  102. click(css: 'a[href="#manage"]')
  103. click(css: 'a[href="#system/object_manager"]')
  104. watch_for(
  105. css: '.content.active table',
  106. value: 'browser_test1',
  107. )
  108. match_not(
  109. css: '.content.active',
  110. value: 'Database Update required',
  111. )
  112. object_manager_attribute_delete(
  113. data: {
  114. name: 'browser_test1',
  115. },
  116. )
  117. watch_for(
  118. css: '.content.active',
  119. value: 'Database Update required',
  120. )
  121. watch_for(
  122. css: '.content.active table',
  123. value: 'browser_test1',
  124. )
  125. click(css: '.content.active .tab-pane.active div.js-execute')
  126. watch_for(
  127. css: '.modal',
  128. value: 'restart',
  129. )
  130. watch_for_disappear(
  131. css: '.modal',
  132. timeout: 7.minutes,
  133. )
  134. sleep 5
  135. watch_for(
  136. css: '.content.active',
  137. )
  138. match_not(
  139. css: '.content.active',
  140. value: 'Database Update required',
  141. )
  142. match_not(
  143. css: '.content.active table',
  144. value: 'browser_test1',
  145. )
  146. end
  147. def test_basic_b
  148. @browser = browser_instance
  149. login(
  150. username: 'admin@example.com',
  151. password: 'test',
  152. url: browser_url,
  153. )
  154. tasks_close_all
  155. object_manager_attribute_create(
  156. data: {
  157. name: 'browser_test2',
  158. display: 'Browser Test 2',
  159. data_type: 'Select',
  160. data_option: {
  161. options: {
  162. 'aa' => 'AA',
  163. 'bb' => 'BB',
  164. },
  165. },
  166. },
  167. )
  168. object_manager_attribute_discard_changes
  169. sleep 4
  170. object_manager_attribute_create(
  171. data: {
  172. name: 'browser_test2',
  173. display: 'Browser Test 2',
  174. data_type: 'Text',
  175. # data_option: {
  176. # default: 'xxx',
  177. # },
  178. },
  179. )
  180. object_manager_attribute_create(
  181. data: {
  182. name: 'browser_test3',
  183. display: 'Browser Test 3',
  184. data_type: 'Select',
  185. data_option: {
  186. options: {
  187. 'aa' => 'AA',
  188. 'bb' => 'BB',
  189. 'cc' => 'CC',
  190. },
  191. },
  192. },
  193. )
  194. object_manager_attribute_create(
  195. data: {
  196. name: 'browser_test4',
  197. display: 'Browser Test 4',
  198. data_type: 'Integer',
  199. # data_option: {
  200. # default: 'xxx',
  201. # min: 15,
  202. # max: 99,
  203. # },
  204. },
  205. )
  206. object_manager_attribute_create(
  207. data: {
  208. name: 'browser_test5',
  209. display: 'Browser Test 5',
  210. data_type: 'Datetime',
  211. # data_option: {
  212. # future: true,
  213. # past: true,
  214. # diff: 24
  215. # },
  216. },
  217. )
  218. object_manager_attribute_create(
  219. data: {
  220. name: 'browser_test6',
  221. display: 'Browser Test 6',
  222. data_type: 'Date',
  223. # data_option: {
  224. # future: true,
  225. # past: true,
  226. # diff: 24
  227. # },
  228. },
  229. )
  230. # rubocop:disable Lint/BooleanSymbol
  231. object_manager_attribute_create(
  232. data: {
  233. name: 'browser_test7',
  234. display: 'Browser Test 7',
  235. data_type: 'Boolean',
  236. data_option: {
  237. options: {
  238. true: 'YES',
  239. false: 'NO',
  240. },
  241. # default: true,
  242. },
  243. },
  244. )
  245. # rubocop:enable Lint/BooleanSymbol
  246. watch_for(
  247. css: '.content.active',
  248. value: 'Database Update required',
  249. )
  250. click(css: '.content.active .tab-pane.active div.js-execute')
  251. watch_for(
  252. css: '.modal',
  253. value: 'restart',
  254. )
  255. watch_for_disappear(
  256. css: '.modal',
  257. timeout: 7.minutes,
  258. )
  259. sleep 5
  260. watch_for(
  261. css: '.content.active',
  262. )
  263. # create new ticket
  264. ticket_create(
  265. data: {
  266. customer: 'nico',
  267. group: 'Users',
  268. priority: '2 normal',
  269. state: 'open',
  270. title: 'ticket attribute test all #1',
  271. body: 'ticket attribute test all #1',
  272. },
  273. custom_data_select: {
  274. browser_test3: 'CC',
  275. browser_test7: 'NO',
  276. },
  277. custom_data_input: {
  278. browser_test2: 'some value öäüß',
  279. browser_test4: '25',
  280. },
  281. disable_group_check: true,
  282. )
  283. ticket_verify(
  284. data: {
  285. title: 'ticket attribute test all #1',
  286. custom_data_select: {
  287. browser_test3: 'CC',
  288. browser_test7: 'NO',
  289. },
  290. custom_data_input: {
  291. browser_test2: 'some value öäüß',
  292. browser_test4: '25',
  293. },
  294. },
  295. )
  296. object_manager_attribute_delete(
  297. data: {
  298. name: 'browser_test2',
  299. },
  300. )
  301. object_manager_attribute_delete(
  302. data: {
  303. name: 'browser_test3',
  304. },
  305. )
  306. object_manager_attribute_delete(
  307. data: {
  308. name: 'browser_test4',
  309. },
  310. )
  311. object_manager_attribute_delete(
  312. data: {
  313. name: 'browser_test5',
  314. },
  315. )
  316. object_manager_attribute_delete(
  317. data: {
  318. name: 'browser_test6',
  319. },
  320. )
  321. object_manager_attribute_delete(
  322. data: {
  323. name: 'browser_test7',
  324. },
  325. )
  326. sleep 1
  327. object_manager_attribute_migrate
  328. match_not(
  329. css: '.content.active',
  330. value: 'Database Update required',
  331. )
  332. match_not(
  333. css: '.content.active table',
  334. value: 'browser_test2',
  335. )
  336. match_not(
  337. css: '.content.active table',
  338. value: 'browser_test3',
  339. )
  340. match_not(
  341. css: '.content.active table',
  342. value: 'browser_test4',
  343. )
  344. match_not(
  345. css: '.content.active table',
  346. value: 'browser_test5',
  347. )
  348. match_not(
  349. css: '.content.active table',
  350. value: 'browser_test6',
  351. )
  352. match_not(
  353. css: '.content.active table',
  354. value: 'browser_test7',
  355. )
  356. end
  357. def test_basic_c
  358. @browser = browser_instance
  359. login(
  360. username: 'admin@example.com',
  361. password: 'test',
  362. url: browser_url,
  363. )
  364. tasks_close_all
  365. # valid name
  366. object_manager_attribute_create(
  367. data: {
  368. name: 'browser_update_test1',
  369. display: 'Browser Update Test 1',
  370. data_type: 'Text',
  371. },
  372. )
  373. watch_for(
  374. css: '.content.active',
  375. value: 'Database Update required',
  376. )
  377. click(css: '.content.active .tab-pane.active div.js-execute')
  378. watch_for(
  379. css: '.modal',
  380. value: 'restart',
  381. )
  382. watch_for_disappear(
  383. css: '.modal',
  384. timeout: 7.minutes,
  385. )
  386. sleep 5
  387. watch_for(
  388. css: '.content.active',
  389. )
  390. match_not(
  391. css: '.content.active',
  392. value: 'Database Update required',
  393. )
  394. # valid name
  395. object_manager_attribute_update(
  396. data: {
  397. name: 'browser_update_test1',
  398. display: 'Browser Update Test 2',
  399. data_type: 'Text',
  400. },
  401. )
  402. watch_for(
  403. css: '.content.active',
  404. value: 'Database Update required',
  405. )
  406. click(css: '.content.active .tab-pane.active div.js-execute')
  407. watch_for(
  408. css: '.modal',
  409. value: 'configuration of Zammad has changed',
  410. )
  411. click(css: '.modal .js-submit')
  412. watch_for_disappear(
  413. css: '.modal',
  414. timeout: 7.minutes,
  415. )
  416. sleep 5
  417. watch_for(
  418. css: '.content.active',
  419. )
  420. match_not(
  421. css: '.content.active',
  422. value: 'Database Update required',
  423. )
  424. object_manager_attribute_delete(
  425. data: {
  426. name: 'browser_update_test1',
  427. },
  428. )
  429. watch_for(
  430. css: '.content.active',
  431. value: 'Database Update required',
  432. )
  433. watch_for(
  434. css: '.content.active table',
  435. value: 'browser_update_test1',
  436. )
  437. click(css: '.content.active .tab-pane.active div.js-execute')
  438. watch_for(
  439. css: '.modal',
  440. value: 'restart',
  441. )
  442. watch_for_disappear(
  443. css: '.modal',
  444. timeout: 7.minutes,
  445. )
  446. sleep 5
  447. watch_for(
  448. css: '.content.active',
  449. )
  450. match_not(
  451. css: '.content.active',
  452. value: 'Database Update required',
  453. )
  454. match_not(
  455. css: '.content.active table',
  456. value: 'browser_update_test1',
  457. )
  458. end
  459. def test_that_attributes_with_references_should_have_a_disabled_delete_button
  460. @browser = instance = browser_instance
  461. login(
  462. username: 'admin@example.com',
  463. password: 'test',
  464. url: browser_url,
  465. )
  466. tasks_close_all
  467. # create two new attributes
  468. object_manager_attribute_create(
  469. data: {
  470. name: 'deletable_attribute',
  471. display: 'Deletable Attribute',
  472. data_type: 'Text',
  473. },
  474. )
  475. object_manager_attribute_create(
  476. data: {
  477. name: 'undeletable_attribute',
  478. display: 'Undeletable Attribute',
  479. data_type: 'Text',
  480. },
  481. )
  482. watch_for(
  483. css: '.content.active',
  484. value: 'Database Update required',
  485. )
  486. click(css: '.content.active .tab-pane.active div.js-execute')
  487. watch_for(
  488. css: '.modal',
  489. value: 'restart',
  490. )
  491. watch_for_disappear(
  492. css: '.modal',
  493. timeout: 7.minutes,
  494. )
  495. sleep 5
  496. watch_for(
  497. css: '.content.active',
  498. )
  499. match_not(
  500. css: '.content.active',
  501. value: 'Database Update required',
  502. )
  503. # create a new overview that references the undeletable_attribute
  504. overview_create(
  505. browser: instance,
  506. data: {
  507. name: 'test_overview',
  508. roles: ['Agent'],
  509. selector: {
  510. 'Undeletable Attribute' => 'DUMMY',
  511. },
  512. 'order::direction' => 'down',
  513. 'text_input' => true,
  514. }
  515. )
  516. click(
  517. browser: instance,
  518. css: 'a[href="#manage"]',
  519. mute_log: true,
  520. )
  521. click(
  522. browser: instance,
  523. css: '.content.active a[href="#system/object_manager"]',
  524. mute_log: true,
  525. )
  526. 30.times do
  527. deletable_attribute = instance.find_elements(xpath: '//td[text()="deletable_attribute"]/following-sibling::*[2]')[0]
  528. break if deletable_attribute
  529. sleep 1
  530. end
  531. sleep 1
  532. deletable_attribute = instance.find_elements(xpath: '//td[text()="deletable_attribute"]/following-sibling::*[2]')[0]
  533. assert_not_nil(deletable_attribute)
  534. deletable_attribute_html = deletable_attribute.attribute('innerHTML')
  535. assert(deletable_attribute_html.include?('title="Delete"'))
  536. assert(deletable_attribute_html.include?('href="#"'))
  537. assert(deletable_attribute_html.exclude?('cannot be deleted'))
  538. undeletable_attribute = instance.find_elements(xpath: '//td[text()="undeletable_attribute"]/following-sibling::*[2]')[0]
  539. assert_not_nil(undeletable_attribute)
  540. undeletable_attribute_html = undeletable_attribute.attribute('innerHTML')
  541. assert(undeletable_attribute_html.include?('Overview'))
  542. assert(undeletable_attribute_html.include?('test_overview'))
  543. assert(undeletable_attribute_html.include?('cannot be deleted'))
  544. assert(undeletable_attribute_html.exclude?('href="#"'))
  545. end
  546. def test_proper_sorting_of_select_attributes
  547. @browser = browser_instance
  548. login(
  549. username: 'admin@example.com',
  550. password: 'test',
  551. url: browser_url,
  552. )
  553. tasks_close_all
  554. # lexicographically ordered list of option strings
  555. options = %w[0 000.000 1 100.100 100.200 2 200.100 200.200 3 ä b n ö p sr ß st t ü v]
  556. options_hash = options.reverse.collect { |o| [o, o] }.to_h
  557. object_manager_attribute_create(
  558. data: {
  559. name: 'select_attributes_sorting_test',
  560. display: 'Select Attributes Sorting Test',
  561. data_type: 'Select',
  562. data_option: { options: options_hash },
  563. },
  564. )
  565. sleep 2
  566. # open the select attribute that we just created
  567. execute(js: "$(\".content.active td:contains('select_attributes_sorting_test')\").first().click()")
  568. sleep 3
  569. unsorted_locations = options.map do |key|
  570. [get_location(xpath: "//input[@value='#{key}']").y, key]
  571. end
  572. log("unsorted_locations = #{unsorted_locations.inspect}")
  573. sorted_locations = unsorted_locations.sort_by(&:first).map(&:second)
  574. log("sorted_locations = #{sorted_locations.inspect}")
  575. assert_equal options, sorted_locations
  576. # close the attribute modal
  577. click(css: '.modal button.js-submit')
  578. watch_for(
  579. css: '.content.active',
  580. value: 'Database Update required',
  581. )
  582. watch_for(
  583. css: '.content.active table',
  584. value: 'select_attributes_sorting_test',
  585. )
  586. click(css: '.content.active .tab-pane.active div.js-execute')
  587. watch_for(
  588. css: '.modal',
  589. value: 'restart',
  590. )
  591. watch_for_disappear(
  592. css: '.modal',
  593. timeout: 7.minutes,
  594. )
  595. sleep 5
  596. watch_for(
  597. css: '.content.active',
  598. )
  599. # create a new ticket and check whether the select attributes are correctly sorted or not
  600. click(
  601. css: 'a[href="#ticket/create"]',
  602. mute_log: true,
  603. )
  604. watch_for(
  605. css: 'select[name="select_attributes_sorting_test"]',
  606. )
  607. select_element = @browser.find_elements(css: 'select[name="select_attributes_sorting_test"]')[0]
  608. unsorted_options = select_element.find_elements(xpath: './*').map(&:text).reject { |x| x == '-' }
  609. log unsorted_options.inspect
  610. assert_equal options, unsorted_options
  611. object_manager_attribute_delete(
  612. data: {
  613. name: 'select_attributes_sorting_test',
  614. },
  615. )
  616. object_manager_attribute_migrate
  617. end
  618. def test_deleted_select_attributes
  619. @browser = browser_instance
  620. login(
  621. username: 'admin@example.com',
  622. password: 'test',
  623. url: browser_url,
  624. )
  625. options = %w[äöü cat delete dog ß].index_with { |x| "#{x.capitalize} Display" }
  626. options_no_dog = options.except('dog')
  627. options_no_dog_no_delete = options_no_dog.except('delete')
  628. tasks_close_all
  629. object_manager_attribute_create(
  630. data: {
  631. name: 'select_attributes_delete_test',
  632. display: 'Select Attributes Delete Test',
  633. data_type: 'Select',
  634. data_option: {
  635. options: options,
  636. },
  637. },
  638. )
  639. object_manager_attribute_migrate
  640. ticket_create(
  641. data: {
  642. customer: 'nico',
  643. group: 'Users',
  644. title: 'select_attributes_delete_test',
  645. body: 'select_attributes_delete_test',
  646. },
  647. custom_data_select: {
  648. select_attributes_delete_test: 'Delete Display',
  649. },
  650. disable_group_check: true,
  651. )
  652. watch_for(
  653. css: '.content.active select[name="select_attributes_delete_test"]',
  654. )
  655. # confirm that all options and their display values are there and are in the correct order
  656. select_element = @browser.find_elements(css: '.content.active select[name="select_attributes_delete_test"]')[0]
  657. unsorted_options = select_element.find_elements(xpath: './*').map { |o| o.attribute('value') }.reject { |x| x == '' }
  658. assert_equal options.keys, unsorted_options
  659. unsorted_display_options = select_element.find_elements(xpath: './*').map(&:text).reject { |x| x == '-' }
  660. assert_equal options.values, unsorted_display_options
  661. # confirm that the "delete" option is selected and that its display text is indeed "Delete Display"
  662. selected_option = select_element.find_elements(css: 'option:checked')[0]
  663. assert_equal 'delete', selected_option.attribute('value')
  664. assert_equal 'Delete Display', selected_option.text
  665. object_manager_attribute_update(
  666. data: {
  667. name: 'select_attributes_delete_test',
  668. data_option: {
  669. options: options_no_dog_no_delete,
  670. },
  671. },
  672. )
  673. object_manager_attribute_migrate
  674. screenshot(comment: 'deleted_select_attributes_before_click')
  675. # open the previously created ticket and verify its attribute selection
  676. click(
  677. xpath: '//a/div[contains(text(),"select_attributes_delete_test")]',
  678. )
  679. # confirm that all options and their display values are there and are in the correct order
  680. select_element = @browser.find_elements(css: '.content.active select[name="select_attributes_delete_test"]')[0]
  681. unsorted_options = select_element.find_elements(xpath: './*').map { |o| o.attribute('value') }.reject { |x| x == '' }
  682. assert_equal options_no_dog.keys, unsorted_options
  683. unsorted_display_options = select_element.find_elements(xpath: './*').map(&:text).reject { |x| x == '-' }
  684. assert_equal options_no_dog.values, unsorted_display_options
  685. # confirm that the "delete" option is still selected and that its display text is still indeed "Delete Display"
  686. selected_option = select_element.find_elements(css: 'option:checked')[0]
  687. assert_equal 'delete', selected_option.attribute('value')
  688. assert_equal 'Delete Display', selected_option.text
  689. # create a new ticket and check that the deleted options no longer appear
  690. click(
  691. css: 'a[href="#ticket/create"]',
  692. mute_log: true,
  693. )
  694. watch_for(
  695. css: 'select[name="select_attributes_delete_test"]',
  696. )
  697. select_element = @browser.find_elements(css: 'select[name="select_attributes_delete_test"]')[0]
  698. unsorted_options = select_element.find_elements(xpath: './*').map { |o| o.attribute('value') }.reject { |x| x == '' }
  699. assert_equal options_no_dog_no_delete.keys, unsorted_options
  700. unsorted_display_options = select_element.find_elements(xpath: './*').map(&:text).reject { |x| x == '-' }
  701. assert_equal options_no_dog_no_delete.values, unsorted_display_options
  702. object_manager_attribute_delete(
  703. data: {
  704. name: 'select_attributes_delete_test',
  705. },
  706. )
  707. object_manager_attribute_migrate
  708. end
  709. # verify fix for issue #2233 - Boolean object set to false is not visible
  710. # verify fix for issue #2277 - Note is not shown for customer / organisations if it's empty
  711. def test_false_boolean_attributes_gets_displayed_for_organizations
  712. @browser = browser_instance
  713. login(
  714. username: 'admin@example.com',
  715. password: 'test',
  716. url: browser_url,
  717. )
  718. tasks_close_all
  719. object_manager_attribute_create(
  720. data: {
  721. object: 'Organization',
  722. name: 'bool_test',
  723. display: 'bool_test',
  724. data_type: 'Boolean',
  725. data_option: {
  726. options: {
  727. # rubocop:disable Lint/BooleanSymbol
  728. true: 'YES',
  729. false: 'NO',
  730. # rubocop:enable Lint/BooleanSymbol
  731. }
  732. },
  733. },
  734. )
  735. object_manager_attribute_create(
  736. data: {
  737. object: 'Organization',
  738. name: 'text_test',
  739. display: 'text_test',
  740. data_type: 'Text',
  741. },
  742. )
  743. object_manager_attribute_migrate
  744. ticket_open_by_title(title: 'select')
  745. click(css: '.content.active .tabsSidebar-tab[data-tab="organization"]')
  746. click(css: '.content.active .sidebar[data-tab="organization"] .js-actions .dropdown-toggle')
  747. click(css: '.content.active .sidebar[data-tab="organization"] .js-actions [data-type="organization-edit"]')
  748. modal_ready
  749. select(css: '.content.active .modal select[name="bool_test"]', value: 'NO')
  750. click(css: '.content.active .modal .js-submit')
  751. modal_disappear
  752. watch_for(
  753. css: '.content.active .sidebar[data-tab="organization"] .sidebar-content',
  754. value: 'bool_test',
  755. )
  756. match_not(
  757. css: '.content.active .sidebar[data-tab="organization"] .sidebar-content',
  758. value: 'text_test',
  759. )
  760. match(
  761. css: '.content.active .sidebar[data-tab="organization"] .sidebar-content',
  762. value: 'note',
  763. )
  764. object_manager_attribute_delete(
  765. data: {
  766. object: 'Organization',
  767. name: 'bool_test',
  768. },
  769. )
  770. object_manager_attribute_delete(
  771. data: {
  772. object: 'Organization',
  773. name: 'text_test',
  774. },
  775. )
  776. object_manager_attribute_migrate
  777. end
  778. # verify fix for issue #2233 - Boolean object set to false is not visible
  779. # verify fix for issue #2277 - Note is not shown for customer / organisations if it's empty
  780. def test_false_boolean_attributes_gets_displayed_for_users
  781. @browser = browser_instance
  782. login(
  783. username: 'admin@example.com',
  784. password: 'test',
  785. url: browser_url,
  786. )
  787. tasks_close_all
  788. object_manager_attribute_create(
  789. data: {
  790. object: 'User',
  791. name: 'bool_test',
  792. display: 'bool_test',
  793. data_type: 'Boolean',
  794. data_option: {
  795. options: {
  796. # rubocop:disable Lint/BooleanSymbol
  797. true: 'YES',
  798. false: 'NO',
  799. # rubocop:enable Lint/BooleanSymbol
  800. }
  801. },
  802. },
  803. )
  804. object_manager_attribute_create(
  805. data: {
  806. object: 'User',
  807. name: 'text_test',
  808. display: 'text_test',
  809. data_type: 'Text',
  810. },
  811. )
  812. object_manager_attribute_migrate
  813. ticket_open_by_title(title: 'select')
  814. click(css: '.content.active .tabsSidebar-tab[data-tab="customer"]')
  815. click(css: '.content.active .sidebar[data-tab="customer"] .js-actions .dropdown-toggle')
  816. click(css: '.content.active .sidebar[data-tab="customer"] .js-actions [data-type="customer-edit"]')
  817. modal_ready
  818. select(css: '.content.active .modal select[name="bool_test"]', value: 'NO')
  819. click(css: '.content.active .modal .js-submit')
  820. modal_disappear
  821. watch_for(
  822. css: '.content.active .sidebar[data-tab="customer"] .sidebar-content',
  823. value: 'bool_test',
  824. )
  825. match_not(
  826. css: '.content.active .sidebar[data-tab="customer"] .sidebar-content',
  827. value: 'text_test',
  828. )
  829. match(
  830. css: '.content.active .sidebar[data-tab="customer"] .sidebar-content',
  831. value: 'note',
  832. )
  833. object_manager_attribute_delete(
  834. data: {
  835. object: 'User',
  836. name: 'bool_test',
  837. },
  838. )
  839. object_manager_attribute_delete(
  840. data: {
  841. object: 'User',
  842. name: 'text_test',
  843. },
  844. )
  845. object_manager_attribute_migrate
  846. end
  847. end