string_test.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. var assert = require('assert');
  2. var value = '';
  3. Feature('string');
  4. Scenario('should have correct initial value', async (I) => {
  5. I.amOnPage('string-ace-editor.html');
  6. I.click('.get-value');
  7. value = await I.grabValueFrom('.debug');
  8. assert.equal(value, '[]');
  9. });
  10. Scenario('should have coerent values', async (I) => {
  11. I.amOnPage('string-ace-editor.html');
  12. I.click('Add item');
  13. I.see('item 1');
  14. I.seeElement('.ace_editor');
  15. I.click('.ace_editor');
  16. I.pressKey('__YELLOW__');
  17. I.see('__YELLOW__');
  18. I.click('.get-value');
  19. value = await I.grabValueFrom('.debug');
  20. assert.equal(value, JSON.stringify([{"editor":"__YELLOW__"}]));
  21. });
  22. Scenario('should have correct initial value', async (I) => {
  23. I.amOnPage('string-sceditor.html');
  24. I.click('.get-value');
  25. value = await I.grabValueFrom('.debug');
  26. assert.equal(value, '[]');
  27. });
  28. Scenario('editor value and String editor should have coerent values', async (I) => {
  29. I.amOnPage('string-sceditor.html');
  30. I.click('Add item');
  31. I.see('item 1');
  32. // enters first iframe, writes text on the body and then exits
  33. I.switchTo('[data-schemapath="root.0.editor"] iframe');
  34. I.click('body');
  35. I.pressKey('__YELLOW__');
  36. I.see('__YELLOW__');
  37. I.switchTo();
  38. I.click('.get-value');
  39. value = await I.grabValueFrom('.debug');
  40. assert.equal(value, JSON.stringify([{"editor":"<p>__YELLOW__<br></p>"}]));
  41. });
  42. Scenario('Should work correctly in arrays @optional', async (I) => {
  43. I.amOnPage('string-sceditor.html');
  44. I.click('Add item');
  45. I.click('Add item');
  46. I.see('item 1');
  47. I.see('item 2');
  48. // enters first iframe, writes text on the body and then exits
  49. I.switchTo('[data-schemapath="root.0.editor"] iframe');
  50. I.click('body');
  51. I.pressKey('__YELLOW__');
  52. I.see('__YELLOW__');
  53. I.switchTo();
  54. // enters first iframe and read text
  55. I.switchTo('[data-schemapath="root.0.editor"] iframe');
  56. I.see('__YELLOW__');
  57. I.switchTo();
  58. // enters secod iframe, writes text on the body and then exits
  59. I.switchTo('[data-schemapath="root.1.editor"] iframe');
  60. I.click('body');
  61. I.pressKey('__BLUE__');
  62. I.see('__BLUE__');
  63. I.switchTo();
  64. // enters second iframe and read text
  65. I.switchTo('[data-schemapath="root.1.editor"] iframe');
  66. I.see('__BLUE__');
  67. I.switchTo();
  68. I.click('.get-value');
  69. value = await I.grabValueFrom('.debug');
  70. assert.equal(value, JSON.stringify([{"editor":"<p>__YELLOW__<br></p>"},{"editor":"<p>__BLUE__<br></p>"}]));
  71. I.click('.json-editor-btn-movedown');
  72. I.click('.get-value');
  73. value = await I.grabValueFrom('.debug');
  74. assert.equal(value, JSON.stringify([{"editor":"<p>__BLUE__<br></p>"},{"editor":"<p>__YELLOW__<br></p>"}]));
  75. // the last 2 tests will fail because Sceditors iframes loose their content when the iframe is reloaded.
  76. // enters first iframe and read text
  77. I.switchTo('[data-schemapath="root.0.editor"] iframe');
  78. I.see('__BLUE__');
  79. I.switchTo();
  80. // enters second iframe and read text
  81. I.switchTo('[data-schemapath="root.1.editor"] iframe');
  82. I.see('__YELLOW__');
  83. I.switchTo();
  84. });
  85. Scenario('should be readonly if specified and not disabled', async (I) => {
  86. I.amOnPage('read-only.html');
  87. I.seeElement('[name="root[string]"]');
  88. value = await I.grabAttributeFrom('[name="root[string]"]', 'readonly');
  89. assert.equal(value, 'true');
  90. });