您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

160 行
4.0 KiB

  1. context("Dynamic Link", () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit("/app/doctype");
  5. return cy
  6. .window()
  7. .its("xhiveframework")
  8. .then((xhiveframework) => {
  9. return xhiveframework.xcall("xhiveframework.tests.ui_test_helpers.create_doctype", {
  10. name: "Test Dynamic Link",
  11. fields: [
  12. {
  13. label: "Document Type",
  14. fieldname: "doc_type",
  15. fieldtype: "Link",
  16. options: "DocType",
  17. in_list_view: 1,
  18. in_standard_filter: 1,
  19. },
  20. {
  21. label: "Document ID",
  22. fieldname: "doc_id",
  23. fieldtype: "Dynamic Link",
  24. options: "doc_type",
  25. in_list_view: 1,
  26. in_standard_filter: 1,
  27. },
  28. ],
  29. });
  30. });
  31. });
  32. function get_dialog_with_dynamic_link() {
  33. return cy.dialog({
  34. title: "Dynamic Link",
  35. fields: [
  36. {
  37. label: "Document Type",
  38. fieldname: "doc_type",
  39. fieldtype: "Link",
  40. options: "DocType",
  41. in_list_view: 1,
  42. },
  43. {
  44. label: "Document ID",
  45. fieldname: "doc_id",
  46. fieldtype: "Dynamic Link",
  47. options: "doc_type",
  48. in_list_view: 1,
  49. },
  50. ],
  51. });
  52. }
  53. function get_dialog_with_dynamic_link_option() {
  54. return cy.dialog({
  55. title: "Dynamic Link",
  56. fields: [
  57. {
  58. label: "Document Type",
  59. fieldname: "doc_type",
  60. fieldtype: "Link",
  61. options: "DocType",
  62. in_list_view: 1,
  63. },
  64. {
  65. label: "Document ID",
  66. fieldname: "doc_id",
  67. fieldtype: "Dynamic Link",
  68. get_options: () => {
  69. return "User";
  70. },
  71. in_list_view: 1,
  72. },
  73. ],
  74. });
  75. }
  76. it("Creating a dynamic link by passing option as function and verifying it in a dialog", () => {
  77. get_dialog_with_dynamic_link_option().as("dialog");
  78. cy.get_field("doc_type").clear();
  79. cy.fill_field("doc_type", "User", "Link");
  80. cy.get_field("doc_id").click();
  81. //Checking if the listbox have length greater than 0
  82. cy.get('[data-fieldname="doc_id"]')
  83. .find(".awesomplete")
  84. .find("li")
  85. .its("length")
  86. .should("be.gte", 0);
  87. cy.get(".btn-modal-close").click({ force: true });
  88. });
  89. it("Creating a dynamic link and verifying it in a dialog", () => {
  90. get_dialog_with_dynamic_link().as("dialog");
  91. cy.get_field("doc_type").clear();
  92. cy.fill_field("doc_type", "User", "Link");
  93. cy.get_field("doc_id").click();
  94. //Checking if the listbox have length greater than 0
  95. cy.get('[data-fieldname="doc_id"]')
  96. .find(".awesomplete")
  97. .find("li")
  98. .its("length")
  99. .should("be.gte", 0);
  100. cy.get(".btn-modal-close").click({ force: true, multiple: true });
  101. });
  102. it("Creating a dynamic link and verifying it", () => {
  103. cy.visit("/app/test-dynamic-link");
  104. //Clicking on the Document ID field
  105. cy.get_field("doc_type").clear();
  106. //Entering User in the Doctype field
  107. cy.fill_field("doc_type", "User", "Link", { delay: 500 });
  108. cy.get_field("doc_id").click();
  109. //Checking if the listbox have length greater than 0
  110. cy.get('[data-fieldname="doc_id"]')
  111. .find(".awesomplete")
  112. .find("li")
  113. .its("length")
  114. .should("be.gte", 0);
  115. //Opening a new form for dynamic link doctype
  116. cy.new_form("Test Dynamic Link");
  117. cy.get_field("doc_type").clear();
  118. //Entering User in the Doctype field
  119. cy.fill_field("doc_type", "User", "Link", { delay: 500 });
  120. cy.get_field("doc_id").click();
  121. //Checking if the listbox have length greater than 0
  122. cy.get('[data-fieldname="doc_id"]')
  123. .find(".awesomplete")
  124. .find("li")
  125. .its("length")
  126. .should("be.gte", 0);
  127. cy.get_field("doc_type").clear();
  128. //Entering System Settings in the Doctype field
  129. cy.intercept("/api/method/xhiveframework.desk.search.search_link").as("search_query");
  130. cy.fill_field("doc_type", "System Settings", "Link", { delay: 500 });
  131. cy.wait("@search_query");
  132. cy.get(`[data-fieldname="doc_type"] ul:visible li:first-child`).click({
  133. scrollBehavior: false,
  134. });
  135. cy.get_field("doc_id").click();
  136. //Checking if the system throws error
  137. cy.get(".modal-title").should("have.text", "Error");
  138. cy.get(".msgprint").should(
  139. "have.text",
  140. "System Settings is not a valid DocType for Dynamic Link"
  141. );
  142. });
  143. });