core_test.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var assert = require('assert');
  2. var value = '';
  3. Feature('core');
  4. Scenario('should Disable and enable entire form', async (I) => {
  5. I.amOnPage('core.html');
  6. I.seeElement('[data-schemapath="root.name"] input');
  7. I.seeElement('[data-schemapath="root.age"] input');
  8. I.click('disable');
  9. I.seeElement('[data-schemapath="root.age"] input:disabled');
  10. I.seeElement('[data-schemapath="root.name"] input:disabled');
  11. I.click('enable');
  12. I.seeElement('[data-schemapath="root.age"] input:not(:disabled)');
  13. I.seeElement('[data-schemapath="root.name"] input:not(:disabled)');
  14. });
  15. Scenario('should Disable and enable part of the form', async (I) => {
  16. I.amOnPage('core.html');
  17. I.seeElement('[data-schemapath="root.name"] input');
  18. I.seeElement('[data-schemapath="root.age"] input');
  19. I.click('disable part');
  20. I.seeElement('[data-schemapath="root.name"] input:disabled');
  21. I.click('enable part');
  22. I.seeElement('[data-schemapath="root.name"] input:not(:disabled)');
  23. });
  24. Scenario('should destroy', async (I) => {
  25. I.amOnPage('core.html');
  26. I.seeElement('[data-schemapath="root"]');
  27. I.click('destroy');
  28. I.dontSeeElement('[data-schemapath="root"]');
  29. });
  30. Scenario('should set and get form value', async (I) => {
  31. I.amOnPage('core.html');
  32. I.click('.get-value');
  33. value = await I.grabValueFrom('.value');
  34. assert.equal(value, '{"age":18,"name":"Francesco Avizzano"}');
  35. I.click('.set-value');
  36. I.click('.get-value');
  37. value = await I.grabValueFrom('.value');
  38. assert.equal(value, '{"age":40,"name":"John Smith"}');
  39. });
  40. Scenario('should set and get individual values', async (I) => {
  41. I.amOnPage('core.html');
  42. I.click('.get-individual-value');
  43. value = await I.grabValueFrom('.value');
  44. assert.equal(value, '"Francesco Avizzano"');
  45. I.click('.set-individual-value');
  46. value = await I.grabValueFrom('.value');
  47. assert.equal(value, '"john kaminski"');
  48. });
  49. Scenario('should watch a specific field for changes', async (I) => {
  50. I.amOnPage('core.html');
  51. I.dontSeeElement('.name-changed');
  52. I.click('.set-individual-value');
  53. I.seeElement('.name-changed');
  54. });
  55. Scenario('should watch form for changes @optional', async (I) => {
  56. I.amOnPage('core.html');
  57. I.dontSeeElement('.form-changed');
  58. I.click('.set-value');
  59. I.seeElement('.form-changed');
  60. });