core_workflow_examples.rb 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_examples 'core workflow' do
  3. let(:field_name) { SecureRandom.hex(10) }
  4. let(:screens) do
  5. {
  6. create_middle: {
  7. '-all-' => {
  8. shown: true,
  9. required: false,
  10. },
  11. },
  12. create: {
  13. '-all-' => {
  14. shown: true,
  15. required: false,
  16. },
  17. },
  18. edit: {
  19. '-all-' => {
  20. shown: true,
  21. required: false,
  22. },
  23. },
  24. }
  25. end
  26. describe 'modify input attribute', authenticated_as: :authenticate, db_strategy: :reset do
  27. def authenticate
  28. create(:object_manager_attribute_text, object_name: object_name, name: field_name, display: field_name, screens: screens)
  29. ObjectManager::Attribute.migration_execute
  30. true
  31. end
  32. describe 'action - show' do
  33. before do
  34. create(:core_workflow,
  35. object: object_name,
  36. perform: {
  37. "#{object_name.downcase}.#{field_name}": {
  38. operator: 'show',
  39. show: 'true'
  40. },
  41. })
  42. end
  43. it 'does perform' do
  44. before_it.call
  45. expect(page).to have_css("input[name='#{field_name}']")
  46. end
  47. end
  48. describe 'action - hide' do
  49. before do
  50. create(:core_workflow,
  51. object: object_name,
  52. perform: {
  53. "#{object_name.downcase}.#{field_name}": {
  54. operator: 'hide',
  55. hide: 'true'
  56. },
  57. })
  58. end
  59. it 'does perform' do
  60. before_it.call
  61. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden)
  62. end
  63. end
  64. describe 'action - remove' do
  65. before do
  66. create(:core_workflow,
  67. object: object_name,
  68. perform: {
  69. "#{object_name.downcase}.#{field_name}": {
  70. operator: 'remove',
  71. remove: 'true'
  72. },
  73. })
  74. end
  75. it 'does perform' do
  76. before_it.call
  77. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden)
  78. end
  79. end
  80. describe 'action - set_optional' do
  81. before do
  82. create(:core_workflow,
  83. object: object_name,
  84. perform: {
  85. "#{object_name.downcase}.#{field_name}": {
  86. operator: 'set_optional',
  87. set_optional: 'true'
  88. },
  89. })
  90. end
  91. it 'does perform' do
  92. before_it.call
  93. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*')
  94. end
  95. end
  96. describe 'action - set_mandatory' do
  97. before do
  98. create(:core_workflow,
  99. object: object_name,
  100. perform: {
  101. "#{object_name.downcase}.#{field_name}": {
  102. operator: 'set_mandatory',
  103. set_mandatory: 'true'
  104. },
  105. })
  106. end
  107. it 'does perform' do
  108. before_it.call
  109. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*')
  110. end
  111. end
  112. describe 'action - unset_readonly' do
  113. before do
  114. create(:core_workflow,
  115. object: object_name,
  116. perform: {
  117. "#{object_name.downcase}.#{field_name}": {
  118. operator: 'unset_readonly',
  119. unset_readonly: 'true'
  120. },
  121. })
  122. end
  123. it 'does perform' do
  124. before_it.call
  125. expect(page).to have_no_selector("div[data-attribute-name='#{field_name}'].is-readonly")
  126. end
  127. end
  128. describe 'action - set_readonly' do
  129. before do
  130. create(:core_workflow,
  131. object: object_name,
  132. perform: {
  133. "#{object_name.downcase}.#{field_name}": {
  134. operator: 'set_readonly',
  135. set_readonly: 'true'
  136. },
  137. })
  138. end
  139. it 'does perform' do
  140. before_it.call
  141. expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-readonly")
  142. end
  143. end
  144. describe 'action - fill_in' do
  145. before do
  146. create(:core_workflow,
  147. object: object_name,
  148. perform: {
  149. "#{object_name.downcase}.#{field_name}": {
  150. operator: 'fill_in',
  151. fill_in: '4cddb2twza'
  152. },
  153. })
  154. end
  155. it 'does perform' do
  156. before_it.call
  157. expect(page).to have_field(field_name, with: '4cddb2twza')
  158. end
  159. end
  160. describe 'action - fill_in_empty' do
  161. describe 'with match' do
  162. before do
  163. create(:core_workflow,
  164. object: object_name,
  165. perform: {
  166. "#{object_name.downcase}.#{field_name}": {
  167. operator: 'fill_in_empty',
  168. fill_in_empty: '9999'
  169. },
  170. })
  171. end
  172. it 'does perform' do
  173. before_it.call
  174. expect(page).to have_field(field_name, with: '9999')
  175. end
  176. end
  177. describe 'without match' do
  178. before do
  179. create(:core_workflow,
  180. object: object_name,
  181. perform: {
  182. "#{object_name.downcase}.#{field_name}": {
  183. operator: 'fill_in',
  184. fill_in: '4cddb2twza'
  185. },
  186. })
  187. create(:core_workflow,
  188. object: object_name,
  189. perform: {
  190. "#{object_name.downcase}.#{field_name}": {
  191. operator: 'fill_in_empty',
  192. fill_in_empty: '9999'
  193. },
  194. })
  195. end
  196. it 'does perform' do
  197. before_it.call
  198. expect(page).to have_no_field(field_name, with: '9999')
  199. end
  200. end
  201. end
  202. end
  203. describe 'modify textarea attribute', authenticated_as: :authenticate, db_strategy: :reset do
  204. def authenticate
  205. create(:object_manager_attribute_textarea, object_name: object_name, name: field_name, display: field_name, screens: screens)
  206. ObjectManager::Attribute.migration_execute
  207. true
  208. end
  209. describe 'action - show' do
  210. before do
  211. create(:core_workflow,
  212. object: object_name,
  213. perform: {
  214. "#{object_name.downcase}.#{field_name}": {
  215. operator: 'show',
  216. show: 'true'
  217. },
  218. })
  219. end
  220. it 'does perform' do
  221. before_it.call
  222. expect(page).to have_css("textarea[name='#{field_name}']")
  223. end
  224. end
  225. describe 'action - hide' do
  226. before do
  227. create(:core_workflow,
  228. object: object_name,
  229. perform: {
  230. "#{object_name.downcase}.#{field_name}": {
  231. operator: 'hide',
  232. hide: 'true'
  233. },
  234. })
  235. end
  236. it 'does perform' do
  237. before_it.call
  238. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden)
  239. end
  240. end
  241. describe 'action - remove' do
  242. before do
  243. create(:core_workflow,
  244. object: object_name,
  245. perform: {
  246. "#{object_name.downcase}.#{field_name}": {
  247. operator: 'remove',
  248. remove: 'true'
  249. },
  250. })
  251. end
  252. it 'does perform' do
  253. before_it.call
  254. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden)
  255. end
  256. end
  257. describe 'action - set_optional' do
  258. before do
  259. create(:core_workflow,
  260. object: object_name,
  261. perform: {
  262. "#{object_name.downcase}.#{field_name}": {
  263. operator: 'set_optional',
  264. set_optional: 'true'
  265. },
  266. })
  267. end
  268. it 'does perform' do
  269. before_it.call
  270. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*')
  271. end
  272. end
  273. describe 'action - set_mandatory' do
  274. before do
  275. create(:core_workflow,
  276. object: object_name,
  277. perform: {
  278. "#{object_name.downcase}.#{field_name}": {
  279. operator: 'set_mandatory',
  280. set_mandatory: 'true'
  281. },
  282. })
  283. end
  284. it 'does perform' do
  285. before_it.call
  286. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*')
  287. end
  288. end
  289. describe 'action - unset_readonly' do
  290. before do
  291. create(:core_workflow,
  292. object: object_name,
  293. perform: {
  294. "#{object_name.downcase}.#{field_name}": {
  295. operator: 'unset_readonly',
  296. unset_readonly: 'true'
  297. },
  298. })
  299. end
  300. it 'does perform' do
  301. before_it.call
  302. expect(page).to have_no_selector("div[data-attribute-name='#{field_name}'].is-readonly")
  303. end
  304. end
  305. describe 'action - set_readonly' do
  306. before do
  307. create(:core_workflow,
  308. object: object_name,
  309. perform: {
  310. "#{object_name.downcase}.#{field_name}": {
  311. operator: 'set_readonly',
  312. set_readonly: 'true'
  313. },
  314. })
  315. end
  316. it 'does perform' do
  317. before_it.call
  318. expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-readonly")
  319. end
  320. end
  321. describe 'action - fill_in' do
  322. before do
  323. create(:core_workflow,
  324. object: object_name,
  325. perform: {
  326. "#{object_name.downcase}.#{field_name}": {
  327. operator: 'fill_in',
  328. fill_in: '4cddb2twza'
  329. },
  330. })
  331. end
  332. it 'does perform' do
  333. before_it.call
  334. expect(page).to have_field(field_name, with: '4cddb2twza')
  335. end
  336. end
  337. describe 'action - fill_in_empty' do
  338. describe 'with match' do
  339. before do
  340. create(:core_workflow,
  341. object: object_name,
  342. perform: {
  343. "#{object_name.downcase}.#{field_name}": {
  344. operator: 'fill_in_empty',
  345. fill_in_empty: '9999'
  346. },
  347. })
  348. end
  349. it 'does perform' do
  350. before_it.call
  351. expect(page).to have_field(field_name, with: '9999')
  352. end
  353. end
  354. describe 'without match' do
  355. before do
  356. create(:core_workflow,
  357. object: object_name,
  358. perform: {
  359. "#{object_name.downcase}.#{field_name}": {
  360. operator: 'fill_in',
  361. fill_in: '4cddb2twza'
  362. },
  363. })
  364. create(:core_workflow,
  365. object: object_name,
  366. perform: {
  367. "#{object_name.downcase}.#{field_name}": {
  368. operator: 'fill_in_empty',
  369. fill_in_empty: '9999'
  370. },
  371. })
  372. end
  373. it 'does perform' do
  374. before_it.call
  375. expect(page).to have_no_field(field_name, with: '9999')
  376. end
  377. end
  378. end
  379. end
  380. describe 'modify select attribute', authenticated_as: :authenticate, db_strategy: :reset do
  381. def authenticate
  382. create(:object_manager_attribute_select, object_name: object_name, name: field_name, display: field_name, screens: screens)
  383. ObjectManager::Attribute.migration_execute
  384. true
  385. end
  386. describe 'action - show' do
  387. before do
  388. create(:core_workflow,
  389. object: object_name,
  390. perform: {
  391. "#{object_name.downcase}.#{field_name}": {
  392. operator: 'show',
  393. show: 'true'
  394. },
  395. })
  396. end
  397. it 'does perform' do
  398. before_it.call
  399. expect(page).to have_css("select[name='#{field_name}']")
  400. end
  401. end
  402. describe 'action - hide' do
  403. before do
  404. create(:core_workflow,
  405. object: object_name,
  406. perform: {
  407. "#{object_name.downcase}.#{field_name}": {
  408. operator: 'hide',
  409. hide: 'true'
  410. },
  411. })
  412. end
  413. it 'does perform' do
  414. before_it.call
  415. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden)
  416. end
  417. end
  418. describe 'action - remove' do
  419. before do
  420. create(:core_workflow,
  421. object: object_name,
  422. perform: {
  423. "#{object_name.downcase}.#{field_name}": {
  424. operator: 'remove',
  425. remove: 'true'
  426. },
  427. })
  428. end
  429. it 'does perform' do
  430. before_it.call
  431. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden)
  432. end
  433. end
  434. describe 'action - set_optional' do
  435. before do
  436. create(:core_workflow,
  437. object: object_name,
  438. perform: {
  439. "#{object_name.downcase}.#{field_name}": {
  440. operator: 'set_optional',
  441. set_optional: 'true'
  442. },
  443. })
  444. end
  445. it 'does perform' do
  446. before_it.call
  447. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*')
  448. end
  449. end
  450. describe 'action - set_mandatory' do
  451. before do
  452. create(:core_workflow,
  453. object: object_name,
  454. perform: {
  455. "#{object_name.downcase}.#{field_name}": {
  456. operator: 'set_mandatory',
  457. set_mandatory: 'true'
  458. },
  459. })
  460. end
  461. it 'does perform' do
  462. before_it.call
  463. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*')
  464. end
  465. end
  466. describe 'action - unset_readonly' do
  467. before do
  468. create(:core_workflow,
  469. object: object_name,
  470. perform: {
  471. "#{object_name.downcase}.#{field_name}": {
  472. operator: 'unset_readonly',
  473. unset_readonly: 'true'
  474. },
  475. })
  476. end
  477. it 'does perform' do
  478. before_it.call
  479. expect(page).to have_no_selector("div[data-attribute-name='#{field_name}'].is-readonly")
  480. end
  481. end
  482. describe 'action - set_readonly' do
  483. before do
  484. create(:core_workflow,
  485. object: object_name,
  486. perform: {
  487. "#{object_name.downcase}.#{field_name}": {
  488. operator: 'set_readonly',
  489. set_readonly: 'true'
  490. },
  491. })
  492. end
  493. it 'does perform' do
  494. before_it.call
  495. expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-readonly")
  496. end
  497. end
  498. describe 'action - restrict values' do
  499. before do
  500. create(:core_workflow,
  501. object: object_name,
  502. perform: {
  503. "#{object_name.downcase}.#{field_name}": {
  504. operator: 'set_fixed_to',
  505. set_fixed_to: %w[key_1 key_3]
  506. },
  507. })
  508. end
  509. it 'does perform' do
  510. before_it.call
  511. expect(page).to have_css("select[name='#{field_name}'] option[value='key_1']")
  512. expect(page).to have_no_selector("select[name='#{field_name}'] option[value='key_2']")
  513. expect(page).to have_css("select[name='#{field_name}'] option[value='key_3']")
  514. end
  515. end
  516. describe 'action - select' do
  517. before do
  518. create(:core_workflow,
  519. object: object_name,
  520. perform: {
  521. "#{object_name.downcase}.#{field_name}": {
  522. operator: 'select',
  523. select: ['key_3']
  524. },
  525. })
  526. end
  527. it 'does perform' do
  528. before_it.call
  529. expect(page).to have_css("select[name='#{field_name}'] option[value='key_3'][selected]")
  530. end
  531. end
  532. describe 'action - auto select' do
  533. before do
  534. create(:core_workflow,
  535. object: object_name,
  536. perform: {
  537. "#{object_name.downcase}.#{field_name}": {
  538. operator: 'set_fixed_to',
  539. set_fixed_to: ['', 'key_3'],
  540. },
  541. })
  542. create(:core_workflow,
  543. object: object_name,
  544. perform: {
  545. "#{object_name.downcase}.#{field_name}": {
  546. operator: 'auto_select',
  547. auto_select: 'true',
  548. },
  549. })
  550. end
  551. it 'does perform' do
  552. before_it.call
  553. expect(page).to have_css("select[name='#{field_name}'] option[value='key_3'][selected]")
  554. end
  555. end
  556. end
  557. describe 'modify multiselect attribute', authenticated_as: :authenticate, db_strategy: :reset do
  558. def authenticate
  559. create(:object_manager_attribute_multiselect, object_name: object_name, name: field_name, display: field_name, screens: screens)
  560. ObjectManager::Attribute.migration_execute
  561. true
  562. end
  563. describe 'action - show' do
  564. before do
  565. create(:core_workflow,
  566. object: object_name,
  567. perform: {
  568. "#{object_name.downcase}.#{field_name}": {
  569. operator: 'show',
  570. show: 'true'
  571. },
  572. })
  573. end
  574. it 'does perform' do
  575. before_it.call
  576. expect(page).to have_css("select[name='#{field_name}']")
  577. end
  578. end
  579. describe 'action - hide' do
  580. before do
  581. create(:core_workflow,
  582. object: object_name,
  583. perform: {
  584. "#{object_name.downcase}.#{field_name}": {
  585. operator: 'hide',
  586. hide: 'true'
  587. },
  588. })
  589. end
  590. it 'does perform' do
  591. before_it.call
  592. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden)
  593. end
  594. end
  595. describe 'action - remove' do
  596. before do
  597. create(:core_workflow,
  598. object: object_name,
  599. perform: {
  600. "#{object_name.downcase}.#{field_name}": {
  601. operator: 'remove',
  602. remove: 'true'
  603. },
  604. })
  605. end
  606. it 'does perform' do
  607. before_it.call
  608. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden)
  609. end
  610. end
  611. describe 'action - set_optional' do
  612. before do
  613. create(:core_workflow,
  614. object: object_name,
  615. perform: {
  616. "#{object_name.downcase}.#{field_name}": {
  617. operator: 'set_optional',
  618. set_optional: 'true'
  619. },
  620. })
  621. end
  622. it 'does perform' do
  623. before_it.call
  624. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*')
  625. end
  626. end
  627. describe 'action - set_mandatory' do
  628. before do
  629. create(:core_workflow,
  630. object: object_name,
  631. perform: {
  632. "#{object_name.downcase}.#{field_name}": {
  633. operator: 'set_mandatory',
  634. set_mandatory: 'true'
  635. },
  636. })
  637. end
  638. it 'does perform' do
  639. before_it.call
  640. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*')
  641. end
  642. end
  643. describe 'action - unset_readonly' do
  644. before do
  645. create(:core_workflow,
  646. object: object_name,
  647. perform: {
  648. "#{object_name.downcase}.#{field_name}": {
  649. operator: 'unset_readonly',
  650. unset_readonly: 'true'
  651. },
  652. })
  653. end
  654. it 'does perform' do
  655. before_it.call
  656. expect(page).to have_no_selector("div[data-attribute-name='#{field_name}'].is-readonly")
  657. end
  658. end
  659. describe 'action - set_readonly' do
  660. before do
  661. create(:core_workflow,
  662. object: object_name,
  663. perform: {
  664. "#{object_name.downcase}.#{field_name}": {
  665. operator: 'set_readonly',
  666. set_readonly: 'true'
  667. },
  668. })
  669. end
  670. it 'does perform' do
  671. before_it.call
  672. expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-readonly")
  673. end
  674. end
  675. describe 'action - restrict values' do
  676. before do
  677. create(:core_workflow,
  678. object: object_name,
  679. perform: {
  680. "#{object_name.downcase}.#{field_name}": {
  681. operator: 'set_fixed_to',
  682. set_fixed_to: %w[key_1 key_3]
  683. },
  684. })
  685. end
  686. it 'does perform' do
  687. before_it.call
  688. expect(page).to have_css("select[name='#{field_name}'] option[value='key_1']")
  689. expect(page).to have_no_selector("select[name='#{field_name}'] option[value='key_2']")
  690. expect(page).to have_css("select[name='#{field_name}'] option[value='key_3']")
  691. end
  692. end
  693. describe 'action - select' do
  694. before do
  695. create(:core_workflow,
  696. object: object_name,
  697. perform: {
  698. "#{object_name.downcase}.#{field_name}": {
  699. operator: 'select',
  700. select: ['key_3']
  701. },
  702. })
  703. end
  704. it 'does perform' do
  705. before_it.call
  706. expect(page).to have_select(field_name, selected: ['value_3'])
  707. end
  708. end
  709. describe 'action - auto select' do
  710. before do
  711. create(:core_workflow,
  712. object: object_name,
  713. perform: {
  714. "#{object_name.downcase}.#{field_name}": {
  715. operator: 'set_fixed_to',
  716. set_fixed_to: ['', 'key_3'],
  717. },
  718. })
  719. create(:core_workflow,
  720. object: object_name,
  721. perform: {
  722. "#{object_name.downcase}.#{field_name}": {
  723. operator: 'auto_select',
  724. auto_select: 'true',
  725. },
  726. })
  727. end
  728. it 'does perform' do
  729. before_it.call
  730. expect(page).to have_select(field_name, selected: ['value_3'])
  731. end
  732. end
  733. end
  734. describe 'modify boolean attribute', authenticated_as: :authenticate, db_strategy: :reset do
  735. def authenticate
  736. create(:object_manager_attribute_boolean, object_name: object_name, name: field_name, display: field_name, screens: screens)
  737. ObjectManager::Attribute.migration_execute
  738. true
  739. end
  740. describe 'action - show' do
  741. before do
  742. create(:core_workflow,
  743. object: object_name,
  744. perform: {
  745. "#{object_name.downcase}.#{field_name}": {
  746. operator: 'show',
  747. show: 'true'
  748. },
  749. })
  750. end
  751. it 'does perform' do
  752. before_it.call
  753. expect(page).to have_css("select[name='#{field_name}']")
  754. end
  755. end
  756. describe 'action - hide' do
  757. before do
  758. create(:core_workflow,
  759. object: object_name,
  760. perform: {
  761. "#{object_name.downcase}.#{field_name}": {
  762. operator: 'hide',
  763. hide: 'true'
  764. },
  765. })
  766. end
  767. it 'does perform' do
  768. before_it.call
  769. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden)
  770. end
  771. end
  772. describe 'action - remove' do
  773. before do
  774. create(:core_workflow,
  775. object: object_name,
  776. perform: {
  777. "#{object_name.downcase}.#{field_name}": {
  778. operator: 'remove',
  779. remove: 'true'
  780. },
  781. })
  782. end
  783. it 'does perform' do
  784. before_it.call
  785. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden)
  786. end
  787. end
  788. describe 'action - set_optional' do
  789. before do
  790. create(:core_workflow,
  791. object: object_name,
  792. perform: {
  793. "#{object_name.downcase}.#{field_name}": {
  794. operator: 'set_optional',
  795. set_optional: 'true'
  796. },
  797. })
  798. end
  799. it 'does perform' do
  800. before_it.call
  801. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*')
  802. end
  803. end
  804. describe 'action - set_mandatory' do
  805. before do
  806. create(:core_workflow,
  807. object: object_name,
  808. perform: {
  809. "#{object_name.downcase}.#{field_name}": {
  810. operator: 'set_mandatory',
  811. set_mandatory: 'true'
  812. },
  813. })
  814. end
  815. it 'does perform' do
  816. before_it.call
  817. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*')
  818. end
  819. end
  820. describe 'action - restrict values' do
  821. before do
  822. create(:core_workflow,
  823. object: object_name,
  824. perform: {
  825. "#{object_name.downcase}.#{field_name}": {
  826. operator: 'set_fixed_to',
  827. set_fixed_to: %w[false]
  828. },
  829. })
  830. end
  831. it 'does perform' do
  832. before_it.call
  833. expect(page).to have_css("select[name='#{field_name}'] option[value='false']")
  834. expect(page).to have_no_selector("select[name='#{field_name}'] option[value='true']")
  835. end
  836. end
  837. describe 'action - select' do
  838. before do
  839. create(:core_workflow,
  840. object: object_name,
  841. perform: {
  842. "#{object_name.downcase}.#{field_name}": {
  843. operator: 'select',
  844. select: ['true']
  845. },
  846. })
  847. end
  848. it 'does perform' do
  849. before_it.call
  850. expect(page).to have_css("select[name='#{field_name}'] option[value='true'][selected]")
  851. end
  852. end
  853. describe 'action - auto select' do
  854. before do
  855. create(:core_workflow,
  856. object: object_name,
  857. perform: {
  858. "#{object_name.downcase}.#{field_name}": {
  859. operator: 'set_fixed_to',
  860. set_fixed_to: ['', 'false'],
  861. },
  862. })
  863. create(:core_workflow,
  864. object: object_name,
  865. perform: {
  866. "#{object_name.downcase}.#{field_name}": {
  867. operator: 'auto_select',
  868. auto_select: 'true',
  869. },
  870. })
  871. end
  872. it 'does perform' do
  873. before_it.call
  874. expect(page).to have_css("select[name='#{field_name}'] option[value='false'][selected]")
  875. end
  876. end
  877. end
  878. describe 'modify tree select attribute', authenticated_as: :authenticate, db_strategy: :reset do
  879. def authenticate
  880. create(:object_manager_attribute_tree_select, object_name: object_name, name: field_name, display: field_name, screens: screens)
  881. ObjectManager::Attribute.migration_execute
  882. true
  883. end
  884. describe 'action - show' do
  885. before do
  886. create(:core_workflow,
  887. object: object_name,
  888. perform: {
  889. "#{object_name.downcase}.#{field_name}": {
  890. operator: 'show',
  891. show: 'true'
  892. },
  893. })
  894. end
  895. it 'does perform' do
  896. before_it.call
  897. expect(page).to have_css("input[name='#{field_name}']", visible: :all)
  898. end
  899. end
  900. describe 'action - hide' do
  901. before do
  902. create(:core_workflow,
  903. object: object_name,
  904. perform: {
  905. "#{object_name.downcase}.#{field_name}": {
  906. operator: 'hide',
  907. hide: 'true'
  908. },
  909. })
  910. end
  911. it 'does perform' do
  912. before_it.call
  913. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :all)
  914. end
  915. end
  916. describe 'action - remove' do
  917. before do
  918. create(:core_workflow,
  919. object: object_name,
  920. perform: {
  921. "#{object_name.downcase}.#{field_name}": {
  922. operator: 'remove',
  923. remove: 'true'
  924. },
  925. })
  926. end
  927. it 'does perform' do
  928. before_it.call
  929. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden)
  930. end
  931. end
  932. describe 'action - set_optional' do
  933. before do
  934. create(:core_workflow,
  935. object: object_name,
  936. perform: {
  937. "#{object_name.downcase}.#{field_name}": {
  938. operator: 'set_optional',
  939. set_optional: 'true'
  940. },
  941. })
  942. end
  943. it 'does perform' do
  944. before_it.call
  945. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*')
  946. end
  947. end
  948. describe 'action - set_mandatory' do
  949. before do
  950. create(:core_workflow,
  951. object: object_name,
  952. perform: {
  953. "#{object_name.downcase}.#{field_name}": {
  954. operator: 'set_mandatory',
  955. set_mandatory: 'true'
  956. },
  957. })
  958. end
  959. it 'does perform' do
  960. before_it.call
  961. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*')
  962. end
  963. end
  964. describe 'action - unset_readonly' do
  965. before do
  966. create(:core_workflow,
  967. object: object_name,
  968. perform: {
  969. "#{object_name.downcase}.#{field_name}": {
  970. operator: 'unset_readonly',
  971. unset_readonly: 'true'
  972. },
  973. })
  974. end
  975. it 'does perform' do
  976. before_it.call
  977. expect(page).to have_no_selector("div[data-attribute-name='#{field_name}'].is-readonly")
  978. end
  979. end
  980. describe 'action - set_readonly' do
  981. before do
  982. create(:core_workflow,
  983. object: object_name,
  984. perform: {
  985. "#{object_name.downcase}.#{field_name}": {
  986. operator: 'set_readonly',
  987. set_readonly: 'true'
  988. },
  989. })
  990. end
  991. it 'does perform' do
  992. before_it.call
  993. expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-readonly")
  994. end
  995. end
  996. describe 'action - restrict values' do
  997. before do
  998. create(:core_workflow,
  999. object: object_name,
  1000. perform: {
  1001. "#{object_name.downcase}.#{field_name}": {
  1002. operator: 'set_fixed_to',
  1003. set_fixed_to: ['Incident', 'Incident::Hardware', 'Incident::Hardware::Monitor']
  1004. },
  1005. })
  1006. end
  1007. it 'does perform' do
  1008. before_it.call
  1009. expect(page).to have_css('span.searchableSelect-option-text', text: 'Incident', visible: :all)
  1010. expect(page).to have_css('span.searchableSelect-option-text', text: 'Hardware', visible: :all)
  1011. expect(page).to have_css('span.searchableSelect-option-text', text: 'Monitor', visible: :all)
  1012. expect(page).to have_no_selector('span.searchableSelect-option-text', text: 'Mouse', visible: :all)
  1013. expect(page).to have_no_selector('span.searchableSelect-option-text', text: 'Softwareproblem', visible: :all)
  1014. end
  1015. end
  1016. describe 'action - select' do
  1017. before do
  1018. create(:core_workflow,
  1019. object: object_name,
  1020. perform: {
  1021. "#{object_name.downcase}.#{field_name}": {
  1022. operator: 'select',
  1023. select: ['Incident::Hardware::Monitor']
  1024. },
  1025. })
  1026. end
  1027. it 'does perform' do
  1028. before_it.call
  1029. expect(page).to have_css("input[name='#{field_name}'][value='Incident::Hardware::Monitor']", visible: :all)
  1030. end
  1031. end
  1032. describe 'action - auto select' do
  1033. before do
  1034. create(:core_workflow,
  1035. object: object_name,
  1036. perform: {
  1037. "#{object_name.downcase}.#{field_name}": {
  1038. operator: 'set_fixed_to',
  1039. set_fixed_to: ['', 'Incident'],
  1040. },
  1041. })
  1042. create(:core_workflow,
  1043. object: object_name,
  1044. perform: {
  1045. "#{object_name.downcase}.#{field_name}": {
  1046. operator: 'auto_select',
  1047. auto_select: 'true',
  1048. },
  1049. })
  1050. end
  1051. it 'does perform' do
  1052. before_it.call
  1053. expect(page).to have_css("input[name='#{field_name}'][value='Incident']", visible: :all)
  1054. end
  1055. end
  1056. end
  1057. describe 'modify multi tree select attribute', authenticated_as: :authenticate, db_strategy: :reset do
  1058. def authenticate
  1059. create(:object_manager_attribute_multi_tree_select, object_name: object_name, name: field_name, display: field_name, screens: screens)
  1060. ObjectManager::Attribute.migration_execute
  1061. true
  1062. end
  1063. describe 'action - show' do
  1064. before do
  1065. create(:core_workflow,
  1066. object: object_name,
  1067. perform: {
  1068. "#{object_name.downcase}.#{field_name}": {
  1069. operator: 'show',
  1070. show: 'true'
  1071. },
  1072. })
  1073. end
  1074. it 'does perform' do
  1075. before_it.call
  1076. expect(page).to have_css("input[name='#{field_name}_completion']", visible: :all)
  1077. end
  1078. end
  1079. describe 'action - hide' do
  1080. before do
  1081. create(:core_workflow,
  1082. object: object_name,
  1083. perform: {
  1084. "#{object_name.downcase}.#{field_name}": {
  1085. operator: 'hide',
  1086. hide: 'true'
  1087. },
  1088. })
  1089. end
  1090. it 'does perform' do
  1091. before_it.call
  1092. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :all)
  1093. end
  1094. end
  1095. describe 'action - remove' do
  1096. before do
  1097. create(:core_workflow,
  1098. object: object_name,
  1099. perform: {
  1100. "#{object_name.downcase}.#{field_name}": {
  1101. operator: 'remove',
  1102. remove: 'true'
  1103. },
  1104. })
  1105. end
  1106. it 'does perform' do
  1107. before_it.call
  1108. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden)
  1109. end
  1110. end
  1111. describe 'action - set_optional' do
  1112. before do
  1113. create(:core_workflow,
  1114. object: object_name,
  1115. perform: {
  1116. "#{object_name.downcase}.#{field_name}": {
  1117. operator: 'set_optional',
  1118. set_optional: 'true'
  1119. },
  1120. })
  1121. end
  1122. it 'does perform' do
  1123. before_it.call
  1124. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*')
  1125. end
  1126. end
  1127. describe 'action - set_mandatory' do
  1128. before do
  1129. create(:core_workflow,
  1130. object: object_name,
  1131. perform: {
  1132. "#{object_name.downcase}.#{field_name}": {
  1133. operator: 'set_mandatory',
  1134. set_mandatory: 'true'
  1135. },
  1136. })
  1137. end
  1138. it 'does perform' do
  1139. before_it.call
  1140. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*')
  1141. end
  1142. end
  1143. describe 'action - unset_readonly' do
  1144. before do
  1145. create(:core_workflow,
  1146. object: object_name,
  1147. perform: {
  1148. "#{object_name.downcase}.#{field_name}": {
  1149. operator: 'unset_readonly',
  1150. unset_readonly: 'true'
  1151. },
  1152. })
  1153. end
  1154. it 'does perform' do
  1155. before_it.call
  1156. expect(page).to have_no_selector("div[data-attribute-name='#{field_name}'].is-readonly")
  1157. end
  1158. end
  1159. describe 'action - set_readonly' do
  1160. before do
  1161. create(:core_workflow,
  1162. object: object_name,
  1163. perform: {
  1164. "#{object_name.downcase}.#{field_name}": {
  1165. operator: 'set_readonly',
  1166. set_readonly: 'true'
  1167. },
  1168. })
  1169. end
  1170. it 'does perform' do
  1171. before_it.call
  1172. expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-readonly")
  1173. end
  1174. end
  1175. describe 'action - restrict values' do
  1176. before do
  1177. create(:core_workflow,
  1178. object: object_name,
  1179. perform: {
  1180. "#{object_name.downcase}.#{field_name}": {
  1181. operator: 'set_fixed_to',
  1182. set_fixed_to: ['Incident', 'Incident::Hardware', 'Incident::Hardware::Monitor']
  1183. },
  1184. })
  1185. end
  1186. it 'does perform' do
  1187. before_it.call
  1188. expect(page).to have_css('span.searchableSelect-option-text', text: 'Incident', visible: :all)
  1189. expect(page).to have_css('span.searchableSelect-option-text', text: 'Hardware', visible: :all)
  1190. expect(page).to have_css('span.searchableSelect-option-text', text: 'Monitor', visible: :all)
  1191. expect(page).to have_no_selector('span.searchableSelect-option-text', text: 'Mouse', visible: :all)
  1192. expect(page).to have_no_selector('span.searchableSelect-option-text', text: 'Softwareproblem', visible: :all)
  1193. end
  1194. end
  1195. describe 'action - select' do
  1196. before do
  1197. create(:core_workflow,
  1198. object: object_name,
  1199. perform: {
  1200. "#{object_name.downcase}.#{field_name}": {
  1201. operator: 'select',
  1202. select: ['Incident::Hardware::Monitor']
  1203. },
  1204. })
  1205. end
  1206. it 'does perform' do
  1207. before_it.call
  1208. expect(page).to have_css('span.token-label', text: 'Incident › Hardware › Monitor')
  1209. end
  1210. end
  1211. describe 'action - auto select' do
  1212. before do
  1213. create(:core_workflow,
  1214. object: object_name,
  1215. perform: {
  1216. "#{object_name.downcase}.#{field_name}": {
  1217. operator: 'set_fixed_to',
  1218. set_fixed_to: ['', 'Incident'],
  1219. },
  1220. })
  1221. create(:core_workflow,
  1222. object: object_name,
  1223. perform: {
  1224. "#{object_name.downcase}.#{field_name}": {
  1225. operator: 'auto_select',
  1226. auto_select: 'true',
  1227. },
  1228. })
  1229. end
  1230. it 'does perform' do
  1231. before_it.call
  1232. expect(page).to have_css('span.token-label', text: 'Incident')
  1233. end
  1234. end
  1235. end
  1236. describe 'modify date attribute', authenticated_as: :authenticate, db_strategy: :reset do
  1237. def authenticate
  1238. create(:object_manager_attribute_date, object_name: object_name, name: field_name, display: field_name, screens: screens)
  1239. ObjectManager::Attribute.migration_execute
  1240. true
  1241. end
  1242. describe 'action - show' do
  1243. before do
  1244. create(:core_workflow,
  1245. object: object_name,
  1246. perform: {
  1247. "#{object_name.downcase}.#{field_name}": {
  1248. operator: 'show',
  1249. show: 'true'
  1250. },
  1251. })
  1252. end
  1253. it 'does perform' do
  1254. before_it.call
  1255. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}']")
  1256. end
  1257. end
  1258. describe 'action - hide' do
  1259. before do
  1260. create(:core_workflow,
  1261. object: object_name,
  1262. perform: {
  1263. "#{object_name.downcase}.#{field_name}": {
  1264. operator: 'hide',
  1265. hide: 'true'
  1266. },
  1267. })
  1268. end
  1269. it 'does perform' do
  1270. before_it.call
  1271. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden)
  1272. end
  1273. end
  1274. describe 'action - remove' do
  1275. before do
  1276. create(:core_workflow,
  1277. object: object_name,
  1278. perform: {
  1279. "#{object_name.downcase}.#{field_name}": {
  1280. operator: 'remove',
  1281. remove: 'true'
  1282. },
  1283. })
  1284. end
  1285. it 'does perform' do
  1286. before_it.call
  1287. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden)
  1288. end
  1289. end
  1290. describe 'action - set_optional' do
  1291. before do
  1292. create(:core_workflow,
  1293. object: object_name,
  1294. perform: {
  1295. "#{object_name.downcase}.#{field_name}": {
  1296. operator: 'set_optional',
  1297. set_optional: 'true'
  1298. },
  1299. })
  1300. end
  1301. it 'does perform' do
  1302. before_it.call
  1303. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*')
  1304. end
  1305. end
  1306. describe 'action - set_mandatory' do
  1307. before do
  1308. create(:core_workflow,
  1309. object: object_name,
  1310. perform: {
  1311. "#{object_name.downcase}.#{field_name}": {
  1312. operator: 'set_mandatory',
  1313. set_mandatory: 'true'
  1314. },
  1315. })
  1316. end
  1317. it 'does perform' do
  1318. before_it.call
  1319. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*')
  1320. end
  1321. end
  1322. describe 'action - unset_readonly' do
  1323. before do
  1324. create(:core_workflow,
  1325. object: object_name,
  1326. perform: {
  1327. "#{object_name.downcase}.#{field_name}": {
  1328. operator: 'unset_readonly',
  1329. unset_readonly: 'true'
  1330. },
  1331. })
  1332. end
  1333. it 'does perform' do
  1334. before_it.call
  1335. expect(page).to have_no_selector("div[data-attribute-name='#{field_name}'].is-readonly")
  1336. end
  1337. end
  1338. describe 'action - set_readonly' do
  1339. before do
  1340. create(:core_workflow,
  1341. object: object_name,
  1342. perform: {
  1343. "#{object_name.downcase}.#{field_name}": {
  1344. operator: 'set_readonly',
  1345. set_readonly: 'true'
  1346. },
  1347. })
  1348. end
  1349. it 'does perform' do
  1350. before_it.call
  1351. expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-readonly")
  1352. end
  1353. end
  1354. end
  1355. describe 'modify datetime attribute', authenticated_as: :authenticate, db_strategy: :reset do
  1356. def authenticate
  1357. create(:object_manager_attribute_datetime, object_name: object_name, name: field_name, display: field_name, screens: screens)
  1358. ObjectManager::Attribute.migration_execute
  1359. true
  1360. end
  1361. describe 'action - show' do
  1362. before do
  1363. create(:core_workflow,
  1364. object: object_name,
  1365. perform: {
  1366. "#{object_name.downcase}.#{field_name}": {
  1367. operator: 'show',
  1368. show: 'true'
  1369. },
  1370. })
  1371. end
  1372. it 'does perform' do
  1373. before_it.call
  1374. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}']")
  1375. end
  1376. end
  1377. describe 'action - hide' do
  1378. before do
  1379. create(:core_workflow,
  1380. object: object_name,
  1381. perform: {
  1382. "#{object_name.downcase}.#{field_name}": {
  1383. operator: 'hide',
  1384. hide: 'true'
  1385. },
  1386. })
  1387. end
  1388. it 'does perform' do
  1389. before_it.call
  1390. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden)
  1391. end
  1392. end
  1393. describe 'action - remove' do
  1394. before do
  1395. create(:core_workflow,
  1396. object: object_name,
  1397. perform: {
  1398. "#{object_name.downcase}.#{field_name}": {
  1399. operator: 'remove',
  1400. remove: 'true'
  1401. },
  1402. })
  1403. end
  1404. it 'does perform' do
  1405. before_it.call
  1406. expect(page).to have_css(".form-group[data-attribute-name='#{field_name}'].is-removed", visible: :hidden)
  1407. end
  1408. end
  1409. describe 'action - set_optional' do
  1410. before do
  1411. create(:core_workflow,
  1412. object: object_name,
  1413. perform: {
  1414. "#{object_name.downcase}.#{field_name}": {
  1415. operator: 'set_optional',
  1416. set_optional: 'true'
  1417. },
  1418. })
  1419. end
  1420. it 'does perform' do
  1421. before_it.call
  1422. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_no_text('*')
  1423. end
  1424. end
  1425. describe 'action - set_mandatory' do
  1426. before do
  1427. create(:core_workflow,
  1428. object: object_name,
  1429. perform: {
  1430. "#{object_name.downcase}.#{field_name}": {
  1431. operator: 'set_mandatory',
  1432. set_mandatory: 'true'
  1433. },
  1434. })
  1435. end
  1436. it 'does perform' do
  1437. before_it.call
  1438. expect(page.find("div[data-attribute-name='#{field_name}'] div.formGroup-label label")).to have_text('*')
  1439. end
  1440. end
  1441. describe 'action - unset_readonly' do
  1442. before do
  1443. create(:core_workflow,
  1444. object: object_name,
  1445. perform: {
  1446. "#{object_name.downcase}.#{field_name}": {
  1447. operator: 'unset_readonly',
  1448. unset_readonly: 'true'
  1449. },
  1450. })
  1451. end
  1452. it 'does perform' do
  1453. before_it.call
  1454. expect(page).to have_no_selector("div[data-attribute-name='#{field_name}'].is-readonly")
  1455. end
  1456. end
  1457. describe 'action - set_readonly' do
  1458. before do
  1459. create(:core_workflow,
  1460. object: object_name,
  1461. perform: {
  1462. "#{object_name.downcase}.#{field_name}": {
  1463. operator: 'set_readonly',
  1464. set_readonly: 'true'
  1465. },
  1466. })
  1467. end
  1468. it 'does perform' do
  1469. before_it.call
  1470. expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-readonly")
  1471. end
  1472. end
  1473. end
  1474. describe 'Unable to close tickets in certran cases if core workflow is used #3710', authenticated_as: :authenticate, db_strategy: :reset do
  1475. def authenticate
  1476. create(:object_manager_attribute_text, object_name: object_name, name: field_name, display: field_name, screens: screens)
  1477. ObjectManager::Attribute.migration_execute
  1478. true
  1479. end
  1480. before do
  1481. create(:core_workflow,
  1482. object: object_name,
  1483. perform: {
  1484. "#{object_name.downcase}.#{field_name}": {
  1485. operator: 'set_mandatory',
  1486. set_mandatory: 'true'
  1487. },
  1488. })
  1489. create(:core_workflow,
  1490. object: object_name,
  1491. perform: {
  1492. "#{object_name.downcase}.#{field_name}": {
  1493. operator: 'hide',
  1494. hide: 'true'
  1495. },
  1496. })
  1497. end
  1498. it 'does not display hidden fields as mandatory' do
  1499. before_it.call
  1500. expect(page.find("input[name='#{field_name}']", visible: :hidden)[:required]).not_to eq('true')
  1501. end
  1502. end
  1503. end