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.

dashboard_links.js 3.4 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import doctype_with_child_table from '../fixtures/doctype_with_child_table';
  2. import child_table_doctype from '../fixtures/child_table_doctype';
  3. import doctype_to_link from '../fixtures/doctype_to_link';
  4. const doctype_to_link_name = doctype_to_link.name;
  5. const child_table_doctype_name = child_table_doctype.name;
  6. context('Dashboard links', () => {
  7. before(() => {
  8. cy.visit('/login');
  9. cy.login();
  10. cy.insert_doc('DocType', child_table_doctype, true);
  11. cy.insert_doc('DocType', doctype_with_child_table, true);
  12. cy.insert_doc('DocType', doctype_to_link, true);
  13. return cy.window().its('frappe').then(frappe => {
  14. return frappe.xcall("frappe.tests.ui_test_helpers.update_child_table", {
  15. name: child_table_doctype_name
  16. });
  17. });
  18. });
  19. it('Adding a new contact, checking for the counter on the dashboard and deleting the created contact', () => {
  20. cy.visit('/app/contact');
  21. cy.clear_filters();
  22. cy.visit('/app/user');
  23. cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click({ force: true });
  24. //To check if initially the dashboard contains only the "Contact" link and there is no counter
  25. cy.get('[data-doctype="Contact"]').should('contain', 'Contact');
  26. //Adding a new contact
  27. cy.get('.document-link-badge[data-doctype="Contact"]').click();
  28. cy.wait(300);
  29. cy.findByRole('button', {name: 'Add Contact'}).should('be.visible');
  30. cy.findByRole('button', {name: 'Add Contact'}).click();
  31. cy.get('[data-doctype="Contact"][data-fieldname="first_name"]').type('Admin');
  32. cy.findByRole('button', {name: 'Save'}).click();
  33. cy.visit('/app/user');
  34. cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click({ force: true });
  35. //To check if the counter for contact doc is "1" after adding the contact
  36. cy.get('[data-doctype="Contact"] > .count').should('contain', '1');
  37. cy.get('[data-doctype="Contact"]').contains('Contact').click();
  38. //Deleting the newly created contact
  39. cy.visit('/app/contact');
  40. cy.get('.list-subject > .select-like > .list-row-checkbox').eq(0).click({ force: true });
  41. cy.findByRole('button', {name: 'Actions'}).click();
  42. cy.get('.actions-btn-group [data-label="Delete"]').click();
  43. cy.findByRole('button', {name: 'Yes'}).click({delay: 700});
  44. //To check if the counter from the "Contact" doc link is removed
  45. cy.wait(700);
  46. cy.visit('/app/user');
  47. cy.get('.list-row-col > .level-item > .ellipsis').eq(0).click({ force: true });
  48. cy.get('[data-doctype="Contact"]').should('contain', 'Contact');
  49. });
  50. it('Report link in dashboard', () => {
  51. cy.visit('/app/user');
  52. cy.visit('/app/user/Administrator');
  53. cy.get('[data-doctype="Contact"]').should('contain', 'Contact');
  54. cy.findByText('Connections');
  55. cy.window()
  56. .its('cur_frm')
  57. .then(cur_frm => {
  58. cur_frm.dashboard.data.reports = [
  59. {
  60. 'label': 'Reports',
  61. 'items': ['Website Analytics']
  62. }
  63. ];
  64. cur_frm.dashboard.render_report_links();
  65. cy.get('[data-report="Website Analytics"]').contains('Website Analytics').click();
  66. cy.findByText('Website Analytics');
  67. });
  68. });
  69. it('check if child table is populated with linked field on creation from dashboard link', () => {
  70. cy.new_form(doctype_to_link_name);
  71. cy.fill_field("title", "Test Linking");
  72. cy.findByRole("button", {name: "Save"}).click();
  73. cy.get('.document-link .btn-new').click();
  74. cy.get('.frappe-control[data-fieldname="child_table"] .rows .data-row .col[data-fieldname="doctype_to_link"]')
  75. .should('contain.text', 'Test Linking');
  76. });
  77. });