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.
 
 
 
 
 
 

60 lines
2.2 KiB

  1. context('Depends On', () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit('/app#workspace/Website');
  5. return cy.window().its('frappe').then(frappe => {
  6. return frappe.call('frappe.tests.ui_test_helpers.create_doctype', {
  7. name: 'Test Depends On',
  8. fields: [
  9. {
  10. "label": "Test Field",
  11. "fieldname": "test_field",
  12. "fieldtype": "Data",
  13. },
  14. {
  15. "label": "Dependant Field",
  16. "fieldname": "dependant_field",
  17. "fieldtype": "Data",
  18. "mandatory_depends_on": "eval:doc.test_field=='Some Value'",
  19. "read_only_depends_on": "eval:doc.test_field=='Some Other Value'",
  20. },
  21. {
  22. "label": "Display Dependant Field",
  23. "fieldname": "display_dependant_field",
  24. "fieldtype": "Data",
  25. 'depends_on': "eval:doc.test_field=='Value'"
  26. },
  27. ]
  28. });
  29. });
  30. });
  31. it('should set the field as mandatory depending on other fields value', () => {
  32. cy.new_form('Test Depends On');
  33. cy.fill_field('test_field', 'Some Value');
  34. cy.get('button.primary-action').contains('Save').click();
  35. cy.get('.msgprint-dialog .modal-title').contains('Missing Fields').should('be.visible');
  36. cy.get('body').click();
  37. cy.fill_field('test_field', 'Random value');
  38. cy.get('button.primary-action').contains('Save').click();
  39. cy.get('.msgprint-dialog .modal-title').contains('Missing Fields').should('not.be.visible');
  40. });
  41. it('should set the field as read only depending on other fields value', () => {
  42. cy.new_form('Test Depends On');
  43. cy.fill_field('dependant_field', 'Some Value');
  44. cy.fill_field('test_field', 'Some Other Value');
  45. cy.get('body').click();
  46. cy.get('.control-input [data-fieldname="dependant_field"]').should('be.disabled');
  47. cy.fill_field('test_field', 'Random Value');
  48. cy.get('body').click();
  49. cy.get('.control-input [data-fieldname="dependant_field"]').should('not.be.disabled');
  50. });
  51. it('should display the field depending on other fields value', () => {
  52. cy.new_form('Test Depends On');
  53. cy.get('.control-input [data-fieldname="display_dependant_field"]').should('not.be.visible');
  54. cy.get('.control-input [data-fieldname="test_field"]').clear();
  55. cy.fill_field('test_field', 'Value');
  56. cy.get('body').click();
  57. cy.get('.control-input [data-fieldname="display_dependant_field"]').should('be.visible');
  58. });
  59. });