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.
 
 
 
 
 
 

99 lines
2.6 KiB

  1. context('MultiSelectDialog', () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit('/app');
  5. const contact_template = {
  6. "doctype": "Contact",
  7. "first_name": "Test",
  8. "status": "Passive",
  9. "email_ids": [
  10. {
  11. "doctype": "Contact Email",
  12. "email_id": "test@example.com",
  13. "is_primary": 0
  14. }
  15. ]
  16. };
  17. const promises = Array.from({length: 25})
  18. .map(() => cy.insert_doc('Contact', contact_template, true));
  19. Promise.all(promises);
  20. });
  21. function open_multi_select_dialog() {
  22. cy.window().its('frappe').then(frappe => {
  23. new frappe.ui.form.MultiSelectDialog({
  24. doctype: "Contact",
  25. target: {},
  26. setters: {
  27. status: null,
  28. gender: null
  29. },
  30. add_filters_group: 1,
  31. allow_child_item_selection: 1,
  32. child_fieldname: "email_ids",
  33. child_columns: ["email_id", "is_primary"]
  34. });
  35. });
  36. }
  37. it('checks multi select dialog api works', () => {
  38. open_multi_select_dialog();
  39. cy.get_open_dialog().should('contain', 'Select Contacts');
  40. });
  41. it('checks for filters', () => {
  42. ['search_term', 'status', 'gender'].forEach(fieldname => {
  43. cy.get_open_dialog().get(`.frappe-control[data-fieldname="${fieldname}"]`).should('exist');
  44. });
  45. // add_filters_group: 1 should add a filter group
  46. cy.get_open_dialog().get(`.frappe-control[data-fieldname="filter_area"]`).should('exist');
  47. });
  48. it('checks for child item selection', () => {
  49. cy.get_open_dialog()
  50. .get(`.dt-row-header`).should('not.exist');
  51. cy.get_open_dialog()
  52. .get(`.frappe-control[data-fieldname="allow_child_item_selection"]`)
  53. .find('input[data-fieldname="allow_child_item_selection"]')
  54. .should('exist')
  55. .click({force: true});
  56. cy.get_open_dialog()
  57. .get(`.frappe-control[data-fieldname="child_selection_area"]`)
  58. .should('exist');
  59. cy.get_open_dialog()
  60. .get(`.dt-row-header`).should('contain', 'Contact');
  61. cy.get_open_dialog()
  62. .get(`.dt-row-header`).should('contain', 'Email Id');
  63. cy.get_open_dialog()
  64. .get(`.dt-row-header`).should('contain', 'Is Primary');
  65. });
  66. it('tests more button', () => {
  67. cy.get_open_dialog()
  68. .get(`.frappe-control[data-fieldname="more_btn"]`)
  69. .should('exist')
  70. .as('more-btn');
  71. cy.get_open_dialog().get('.list-item-container').should(($rows) => {
  72. expect($rows).to.have.length(20);
  73. });
  74. cy.intercept('POST', 'api/method/frappe.client.get_list').as('get-more-records');
  75. cy.get('@more-btn').find('button').click({force: true});
  76. cy.wait('@get-more-records');
  77. cy.get_open_dialog().get('.list-item-container').should(($rows) => {
  78. if ($rows.length <= 20) {
  79. throw new Error("More button doesn't work");
  80. }
  81. });
  82. });
  83. });