string-sceditor_test.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 work correctly in arrays @optional', 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 first iframe and read text
  37. I.switchTo('[data-schemapath="root.0.editor"] iframe');
  38. I.see('__YELLOW__');
  39. I.switchTo();
  40. // enters secod iframe, writes text on the body and then exits
  41. I.switchTo('[data-schemapath="root.1.editor"] iframe');
  42. I.click('body');
  43. I.pressKey('__BLUE__');
  44. I.see('__BLUE__');
  45. I.switchTo();
  46. // enters second iframe and read text
  47. I.switchTo('[data-schemapath="root.1.editor"] iframe');
  48. I.see('__BLUE__');
  49. I.switchTo();
  50. I.click('.get-value');
  51. value = await I.grabValueFrom('.debug');
  52. assert.equal(value, JSON.stringify([{"editor":"<p>__YELLOW__<br></p>"},{"editor":"<p>__BLUE__<br></p>"}]));
  53. I.click('.json-editor-btn-movedown');
  54. I.click('.get-value');
  55. value = await I.grabValueFrom('.debug');
  56. assert.equal(value, JSON.stringify([{"editor":"<p>__BLUE__<br></p>"},{"editor":"<p>__YELLOW__<br></p>"}]));
  57. // the last 2 tests will fail because Sceditors iframes loose their content when the iframe is reloaded.
  58. // enters first iframe and read text
  59. I.switchTo('[data-schemapath="root.0.editor"] iframe');
  60. I.see('__BLUE__');
  61. I.switchTo();
  62. // enters second iframe and read text
  63. I.switchTo('[data-schemapath="root.1.editor"] iframe');
  64. I.see('__YELLOW__');
  65. I.switchTo();
  66. });