array_test.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. var assert = require('assert');
  2. var i;
  3. Feature('array');
  4. Scenario('should have correct initial value', async (I) => {
  5. I.amOnPage('array.html');
  6. I.click('.get-value');
  7. value = await I.grabValueFrom('.debug');
  8. assert.equal(value, '[]');
  9. });
  10. Scenario('should work well with string editors', async (I) => {
  11. I.amOnPage('array-strings.html');
  12. I.click('Add String');
  13. I.click('Add String');
  14. I.click('Add String');
  15. I.click('Add String');
  16. I.click('Add String');
  17. I.seeElement('[name="root[0]"]');
  18. I.seeElement('[name="root[1]"]');
  19. I.seeElement('[name="root[2]"]');
  20. I.seeElement('[name="root[3]"]');
  21. I.seeElement('[name="root[4]"]');
  22. I.fillField('[name="root[0]"]', "1");
  23. I.fillField('[name="root[1]"]', "2");
  24. I.fillField('[name="root[2]"]', "3");
  25. I.fillField('[name="root[3]"]', "4");
  26. I.fillField('[name="root[4]"]', "5");
  27. I.click('.get-value');
  28. value = await I.grabValueFrom('.debug');
  29. assert.equal(value, '["1","2","3","4","5"]');
  30. // shuffle
  31. I.click('.moveup[data-i="4"]');
  32. I.click('.moveup[data-i="2"]');
  33. I.click('.moveup[data-i="1"]');
  34. I.click('.get-value');
  35. value = await I.grabValueFrom('.debug');
  36. assert.equal(value, '["3","1","2","5","4"]');
  37. // delete single
  38. I.see('String 5');
  39. I.click('[data-schemapath="root.4"] .delete');
  40. I.seeInPopup('Are you sure you want to remove this node?');
  41. I.cancelPopup();
  42. I.see('String 5');
  43. I.click('[data-schemapath="root.4"] .delete');
  44. I.seeInPopup('Are you sure you want to remove this node?');
  45. I.acceptPopup();
  46. I.dontSee('String 5');
  47. // delete last
  48. I.see('String 4');
  49. I.click('Delete Last String');
  50. I.seeInPopup('Are you sure you want to remove this node?');
  51. I.cancelPopup();
  52. I.see('String 4');
  53. I.click('Delete Last String');
  54. I.seeInPopup('Are you sure you want to remove this node?');
  55. I.acceptPopup();
  56. I.dontSee('String 4');
  57. // delete all
  58. I.see('String 1');
  59. I.see('String 2');
  60. I.see('String 3');
  61. I.click('Delete All');
  62. I.seeInPopup('Are you sure you want to remove this node?');
  63. I.cancelPopup();
  64. I.see('String 1');
  65. I.see('String 2');
  66. I.see('String 3');
  67. I.click('Delete All');
  68. I.seeInPopup('Are you sure you want to remove this node?');
  69. I.acceptPopup();
  70. I.dontSee('String 1');
  71. I.dontSee('String 2');
  72. I.dontSee('String 3');
  73. });
  74. Scenario('should work well with number editors', async (I) => {
  75. I.amOnPage('array-numbers.html');
  76. I.click('Add Number');
  77. I.click('Add Number');
  78. I.click('Add Number');
  79. I.click('Add Number');
  80. I.click('Add Number');
  81. I.seeElement('[name="root[0]"]');
  82. I.seeElement('[name="root[1]"]');
  83. I.seeElement('[name="root[2]"]');
  84. I.seeElement('[name="root[3]"]');
  85. I.seeElement('[name="root[4]"]');
  86. I.fillField('[name="root[0]"]', "1");
  87. I.fillField('[name="root[1]"]', "2");
  88. I.fillField('[name="root[2]"]', "3");
  89. I.fillField('[name="root[3]"]', "4");
  90. I.fillField('[name="root[4]"]', "5");
  91. I.click('.get-value');
  92. value = await I.grabValueFrom('.debug');
  93. assert.equal(value, '[1,2,3,4,5]');
  94. // shuffle
  95. I.click('.moveup[data-i="4"]');
  96. I.click('.moveup[data-i="2"]');
  97. I.click('.moveup[data-i="1"]');
  98. I.click('.get-value');
  99. value = await I.grabValueFrom('.debug');
  100. assert.equal(value, '[3,1,2,5,4]');
  101. // delete single
  102. I.see('Number 5');
  103. I.click('[data-schemapath="root.4"] .delete');
  104. I.seeInPopup('Are you sure you want to remove this node?');
  105. I.cancelPopup();
  106. I.see('Number 5');
  107. I.click('[data-schemapath="root.4"] .delete');
  108. I.seeInPopup('Are you sure you want to remove this node?');
  109. I.acceptPopup();
  110. I.dontSee('Number 5');
  111. // delete last
  112. I.see('Number 4');
  113. I.click('Delete Last Number');
  114. I.seeInPopup('Are you sure you want to remove this node?');
  115. I.cancelPopup();
  116. I.see('Number 4');
  117. I.click('Delete Last Number');
  118. I.seeInPopup('Are you sure you want to remove this node?');
  119. I.acceptPopup();
  120. I.dontSee('Number 4');
  121. // delete all
  122. I.see('Number 1');
  123. I.see('Number 2');
  124. I.see('Number 3');
  125. I.click('Delete All');
  126. I.seeInPopup('Are you sure you want to remove this node?');
  127. I.cancelPopup();
  128. I.see('Number 1');
  129. I.see('Number 2');
  130. I.see('Number 3');
  131. I.click('Delete All');
  132. I.seeInPopup('Are you sure you want to remove this node?');
  133. I.acceptPopup();
  134. I.dontSee('Number 1');
  135. I.dontSee('Number 2');
  136. I.dontSee('Number 3');
  137. });
  138. Scenario('should work well with integer editors', async (I) => {
  139. I.amOnPage('array-integers.html');
  140. I.click('Add Integer');
  141. I.click('Add Integer');
  142. I.click('Add Integer');
  143. I.click('Add Integer');
  144. I.click('Add Integer');
  145. I.seeElement('[name="root[0]"]');
  146. I.seeElement('[name="root[1]"]');
  147. I.seeElement('[name="root[2]"]');
  148. I.seeElement('[name="root[3]"]');
  149. I.seeElement('[name="root[4]"]');
  150. I.fillField('[name="root[0]"]', "1");
  151. I.fillField('[name="root[1]"]', "2");
  152. I.fillField('[name="root[2]"]', "3");
  153. I.fillField('[name="root[3]"]', "4");
  154. I.fillField('[name="root[4]"]', "5");
  155. I.click('.get-value');
  156. value = await I.grabValueFrom('.debug');
  157. assert.equal(value, '[1,2,3,4,5]');
  158. // shuffle
  159. I.click('.moveup[data-i="4"]');
  160. I.click('.moveup[data-i="2"]');
  161. I.click('.moveup[data-i="1"]');
  162. I.click('.get-value');
  163. value = await I.grabValueFrom('.debug');
  164. assert.equal(value, '[3,1,2,5,4]');
  165. // delete single
  166. I.see('Integer 5');
  167. I.click('[data-schemapath="root.4"] .delete');
  168. I.seeInPopup('Are you sure you want to remove this node?');
  169. I.cancelPopup();
  170. I.see('Integer 5');
  171. I.click('[data-schemapath="root.4"] .delete');
  172. I.seeInPopup('Are you sure you want to remove this node?');
  173. I.acceptPopup();
  174. I.dontSee('Integer 5');
  175. // delete last
  176. I.see('Integer 4');
  177. I.click('Delete Last Integer');
  178. I.seeInPopup('Are you sure you want to remove this node?');
  179. I.cancelPopup();
  180. I.see('Integer 4');
  181. I.click('Delete Last Integer');
  182. I.seeInPopup('Are you sure you want to remove this node?');
  183. I.acceptPopup();
  184. I.dontSee('Integer 4');
  185. // delete all
  186. I.see('Integer 1');
  187. I.see('Integer 2');
  188. I.see('Integer 3');
  189. I.click('Delete All');
  190. I.seeInPopup('Are you sure you want to remove this node?');
  191. I.cancelPopup();
  192. I.see('Integer 1');
  193. I.see('Integer 2');
  194. I.see('Integer 3');
  195. I.click('Delete All');
  196. I.seeInPopup('Are you sure you want to remove this node?');
  197. I.acceptPopup();
  198. I.dontSee('Integer 1');
  199. I.dontSee('Integer 2');
  200. I.dontSee('Integer 3');
  201. });
  202. Scenario('should work well with select editors', async (I) => {
  203. I.amOnPage('array-selects.html');
  204. I.click('Add Select');
  205. I.click('Add Select');
  206. I.seeElement('[name="root[0]"]');
  207. I.seeElement('[name="root[1]"]');
  208. I.selectOption('[name="root[0]"]', "true");
  209. I.selectOption('[name="root[1]"]', "false");
  210. I.click('.get-value');
  211. value = await I.grabValueFrom('.debug');
  212. assert.equal(value, '[true,false]');
  213. // shuffle
  214. I.click('.moveup[data-i="1"]');
  215. I.click('.get-value');
  216. value = await I.grabValueFrom('.debug');
  217. assert.equal(value, '[false,true]');
  218. // delete single
  219. I.click('Add Select');
  220. I.click('Add Select');
  221. I.click('Add Select');
  222. I.see('Select 5');
  223. I.click('[data-schemapath="root.4"] .delete');
  224. I.seeInPopup('Are you sure you want to remove this node?');
  225. I.cancelPopup();
  226. I.see('Select 5');
  227. I.click('[data-schemapath="root.4"] .delete');
  228. I.seeInPopup('Are you sure you want to remove this node?');
  229. I.acceptPopup();
  230. I.dontSee('Select 5');
  231. // delete last
  232. I.see('Select 4');
  233. I.click('Delete Last Select');
  234. I.seeInPopup('Are you sure you want to remove this node?');
  235. I.cancelPopup();
  236. I.see('Select 4');
  237. I.click('Delete Last Select');
  238. I.seeInPopup('Are you sure you want to remove this node?');
  239. I.acceptPopup();
  240. I.dontSee('Select 4');
  241. // delete all
  242. I.see('Select 1');
  243. I.see('Select 2');
  244. I.see('Select 3');
  245. I.click('Delete All');
  246. I.seeInPopup('Are you sure you want to remove this node?');
  247. I.cancelPopup();
  248. I.see('Select 1');
  249. I.see('Select 2');
  250. I.see('Select 3');
  251. I.click('Delete All');
  252. I.seeInPopup('Are you sure you want to remove this node?');
  253. I.acceptPopup();
  254. I.dontSee('Select 1');
  255. I.dontSee('Select 2');
  256. I.dontSee('Select 3');
  257. });
  258. Scenario('should work well with checkbox editors', async (I) => {
  259. I.amOnPage('array-checkboxes.html');
  260. I.click('Add Checkbox');
  261. I.click('Add Checkbox');
  262. I.click('Add Checkbox');
  263. I.click('Add Checkbox');
  264. I.click('Add Checkbox');
  265. I.seeElement('[data-schemapath="root.0"]');
  266. I.seeElement('[data-schemapath="root.1"]');
  267. I.seeElement('[data-schemapath="root.2"]');
  268. I.seeElement('[data-schemapath="root.3"]');
  269. I.seeElement('[data-schemapath="root.4"]');
  270. I.checkOption('1', '[data-schemapath="root.0"]');
  271. I.checkOption('2', '[data-schemapath="root.1"]');
  272. I.checkOption('3', '[data-schemapath="root.2"]');
  273. I.checkOption('4', '[data-schemapath="root.3"]');
  274. I.checkOption('5', '[data-schemapath="root.4"]');
  275. I.click('.get-value');
  276. value = await I.grabValueFrom('.debug');
  277. assert.equal(value, '[["1"],["2"],["3"],["4"],["5"]]');
  278. // shuffle
  279. I.click('.moveup[data-i="4"]');
  280. I.click('.moveup[data-i="2"]');
  281. I.click('.moveup[data-i="1"]');
  282. I.click('.get-value');
  283. value = await I.grabValueFrom('.debug');
  284. assert.equal(value, '[["3"],["1"],["2"],["5"],["4"]]');
  285. // delete single
  286. I.see('Checkbox 5');
  287. I.click('[data-schemapath="root.4"] .delete');
  288. I.seeInPopup('Are you sure you want to remove this node?');
  289. I.cancelPopup();
  290. I.see('Checkbox 5');
  291. I.click('[data-schemapath="root.4"] .delete');
  292. I.seeInPopup('Are you sure you want to remove this node?');
  293. I.acceptPopup();
  294. I.dontSee('Checkbox 5');
  295. // delete last
  296. I.see('Checkbox 4');
  297. I.click('Delete Last Checkbox');
  298. I.seeInPopup('Are you sure you want to remove this node?');
  299. I.cancelPopup();
  300. I.see('Checkbox 4');
  301. I.click('Delete Last Checkbox');
  302. I.seeInPopup('Are you sure you want to remove this node?');
  303. I.acceptPopup();
  304. I.dontSee('Checkbox 4');
  305. // delete all
  306. I.see('Checkbox 1');
  307. I.see('Checkbox 2');
  308. I.see('Checkbox 3');
  309. I.click('Delete All');
  310. I.seeInPopup('Are you sure you want to remove this node?');
  311. I.cancelPopup();
  312. I.see('Checkbox 1');
  313. I.see('Checkbox 2');
  314. I.see('Checkbox 3');
  315. I.click('Delete All');
  316. I.seeInPopup('Are you sure you want to remove this node?');
  317. I.acceptPopup();
  318. I.dontSee('Checkbox 1');
  319. I.dontSee('Checkbox 2');
  320. I.dontSee('Checkbox 3');
  321. });
  322. Scenario('should work well with rating editors', async (I) => {
  323. I.amOnPage('array-ratings.html');
  324. I.seeElement('[data-schemapath="root.0"]');
  325. I.seeElement('[data-schemapath="root.1"]');
  326. I.seeElement('[data-schemapath="root.2"]');
  327. I.seeElement('[data-schemapath="root.3"]');
  328. I.seeElement('[data-schemapath="root.4"]');
  329. I.click('.get-value');
  330. value = await I.grabValueFrom('.debug');
  331. assert.equal(value, '[1,2,3,4,5]');
  332. // shuffle
  333. I.click('.moveup[data-i="4"]');
  334. I.click('.moveup[data-i="2"]');
  335. I.click('.moveup[data-i="1"]');
  336. I.click('.get-value');
  337. value = await I.grabValueFrom('.debug');
  338. assert.equal(value, '[3,1,2,5,4]');
  339. // delete single
  340. I.see('Rating 5');
  341. I.click('[data-schemapath="root.4"] .delete');
  342. I.seeInPopup('Are you sure you want to remove this node?');
  343. I.cancelPopup();
  344. I.see('Rating 5');
  345. I.click('[data-schemapath="root.4"] .delete');
  346. I.seeInPopup('Are you sure you want to remove this node?');
  347. I.acceptPopup();
  348. I.dontSee('Rating 5');
  349. // delete last
  350. I.see('Rating 4');
  351. I.click('Delete Last Rating');
  352. I.seeInPopup('Are you sure you want to remove this node?');
  353. I.cancelPopup();
  354. I.see('Rating 4');
  355. I.click('Delete Last Rating');
  356. I.seeInPopup('Are you sure you want to remove this node?');
  357. I.acceptPopup();
  358. I.dontSee('Rating 4');
  359. // delete all
  360. I.see('Rating 1');
  361. I.see('Rating 2');
  362. I.see('Rating 3');
  363. I.click('Delete All');
  364. I.seeInPopup('Are you sure you want to remove this node?');
  365. I.cancelPopup();
  366. I.see('Rating 1');
  367. I.see('Rating 2');
  368. I.see('Rating 3');
  369. I.click('Delete All');
  370. I.seeInPopup('Are you sure you want to remove this node?');
  371. I.acceptPopup();
  372. I.dontSee('Rating 1');
  373. I.dontSee('Rating 2');
  374. I.dontSee('Rating 3');
  375. });
  376. Scenario('should work well with multiselect editors', async (I) => {
  377. I.amOnPage('array-multiselects.html');
  378. I.click('Add Multiselect');
  379. I.click('Add Multiselect');
  380. I.click('Add Multiselect');
  381. I.click('Add Multiselect');
  382. I.click('Add Multiselect');
  383. I.seeElement('[data-schemapath="root.0"]');
  384. I.seeElement('[data-schemapath="root.1"]');
  385. I.seeElement('[data-schemapath="root.2"]');
  386. I.seeElement('[data-schemapath="root.3"]');
  387. I.seeElement('[data-schemapath="root.4"]');
  388. I.selectOption('[name="root[0]"]', "1");
  389. I.selectOption('[name="root[1]"]', "2");
  390. I.selectOption('[name="root[2]"]', "3");
  391. I.selectOption('[name="root[3]"]', "4");
  392. I.selectOption('[name="root[4]"]', "5");
  393. I.click('.get-value');
  394. value = await I.grabValueFrom('.debug');
  395. assert.equal(value, '[["1"],["2"],["3"],["4"],["5"]]');
  396. // shuffle
  397. I.click('.moveup[data-i="4"]');
  398. I.click('.moveup[data-i="2"]');
  399. I.click('.moveup[data-i="1"]');
  400. I.click('.get-value');
  401. value = await I.grabValueFrom('.debug');
  402. assert.equal(value, '[["3"],["1"],["2"],["5"],["4"]]');
  403. // delete single
  404. I.see('Multiselect 5');
  405. I.click('[data-schemapath="root.4"] .delete');
  406. I.seeInPopup('Are you sure you want to remove this node?');
  407. I.cancelPopup();
  408. I.see('Multiselect 5');
  409. I.click('[data-schemapath="root.4"] .delete');
  410. I.seeInPopup('Are you sure you want to remove this node?');
  411. I.acceptPopup();
  412. I.dontSee('Multiselect 5');
  413. // delete last
  414. I.see('Multiselect 4');
  415. I.click('Delete Last Multiselect');
  416. I.seeInPopup('Are you sure you want to remove this node?');
  417. I.cancelPopup();
  418. I.see('Multiselect 4');
  419. I.click('Delete Last Multiselect');
  420. I.seeInPopup('Are you sure you want to remove this node?');
  421. I.acceptPopup();
  422. I.dontSee('Multiselect 4');
  423. // delete all
  424. I.see('Multiselect 1');
  425. I.see('Multiselect 2');
  426. I.see('Multiselect 3');
  427. I.click('Delete All');
  428. I.seeInPopup('Are you sure you want to remove this node?');
  429. I.cancelPopup();
  430. I.see('Multiselect 1');
  431. I.see('Multiselect 2');
  432. I.see('Multiselect 3');
  433. I.click('Delete All');
  434. I.seeInPopup('Are you sure you want to remove this node?');
  435. I.acceptPopup();
  436. I.dontSee('Multiselect 1');
  437. I.dontSee('Multiselect 2');
  438. I.dontSee('Multiselect 3');
  439. });
  440. Scenario('should work well with object editors', async (I) => {
  441. I.amOnPage('array-objects.html');
  442. I.click('Add Object');
  443. I.click('Add Object');
  444. I.click('Add Object');
  445. I.click('Add Object');
  446. I.click('Add Object');
  447. I.seeElement('[name="root[0][property]"]');
  448. I.seeElement('[name="root[1][property]"]');
  449. I.seeElement('[name="root[2][property]"]');
  450. I.seeElement('[name="root[3][property]"]');
  451. I.seeElement('[name="root[4][property]"]');
  452. I.fillField('[name="root[0][property]"]', "1");
  453. I.fillField('[name="root[1][property]"]', "2");
  454. I.fillField('[name="root[2][property]"]', "3");
  455. I.fillField('[name="root[3][property]"]', "4");
  456. I.fillField('[name="root[4][property]"]', "5");
  457. I.click('.get-value');
  458. value = await I.grabValueFrom('.debug');
  459. assert.equal(value, '[{"property":"1"},{"property":"2"},{"property":"3"},{"property":"4"},{"property":"5"}]');
  460. // shuffle
  461. I.click('.moveup[data-i="4"]');
  462. I.click('.moveup[data-i="2"]');
  463. I.click('.moveup[data-i="1"]');
  464. I.click('.get-value');
  465. value = await I.grabValueFrom('.debug');
  466. assert.equal(value, '[{"property":"3"},{"property":"1"},{"property":"2"},{"property":"5"},{"property":"4"}]');
  467. // delete single
  468. I.see('Object 5');
  469. I.click('[data-schemapath="root.4"] .delete');
  470. I.seeInPopup('Are you sure you want to remove this node?');
  471. I.cancelPopup();
  472. I.see('Object 5');
  473. I.click('[data-schemapath="root.4"] .delete');
  474. I.seeInPopup('Are you sure you want to remove this node?');
  475. I.acceptPopup();
  476. I.dontSee('Object 5');
  477. // delete last
  478. I.see('Object 4');
  479. I.click('Delete Last Object');
  480. I.seeInPopup('Are you sure you want to remove this node?');
  481. I.cancelPopup();
  482. I.see('Object 4');
  483. I.click('Delete Last Object');
  484. I.seeInPopup('Are you sure you want to remove this node?');
  485. I.acceptPopup();
  486. I.dontSee('Object 4');
  487. // delete all
  488. I.see('Object 1');
  489. I.see('Object 2');
  490. I.see('Object 3');
  491. I.click('Delete All');
  492. I.seeInPopup('Are you sure you want to remove this node?');
  493. I.cancelPopup();
  494. I.see('Object 1');
  495. I.see('Object 2');
  496. I.see('Object 3');
  497. I.click('Delete All');
  498. I.seeInPopup('Are you sure you want to remove this node?');
  499. I.acceptPopup();
  500. I.dontSee('Object 1');
  501. I.dontSee('Object 2');
  502. I.dontSee('Object 3');
  503. });
  504. Scenario('should work well with nested array editors', async (I) => {
  505. I.amOnPage('array-nested-arrays.html');
  506. I.click('Add Array');
  507. I.click('Add Array');
  508. I.click('Add Array');
  509. I.click('Add Array');
  510. I.click('Add Array');
  511. I.seeElement('[data-schemapath="root.0"]');
  512. I.seeElement('[data-schemapath="root.1"]');
  513. I.seeElement('[data-schemapath="root.2"]');
  514. I.seeElement('[data-schemapath="root.3"]');
  515. I.seeElement('[data-schemapath="root.4"]');
  516. I.click('.get-value');
  517. value = await I.grabValueFrom('.debug');
  518. assert.equal(value, '[[],[],[],[],[]]');
  519. // adds one string editor in each first level array
  520. for (i = 0; i < 5; i++) {
  521. I.click('Add String', '[data-schemapath="root.' + i + '"]');
  522. I.fillField('[data-schemapath="root.' + i + '"] [name="root[' + i + '][0]"]', String(i + 1));
  523. }
  524. I.click('.get-value');
  525. value = await I.grabValueFrom('.debug');
  526. assert.equal(value, '[["1"],["2"],["3"],["4"],["5"]]');
  527. // shuffle
  528. I.click('.moveup[data-i="4"]');
  529. I.click('.moveup[data-i="2"]');
  530. I.click('.moveup[data-i="1"]');
  531. I.click('.get-value');
  532. value = await I.grabValueFrom('.debug');
  533. assert.equal(value, '[["3"],["1"],["2"],["5"],["4"]]');
  534. // delete single
  535. I.see('Array 5');
  536. I.click('[data-schemapath="root.4"] .delete');
  537. I.seeInPopup('Are you sure you want to remove this node?');
  538. I.cancelPopup();
  539. I.see('Array 5');
  540. I.click('[data-schemapath="root.4"] .delete');
  541. I.seeInPopup('Are you sure you want to remove this node?');
  542. I.acceptPopup();
  543. I.dontSee('Array 5');
  544. // delete last
  545. I.see('Array 4');
  546. I.click('Delete Last Array');
  547. I.seeInPopup('Are you sure you want to remove this node?');
  548. I.cancelPopup();
  549. I.see('Array 4');
  550. I.click('Delete Last Array');
  551. I.seeInPopup('Are you sure you want to remove this node?');
  552. I.acceptPopup();
  553. I.dontSee('Array 4');
  554. // delete all
  555. I.see('Array 1');
  556. I.see('Array 2');
  557. I.see('Array 3');
  558. // there are hidden "Delete All" buttons right now and "I.click(Delete All)"
  559. // will attempt to click the first match. It fails because is hidden.
  560. // this is why i use this script. is more flexible.
  561. I.executeScript(function() {
  562. var e = document.querySelectorAll('.json-editor-btn-delete');
  563. e[e.length - 1].click();
  564. });
  565. I.seeInPopup('Are you sure you want to remove this node?');
  566. I.cancelPopup();
  567. I.see('Array 1');
  568. I.see('Array 2');
  569. I.see('Array 3');
  570. I.executeScript(function() {
  571. var e = document.querySelectorAll('.json-editor-btn-delete');
  572. e[e.length - 1].click();
  573. });
  574. I.seeInPopup('Are you sure you want to remove this node?');
  575. I.acceptPopup();
  576. I.dontSee('Array 1');
  577. I.dontSee('Array 2');
  578. I.dontSee('Array 3');
  579. // manipulate nested items
  580. I.amOnPage('array-nested-arrays.html');
  581. I.click('Add Array');
  582. I.click('Add Array');
  583. I.click('Add Array');
  584. I.click('Add Array');
  585. I.click('Add Array');
  586. I.seeElement('[data-schemapath="root.0"]');
  587. I.seeElement('[data-schemapath="root.1"]');
  588. I.seeElement('[data-schemapath="root.2"]');
  589. I.click('.get-value');
  590. value = await I.grabValueFrom('.debug');
  591. assert.equal(value, '[[],[],[],[],[]]');
  592. // adds one string editor in each first level array
  593. for (i = 0; i < 5; i++) {
  594. I.click('Add String', '[data-schemapath="root.' + i + '"]');
  595. I.click('Add String', '[data-schemapath="root.' + i + '"]');
  596. I.click('Add String', '[data-schemapath="root.' + i + '"]');
  597. I.click('Add String', '[data-schemapath="root.' + i + '"]');
  598. I.click('Add String', '[data-schemapath="root.' + i + '"]');
  599. I.fillField('[data-schemapath="root.' + i + '"] [name="root[' + i + '][0]"]', "1");
  600. I.fillField('[data-schemapath="root.' + i + '"] [name="root[' + i + '][1]"]', "2");
  601. I.fillField('[data-schemapath="root.' + i + '"] [name="root[' + i + '][2]"]', "3");
  602. I.fillField('[data-schemapath="root.' + i + '"] [name="root[' + i + '][3]"]', "4");
  603. I.fillField('[data-schemapath="root.' + i + '"] [name="root[' + i + '][4]"]', "5");
  604. }
  605. I.click('.get-value');
  606. value = await I.grabValueFrom('.debug');
  607. assert.equal(value, '[["1","2","3","4","5"],["1","2","3","4","5"],["1","2","3","4","5"],["1","2","3","4","5"],["1","2","3","4","5"]]');
  608. // shuffle every strings array
  609. for (i = 0; i < 5; i++) {
  610. I.click('[data-schemapath="root.' + i + '.4"] .moveup');
  611. I.click('[data-schemapath="root.' + i + '.2"] .moveup');
  612. I.click('[data-schemapath="root.' + i + '.1"] .moveup');
  613. }
  614. I.click('.get-value');
  615. value = await I.grabValueFrom('.debug');
  616. assert.equal(value, '[["3","1","2","5","4"],["3","1","2","5","4"],["3","1","2","5","4"],["3","1","2","5","4"],["3","1","2","5","4"]]');
  617. // delete single (fifth) element from every string array
  618. for (i = 0; i < 5; i++) {
  619. I.see('String 5', '[data-schemapath="root.' + i + '"]');
  620. I.click('[data-schemapath="root.' + i + '.4"] .delete');
  621. I.seeInPopup('Are you sure you want to remove this node?');
  622. I.cancelPopup();
  623. I.see('String 5', '[data-schemapath="root.' + i + '"]');
  624. I.click('[data-schemapath="root.' + i + '.4"] .delete');
  625. I.seeInPopup('Are you sure you want to remove this node?');
  626. I.acceptPopup();
  627. I.dontSee('String 5', '[data-schemapath="root.' + i + '"]');
  628. }
  629. I.click('.get-value');
  630. value = await I.grabValueFrom('.debug');
  631. assert.equal(value, '[["3","1","2","5"],["3","1","2","5"],["3","1","2","5"],["3","1","2","5"],["3","1","2","5"]]');
  632. // delete last (fourth) element from every string array
  633. for (i = 0; i < 5; i++) {
  634. I.see('String 4', '[data-schemapath="root.' + i + '"]');
  635. I.click('Delete Last String', '[data-schemapath="root.' + i + '"]');
  636. I.seeInPopup('Are you sure you want to remove this node?');
  637. I.cancelPopup();
  638. I.see('String 4', '[data-schemapath="root.' + i + '"]');
  639. I.click('Delete Last String', '[data-schemapath="root.' + i + '"]');
  640. I.seeInPopup('Are you sure you want to remove this node?');
  641. I.acceptPopup();
  642. I.dontSee('String 4', '[data-schemapath="root.' + i + '"]');
  643. }
  644. I.click('.get-value');
  645. value = await I.grabValueFrom('.debug');
  646. assert.equal(value, '[["3","1","2"],["3","1","2"],["3","1","2"],["3","1","2"],["3","1","2"]]');
  647. // delete last (fourth) element from every string array
  648. for (i = 0; i < 5; i++) {
  649. I.see('String 1', '[data-schemapath="root.' + i + '"]');
  650. I.see('String 2', '[data-schemapath="root.' + i + '"]');
  651. I.see('String 3', '[data-schemapath="root.' + i + '"]');
  652. I.click('Delete All', '[data-schemapath="root.' + i + '"]');
  653. I.seeInPopup('Are you sure you want to remove this node?');
  654. I.cancelPopup();
  655. I.see('String 1', '[data-schemapath="root.' + i + '"]');
  656. I.see('String 2', '[data-schemapath="root.' + i + '"]');
  657. I.see('String 3', '[data-schemapath="root.' + i + '"]');
  658. I.click('Delete All', '[data-schemapath="root.' + i + '"]');
  659. I.seeInPopup('Are you sure you want to remove this node?');
  660. I.acceptPopup();
  661. I.dontSee('String 1', '[data-schemapath="root.' + i + '"]');
  662. I.dontSee('String 2', '[data-schemapath="root.' + i + '"]');
  663. I.dontSee('String 3', '[data-schemapath="root.' + i + '"]');
  664. }
  665. I.click('.get-value');
  666. value = await I.grabValueFrom('.debug');
  667. assert.equal(value, '[[],[],[],[],[]]');
  668. });