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.
 
 
 
 
 
 

93 regels
4.0 KiB

  1. context('Grid', () => {
  2. beforeEach(() => {
  3. cy.login();
  4. cy.visit('/app/website');
  5. });
  6. before(() => {
  7. cy.login();
  8. cy.visit('/app/website');
  9. return cy.window().its('frappe').then(frappe => {
  10. return frappe.call("frappe.tests.ui_test_helpers.create_contact_phone_nos_records");
  11. });
  12. });
  13. it('update docfield property using update_docfield_property', () => {
  14. cy.visit('/app/contact/Test Contact');
  15. cy.window().its("cur_frm").then(frm => {
  16. cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
  17. let field = frm.get_field("phone_nos");
  18. field.grid.update_docfield_property("is_primary_phone", "hidden", true);
  19. cy.get('@table').find('[data-idx="1"] .edit-grid-row').click();
  20. cy.get('.grid-row-open').as('table-form');
  21. cy.get('@table-form').find('.frappe-control[data-fieldname="is_primary_phone"]').should("be.hidden");
  22. cy.get('@table-form').find('.grid-footer-toolbar').click();
  23. cy.get('@table').find('[data-idx="2"] .edit-grid-row').click();
  24. cy.get('.grid-row-open').as('table-form');
  25. cy.get('@table-form').find('.frappe-control[data-fieldname="is_primary_phone"]').should("be.hidden");
  26. cy.get('@table-form').find('.grid-footer-toolbar').click();
  27. });
  28. });
  29. it('update docfield property using toggle_display', () => {
  30. cy.visit('/app/contact/Test Contact');
  31. cy.window().its("cur_frm").then(frm => {
  32. cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
  33. let field = frm.get_field("phone_nos");
  34. field.grid.toggle_display("is_primary_mobile_no", false);
  35. cy.get('@table').find('[data-idx="1"] .edit-grid-row').click();
  36. cy.get('.grid-row-open').as('table-form');
  37. cy.get('@table-form').find('.frappe-control[data-fieldname="is_primary_mobile_no"]').should("be.hidden");
  38. cy.get('@table-form').find('.grid-footer-toolbar').click();
  39. cy.get('@table').find('[data-idx="2"] .edit-grid-row').click();
  40. cy.get('.grid-row-open').as('table-form');
  41. cy.get('@table-form').find('.frappe-control[data-fieldname="is_primary_mobile_no"]').should("be.hidden");
  42. cy.get('@table-form').find('.grid-footer-toolbar').click();
  43. });
  44. });
  45. it('update docfield property using toggle_enable', () => {
  46. cy.visit('/app/contact/Test Contact');
  47. cy.window().its("cur_frm").then(frm => {
  48. cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
  49. let field = frm.get_field("phone_nos");
  50. field.grid.toggle_enable("phone", false);
  51. cy.get('@table').find('[data-idx="1"] .edit-grid-row').click();
  52. cy.get('.grid-row-open').as('table-form');
  53. cy.get('@table-form').find('.frappe-control[data-fieldname="phone"] .control-value').should('have.class', 'like-disabled-input');
  54. cy.get('@table-form').find('.grid-footer-toolbar').click();
  55. cy.get('@table').find('[data-idx="2"] .edit-grid-row').click();
  56. cy.get('.grid-row-open').as('table-form');
  57. cy.get('@table-form').find('.frappe-control[data-fieldname="phone"] .control-value').should('have.class', 'like-disabled-input');
  58. cy.get('@table-form').find('.grid-footer-toolbar').click();
  59. });
  60. });
  61. it('update docfield property using toggle_reqd', () => {
  62. cy.visit('/app/contact/Test Contact');
  63. cy.window().its("cur_frm").then(frm => {
  64. cy.get('.frappe-control[data-fieldname="phone_nos"]').as('table');
  65. let field = frm.get_field("phone_nos");
  66. field.grid.toggle_reqd("phone", false);
  67. cy.get('@table').find('[data-idx="1"] .edit-grid-row').click();
  68. cy.get('.grid-row-open').as('table-form');
  69. cy.get_field("phone").as('phone-field');
  70. cy.get('@phone-field').focus().clear().wait(500).blur();
  71. cy.get('@phone-field').should("not.have.class", "has-error");
  72. cy.get('@table-form').find('.grid-footer-toolbar').click();
  73. cy.get('@table').find('[data-idx="2"] .edit-grid-row').click();
  74. cy.get('.grid-row-open').as('table-form');
  75. cy.get_field("phone").as('phone-field');
  76. cy.get('@phone-field').focus().clear().wait(500).blur();
  77. cy.get('@phone-field').should("not.have.class", "has-error");
  78. cy.get('@table-form').find('.grid-footer-toolbar').click();
  79. });
  80. });
  81. });