string-sceditor_test.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. var assert = require('assert');
  2. var value = '';
  3. Feature('string-sceditor');
  4. Scenario('should have correct initial value', async (I) => {
  5. I.amOnPage('string-sceditor.html');
  6. I.click('.get-value');
  7. value = await I.grabValueFrom('.debug');
  8. assert.equal(value, '[]');
  9. });
  10. Scenario('editor value and String editor should have coerent values', async (I) => {
  11. I.amOnPage('string-sceditor.html');
  12. I.click('Add item');
  13. I.see('item 1');
  14. // enters first iframe, writes text on the body and then exits
  15. I.switchTo('[data-schemapath="root.0.editor"] iframe');
  16. I.click('body');
  17. I.pressKey('__YELLOW__');
  18. I.see('__YELLOW__');
  19. I.switchTo();
  20. I.click('.get-value');
  21. value = await I.grabValueFrom('.debug');
  22. assert.equal(value, JSON.stringify([{"editor":"<p>__YELLOW__<br></p>"}]));
  23. });
  24. Scenario('Should have values ordered in the same order as the array ', async (I) => {
  25. I.amOnPage('string-sceditor.html');
  26. I.click('Add item');
  27. I.click('Add item');
  28. I.see('item 1');
  29. I.see('item 2');
  30. // enters first iframe, writes text on the body and then exits
  31. I.switchTo('[data-schemapath="root.0.editor"] iframe');
  32. I.click('body');
  33. I.pressKey('__YELLOW__');
  34. I.see('__YELLOW__');
  35. I.switchTo();
  36. // enters secod iframe, writes text on the body and then exits
  37. I.switchTo('[data-schemapath="root.1.editor"] iframe');
  38. I.click('body');
  39. I.pressKey('__BLUE__');
  40. I.see('__BLUE__');
  41. I.switchTo();
  42. I.click('.get-value');
  43. value = await I.grabValueFrom('.debug');
  44. assert.equal(value, JSON.stringify([{"editor":"<p>__YELLOW__<br></p>"},{"editor":"<p>__BLUE__<br></p>"}]));
  45. I.click('.json-editor-btn-movedown');
  46. I.click('.get-value');
  47. value = await I.grabValueFrom('.debug');
  48. assert.equal(value, JSON.stringify([{"editor":"<p>__BLUE__<br></p>"},{"editor":"<p>__YELLOW__<br></p>"}]));
  49. });