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.
 
 
 
 
 
 

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