Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

159 linhas
5.2 KiB

  1. context('Form', () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit('/app/website');
  5. return cy.window().its('frappe').then(frappe => {
  6. return frappe.call("frappe.tests.ui_test_helpers.create_contact_records");
  7. });
  8. });
  9. it('create a new form', () => {
  10. cy.visit('/app/todo/new');
  11. cy.get_field('description', 'Text Editor').type('this is a test todo', {force: true}).wait(200);
  12. cy.get('.page-title').should('contain', 'Not Saved');
  13. cy.intercept({
  14. method: 'POST',
  15. url: 'api/method/frappe.desk.form.save.savedocs'
  16. }).as('form_save');
  17. cy.get('.primary-action').click();
  18. cy.wait('@form_save').its('response.statusCode').should('eq', 200);
  19. cy.go_to_list('ToDo');
  20. cy.clear_filters()
  21. cy.get('.page-head').findByTitle('To Do').should('exist');
  22. cy.get('.list-row').should('contain', 'this is a test todo');
  23. });
  24. it('navigates between documents with child table list filters applied', () => {
  25. cy.visit('/app/contact');
  26. cy.clear_filters();
  27. cy.get('.standard-filter-section [data-fieldname="name"] input').type('Test Form Contact 3').blur();
  28. cy.click_listview_row_item_with_text('Test Form Contact 3');
  29. cy.get('#page-Contact .page-head').findByTitle('Test Form Contact 3').should('exist');
  30. cy.get('.prev-doc').should('be.visible').click();
  31. cy.get('.msgprint-dialog .modal-body').contains('No further records').should('be.visible');
  32. cy.hide_dialog();
  33. cy.get('#page-Contact .page-head').findByTitle('Test Form Contact 3').should('exist');
  34. cy.get('.next-doc').should('be.visible').click();
  35. cy.get('.msgprint-dialog .modal-body').contains('No further records').should('be.visible');
  36. cy.hide_dialog();
  37. cy.get('#page-Contact .page-head').findByTitle('Test Form Contact 3').should('exist');
  38. // clear filters
  39. cy.visit('/app/contact');
  40. cy.clear_filters();
  41. });
  42. it('validates behaviour of Data options validations in child table', () => {
  43. // test email validations for set_invalid controller
  44. let website_input = 'website.in';
  45. let valid_email = 'user@email.com';
  46. let expectBackgroundColor = 'rgb(255, 245, 245)';
  47. cy.visit('/app/contact/new');
  48. cy.get('.frappe-control[data-fieldname="email_ids"]').as('table');
  49. cy.get('@table').find('button.grid-add-row').click();
  50. cy.get('@table').find('button.grid-add-row').click();
  51. cy.get('@table').find('[data-idx="1"]').as('row1');
  52. cy.get('@table').find('[data-idx="2"]').as('row2');
  53. cy.get('@row1').click();
  54. cy.get('@row1').find('input.input-with-feedback.form-control').as('email_input1');
  55. cy.get('@email_input1').type(website_input, { waitForAnimations: false });
  56. cy.fill_field('company_name', 'Test Company');
  57. cy.get('@row2').click();
  58. cy.get('@row2').find('input.input-with-feedback.form-control').as('email_input2');
  59. cy.get('@email_input2').type(valid_email, { waitForAnimations: false });
  60. cy.get('@row1').click();
  61. cy.get('@email_input1').should($div => {
  62. const style = window.getComputedStyle($div[0]);
  63. expect(style.backgroundColor).to.equal(expectBackgroundColor);
  64. });
  65. cy.get('@email_input1').should('have.class', 'invalid');
  66. cy.get('@row2').click();
  67. cy.get('@email_input2').should('not.have.class', 'invalid');
  68. });
  69. it('Shows version conflict warning', { scrollBehavior: false }, () => {
  70. cy.visit('/app/todo');
  71. cy.insert_doc("ToDo", {"description": "old"}).then(doc => {
  72. cy.visit(`/app/todo/${doc.name}`);
  73. // make form dirty
  74. cy.fill_field("status", "Cancelled", "Select");
  75. // update doc using api - simulating parallel change by another user
  76. cy.update_doc("ToDo", doc.name, {"status": "Closed"}).then(() => {
  77. cy.findByRole("button", {name: "Refresh"}).click();
  78. cy.get_field("status", "Select").should("have.value", "Closed");
  79. })
  80. })
  81. });
  82. it('let user undo/redo field value changes', { scrollBehavior: false }, () => {
  83. const jump_to_field = (field_label) => {
  84. cy.get("body")
  85. .type("{esc}") // lose focus if any
  86. .type("{ctrl+j}") // jump to field
  87. .type(field_label)
  88. .wait(500)
  89. .type("{enter}")
  90. .wait(200)
  91. .type("{enter}")
  92. .wait(500);
  93. };
  94. const type_value = (value) => {
  95. cy.focused()
  96. .clear()
  97. .type(value)
  98. .type("{esc}");
  99. };
  100. const undo = () => cy.get("body").type("{esc}").type("{ctrl+z}").wait(500);
  101. const redo = () => cy.get("body").type("{esc}").type("{ctrl+y}").wait(500);
  102. cy.new_form('User');
  103. jump_to_field("Email");
  104. type_value("admin@example.com");
  105. jump_to_field("Username");
  106. type_value("admin42");
  107. jump_to_field("Birth Date");
  108. type_value("12-31-01");
  109. jump_to_field("Send Welcome Email");
  110. cy.focused().uncheck()
  111. // make a mistake
  112. jump_to_field("Username");
  113. type_value("admin24");
  114. // undo behaviour
  115. undo();
  116. cy.get_field("username").should('have.value', 'admin42');
  117. // redo behaviour
  118. redo();
  119. cy.get_field("username").should('have.value', 'admin24');
  120. // undo everything & redo everything, ensure same values at the end
  121. undo(); undo(); undo(); undo(); undo();
  122. redo(); redo(); redo(); redo(); redo();
  123. cy.get_field("username").should('have.value', 'admin24');
  124. cy.get_field("email").should('have.value', 'admin@example.com');
  125. cy.get_field("birth_date").should('have.value', '12-31-2001'); // parsed value
  126. cy.get_field("send_welcome_email").should('not.be.checked');
  127. });
  128. });