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.
 
 
 
 
 
 

135 lines
5.2 KiB

  1. context('Data Control', () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit('/app/doctype');
  5. return cy.window().its('frappe').then(frappe => {
  6. return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', {
  7. name: 'Test Data Control',
  8. fields: [
  9. {
  10. "label": "Name",
  11. "fieldname": "name1",
  12. "fieldtype": "Data",
  13. "options": "Name",
  14. "in_list_view": 1,
  15. "reqd": 1,
  16. },
  17. {
  18. "label": "Email-ID",
  19. "fieldname": "email",
  20. "fieldtype": "Data",
  21. "options": "Email",
  22. "in_list_view": 1,
  23. "reqd": 1,
  24. },
  25. {
  26. "label": "Phone No.",
  27. "fieldname": "phone",
  28. "fieldtype": "Data",
  29. "options": "Phone",
  30. "in_list_view": 1,
  31. "reqd": 1,
  32. },
  33. ]
  34. });
  35. });
  36. });
  37. it('check custom formatters', () => {
  38. cy.visit(`/app/doctype/User`);
  39. cy.get('[data-fieldname="fields"] .grid-row[data-idx="2"] [data-fieldname="fieldtype"] .static-area').should('have.text', '🔵 Section Break');
  40. });
  41. it('Verifying data control by inputting different patterns for "Name" field', () => {
  42. cy.new_form('Test Data Control');
  43. //Checking the URL for the new form of the doctype
  44. cy.location("pathname").should('eq', '/app/test-data-control/new-test-data-control-1');
  45. cy.get('.title-text').should('have.text', 'New Test Data Control');
  46. cy.get('.frappe-control[data-fieldname="name1"]').find('label').should('have.class', 'reqd');
  47. cy.get('.frappe-control[data-fieldname="email"]').find('label').should('have.class', 'reqd');
  48. cy.get('.frappe-control[data-fieldname="phone"]').find('label').should('have.class', 'reqd');
  49. //Checking if the status is "Not Saved" initially
  50. cy.get('.indicator-pill').should('have.text', 'Not Saved');
  51. //Inputting data in the field
  52. cy.fill_field('name1', '@@###', 'Data');
  53. cy.fill_field('email', 'test@example.com', 'Data');
  54. cy.fill_field('phone', '9834280031', 'Data');
  55. //Checking if the border color of the field changes to red
  56. cy.get('.frappe-control[data-fieldname="name1"]').should('have.class', 'has-error');
  57. cy.save();
  58. //Checking for the error message
  59. cy.get('.modal-title').should('have.text', 'Message');
  60. cy.get('.msgprint').should('have.text', '@@### is not a valid Name');
  61. cy.hide_dialog();
  62. cy.get_field('name1', 'Data').clear({force: true});
  63. cy.fill_field('name1', 'Komal{}/!', 'Data');
  64. cy.get('.frappe-control[data-fieldname="name1"]').should('have.class', 'has-error');
  65. cy.save();
  66. cy.get('.modal-title').should('have.text', 'Message');
  67. cy.get('.msgprint').should('have.text', 'Komal{}/! is not a valid Name');
  68. cy.hide_dialog();
  69. });
  70. it('Verifying data control by inputting different patterns for "Email" field', () => {
  71. cy.get_field('name1', 'Data').clear({force: true});
  72. cy.fill_field('name1', 'Komal', 'Data');
  73. cy.get_field('email', 'Data').clear({force: true});
  74. cy.fill_field('email', 'komal', 'Data');
  75. cy.get('.frappe-control[data-fieldname="email"]').should('have.class', 'has-error');
  76. cy.save();
  77. cy.get('.modal-title').should('have.text', 'Message');
  78. cy.get('.msgprint').should('have.text', 'komal is not a valid Email Address');
  79. cy.hide_dialog();
  80. cy.get_field('email', 'Data').clear({force: true});
  81. cy.fill_field('email', 'komal@test', 'Data');
  82. cy.get('.frappe-control[data-fieldname="email"]').should('have.class', 'has-error');
  83. cy.save();
  84. cy.get('.modal-title').should('have.text', 'Message');
  85. cy.get('.msgprint').should('have.text', 'komal@test is not a valid Email Address');
  86. cy.hide_dialog();
  87. });
  88. it('Verifying data control by inputting different patterns for "Phone" field', () => {
  89. cy.get_field('email', 'Data').clear({force: true});
  90. cy.fill_field('email', 'komal@test.com', 'Data');
  91. cy.get_field('phone', 'Data').clear({force: true});
  92. cy.fill_field('phone', 'komal', 'Data');
  93. cy.get('.frappe-control[data-fieldname="phone"]').should('have.class', 'has-error');
  94. cy.findByRole('button', {name: 'Save'}).click({force: true});
  95. cy.get('.modal-title').should('have.text', 'Message');
  96. cy.get('.msgprint').should('have.text', 'komal is not a valid Phone Number');
  97. cy.hide_dialog();
  98. });
  99. it('Inputting correct data and saving the doc', () => {
  100. //Inputting the data as expected and saving the document
  101. cy.get_field('name1', 'Data').clear({force: true});
  102. cy.get_field('email', 'Data').clear({force: true});
  103. cy.get_field('phone', 'Data').clear({force: true});
  104. cy.fill_field('name1', 'Komal', 'Data');
  105. cy.fill_field('email', 'komal@test.com', 'Data');
  106. cy.fill_field('phone', '9432380001', 'Data');
  107. cy.findByRole('button', {name: 'Save'}).click({force: true});
  108. //Checking if the fields contains the data which has been filled in
  109. cy.location("pathname").should('not.be', '/app/test-data-control/new-test-data-control-1');
  110. cy.get_field('name1').should('have.value', 'Komal');
  111. cy.get_field('email').should('have.value', 'komal@test.com');
  112. cy.get_field('phone').should('have.value', '9432380001');
  113. });
  114. it('Deleting the doc', () => {
  115. //Deleting the inserted document
  116. cy.go_to_list('Test Data Control');
  117. cy.get('.list-row-checkbox').eq(0).click({force: true});
  118. cy.get('.actions-btn-group > .btn').contains('Actions').click();
  119. cy.get('.actions-btn-group > .dropdown-menu [data-label="Delete"]').click();
  120. cy.click_modal_primary_button('Yes');
  121. });
  122. });