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.5 KiB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.get('[data-doctype="Contact"]').should("contain", "Contact");
  30. //Adding a new contact
  31. cy.get('.document-link-badge[data-doctype="Contact"]').click();
  32. cy.wait(300);
  33. cy.findByRole("button", { name: "Add Contact" }).should("be.visible");
  34. cy.findByRole("button", { name: "Add Contact" }).click();
  35. cy.get('[data-doctype="Contact"][data-fieldname="first_name"]').type("Admin");
  36. cy.findByRole("button", { name: "Save" }).click();
  37. cy.visit(`/app/user/${cy.config("testUser")}`);
  38. //To check if the counter for contact doc is "2" after adding additional contact
  39. cy.get('[data-doctype="Contact"] > .count').should("contain", "2");
  40. cy.get('[data-doctype="Contact"]').contains("Contact").click();
  41. //Deleting the newly created contact
  42. cy.visit("/app/contact");
  43. cy.get(".list-subject > .select-like > .list-row-checkbox").eq(0).click({ force: true });
  44. cy.findByRole("button", { name: "Actions" }).click();
  45. cy.get('.actions-btn-group [data-label="Delete"]').click();
  46. cy.findByRole("button", { name: "Yes" }).click({ delay: 700 });
  47. //To check if the counter from the "Contact" doc link is removed
  48. cy.wait(700);
  49. cy.visit("/app/user");
  50. cy.get(".list-row-col > .level-item > .ellipsis").eq(0).click({ force: true });
  51. cy.get('[data-doctype="Contact"]').should("contain", "Contact");
  52. });
  53. it("Report link in dashboard", () => {
  54. cy.visit(`/app/user/${cy.config("testUser")}`);
  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(
  77. '.xhiveframework-control[data-fieldname="child_table"] .rows .data-row .col[data-fieldname="doctype_to_link"]'
  78. ).should("contain.text", "Test Linking");
  79. });
  80. });