You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 line
2.9 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.fill_field('description', 'this is a test todo', 'Text Editor');
  12. cy.wait(300);
  13. cy.get('.page-title').should('contain', 'Not Saved');
  14. cy.intercept({
  15. method: 'POST',
  16. url: 'api/method/frappe.desk.form.save.savedocs'
  17. }).as('form_save');
  18. cy.get('.primary-action').click();
  19. cy.wait('@form_save').its('response.statusCode').should('eq', 200);
  20. cy.visit('/app/todo');
  21. cy.get('.title-text').should('be.visible').and('contain', 'To Do');
  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.add_filter();
  27. cy.get('.filter-field .input-with-feedback.form-control').type('123', { force: true });
  28. cy.get('.filter-popover .apply-filters').click({ force: true });
  29. cy.visit('/app/contact/Test Form Contact 3');
  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('.next-doc').click();
  34. cy.wait(200);
  35. cy.hide_dialog();
  36. cy.contains('Test Form Contact 2').should('not.exist');
  37. cy.get('.title-text').should('contain', 'Test Form Contact 3');
  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. });