Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

92 рядки
3.5 KiB

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