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.
 
 
 
 
 
 

39 regels
1.3 KiB

  1. import data_field_validation_doctype from '../fixtures/data_field_validation_doctype';
  2. const doctype_name = data_field_validation_doctype.name;
  3. context('Data Field Input Validation in New Form', () => {
  4. before(() => {
  5. cy.login();
  6. cy.visit('/app/website');
  7. return cy.insert_doc('DocType', data_field_validation_doctype, true);
  8. });
  9. function validateField(fieldname, invalid_value, valid_value) {
  10. // Invalid, should have has-error class
  11. cy.get_field(fieldname).type(invalid_value).blur();
  12. cy.get(`.frappe-control[data-fieldname="${fieldname}"]`).should('have.class', 'has-error');
  13. // Valid value, should not have has-error class
  14. cy.get_field(fieldname).clear().type(valid_value);
  15. cy.get(`.frappe-control[data-fieldname="${fieldname}"]`).should('not.have.class', 'has-error');
  16. }
  17. describe('Data Field Options', () => {
  18. it('should validate email address', () => {
  19. cy.new_form(doctype_name);
  20. validateField('email', 'captian', 'hello@test.com');
  21. });
  22. it('should validate URL', () => {
  23. validateField('url', 'jkl', 'https://frappe.io');
  24. });
  25. it('should validate phone number', () => {
  26. validateField('phone', 'america', '89787878');
  27. });
  28. it('should validate name', () => {
  29. validateField('person_name', ' 777Hello', 'James Bond');
  30. });
  31. });
  32. });