No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

283 líneas
9.6 KiB

  1. import form_builder_doctype from "../fixtures/form_builder_doctype";
  2. const doctype_name = form_builder_doctype.name;
  3. context("Form Builder", () => {
  4. before(() => {
  5. cy.login();
  6. cy.visit("/app");
  7. return cy.insert_doc("DocType", form_builder_doctype, true);
  8. });
  9. it("Open Form Builder for Web Form Doctype/Customize Form", () => {
  10. // doctype
  11. cy.visit("/app/doctype/Web Form");
  12. cy.findByRole("tab", { name: "Form" }).click();
  13. cy.get(".form-builder-container").should("exist");
  14. // customize form
  15. cy.visit("/app/customize-form?doc_type=Web%20Form");
  16. cy.findByRole("tab", { name: "Form" }).click();
  17. cy.get(".form-builder-container").should("exist");
  18. });
  19. it("Save without change, check form dirty", () => {
  20. cy.visit(`/app/doctype/${doctype_name}`);
  21. cy.findByRole("tab", { name: "Form" }).click();
  22. // Save without change
  23. cy.click_doc_primary_button("Save");
  24. cy.get(".desk-alert.orange .alert-message").should("have.text", "No changes in document");
  25. // Check form dirty
  26. cy.get(".tab-content.active .section-columns-container:first .column:first .field:first")
  27. .find("div[title='Double click to edit label']")
  28. .dblclick()
  29. .type("Dirty");
  30. cy.get(".title-area .indicator-pill.orange").should("have.text", "Not Saved");
  31. });
  32. it("Add empty section and save", () => {
  33. cy.visit(`/app/doctype/${doctype_name}`);
  34. cy.findByRole("tab", { name: "Form" }).click();
  35. let first_section = ".tab-content.active .form-section-container:first";
  36. // add new section
  37. cy.get(first_section).click(15, 10);
  38. cy.get(first_section).find(".dropdown-btn:first").click();
  39. cy.get(".dropdown-options:visible .dropdown-item:first").click();
  40. // save
  41. cy.click_doc_primary_button("Save");
  42. cy.get(".tab-content.active .form-section-container").should("have.length", 1);
  43. });
  44. it("Add Table field and check if columns are rendered", () => {
  45. cy.intercept("POST", "/api/method/xhiveframework.desk.search.search_link").as("search_link");
  46. cy.visit(`/app/doctype/${doctype_name}`);
  47. cy.findByRole("tab", { name: "Form" }).click();
  48. let first_column = ".tab-content.active .section-columns-container:first .column:first";
  49. let last_field = first_column + " .field:last";
  50. let add_new_field_btn = first_column + " .add-new-field-btn button";
  51. // add new field
  52. cy.get(add_new_field_btn).click();
  53. // type table and press enter
  54. cy.get(".combo-box-options:visible .search-box > input").type("table{enter}");
  55. // save
  56. cy.click_doc_primary_button("Save");
  57. // Validate if options is not set
  58. cy.get_open_dialog().find(".msgprint").should("contain", "Options is required");
  59. cy.hide_dialog();
  60. cy.get(last_field).click({ force: true });
  61. cy.get(".sidebar-container .xhiveframework-control[data-fieldname='options'] input")
  62. .click()
  63. .as("input");
  64. cy.get("@input").clear({ force: true }).type("Web Form Field", { delay: 200 });
  65. cy.wait("@search_link");
  66. cy.get(last_field).click({ force: true });
  67. cy.get(last_field).find(".table-controls .table-column").contains("Field").should("exist");
  68. cy.get(last_field)
  69. .find(".table-controls .table-column")
  70. .contains("Fieldtype")
  71. .should("exist");
  72. // validate In List View
  73. cy.get(".sidebar-container .field label .label-area").contains("In List View").click();
  74. // save
  75. cy.click_doc_primary_button("Save");
  76. cy.get_open_dialog().find(".msgprint").should("contain", "In List View");
  77. cy.hide_dialog();
  78. cy.get(last_field).click({ force: true });
  79. cy.get(".sidebar-container .field label .label-area").contains("In List View").click();
  80. // validate In Global Search
  81. cy.get(".sidebar-container .field label .label-area").contains("In Global Search").click();
  82. // save
  83. cy.click_doc_primary_button("Save");
  84. cy.get_open_dialog().find(".msgprint").should("contain", "In Global Search");
  85. });
  86. // not important and was flaky on CI
  87. it.skip("Drag Field/Column/Section & Tab", () => {
  88. cy.visit(`/app/doctype/${doctype_name}`);
  89. cy.findByRole("tab", { name: "Form" }).click();
  90. let first_column = ".tab-content.active .section-columns-container:first .column:first";
  91. let first_field = first_column + " .field:first";
  92. let label = "div[title='Double click to edit label'] span:first";
  93. cy.get(".tab-header .tabs .tab:first").click();
  94. // drag first tab to second position
  95. cy.get(".tab-header .tabs .tab:first").drag(".tab-header .tabs .tab:nth-child(2)", {
  96. target: { x: 10, y: 10 },
  97. force: true,
  98. });
  99. cy.get(".tab-header .tabs .tab:first").find(label).should("have.text", "Tab 2");
  100. cy.get(".tab-header .tabs .tab:first").click();
  101. cy.get(".sidebar-container .tab:first").click();
  102. // drag check field to first column
  103. cy.get(".fields-container .field[title='Check']").drag(first_field, {
  104. target: { x: 100, y: 10 },
  105. });
  106. cy.get(first_column).find(".field").should("have.length", 3);
  107. cy.get(first_field)
  108. .find("div[title='Double click to edit label']")
  109. .dblclick()
  110. .type("Test Check");
  111. cy.get(first_field).find(label).should("have.text", "Test Check");
  112. // drag the first field to second position
  113. cy.get(first_field).drag(first_column + " .field:nth-child(2)", {
  114. target: { x: 100, y: 10 },
  115. });
  116. cy.get(first_field).find(label).should("have.text", "Data");
  117. // drag first column to second position
  118. cy.get(first_column).click().wait(200);
  119. cy.get(first_column)
  120. .find(".column-actions")
  121. .drag(".section-columns-container:first .column:last", {
  122. target: { x: 100, y: 10 },
  123. force: true,
  124. });
  125. cy.get(first_field).find(label).should("have.text", "Data 1");
  126. let first_section = ".tab-content.active .form-section-container:first";
  127. // drag first section to second position
  128. cy.get(first_section).click().wait(200);
  129. cy.get(first_section)
  130. .find(".section-header")
  131. .drag(".form-section-container:nth-child(2)", {
  132. target: { x: 100, y: 10 },
  133. force: true,
  134. });
  135. cy.get(first_field).find(label).should("have.text", "Data 2");
  136. });
  137. it("Add New Tab/Section/Column to Form", () => {
  138. cy.visit(`/app/doctype/${doctype_name}`);
  139. cy.findByRole("tab", { name: "Form" }).click();
  140. let first_section = ".tab-content.active .form-section-container:first";
  141. // add new tab
  142. cy.get(".tab-header").realHover().find(".tab-actions .new-tab-btn").click();
  143. cy.get(".tab-header .tabs .tab").should("have.length", 3);
  144. // add new section
  145. cy.get(first_section).click(15, 10);
  146. cy.get(first_section).find(".dropdown-btn:first").click();
  147. cy.get(".dropdown-options:visible .dropdown-item:first").click();
  148. cy.get(".tab-content.active .form-section-container").should("have.length", 2);
  149. // add new column
  150. cy.get(first_section).click(15, 10);
  151. cy.get(first_section).find(".dropdown-btn:first").click();
  152. cy.get(".dropdown-options:visible .dropdown-item:last").click();
  153. cy.get(first_section).find(".column").should("have.length", 2);
  154. });
  155. it("Remove Tab/Section/Column", () => {
  156. let first_section = ".tab-content.active .form-section-container:first";
  157. // remove column
  158. cy.get(first_section).click(15, 10);
  159. cy.get(first_section).find(".dropdown-btn:first").click();
  160. cy.get(".dropdown-options:visible .dropdown-item:last").click();
  161. cy.get(first_section).find(".column").should("have.length", 1);
  162. // remove section
  163. cy.get(first_section).click(15, 10);
  164. cy.get(first_section).find(".dropdown-btn:first").click();
  165. cy.get(".dropdown-options:visible .dropdown-item").eq(1).click();
  166. cy.get(".tab-content.active .form-section-container").should("have.length", 1);
  167. // remove tab
  168. cy.get(".tab-header .tab:last").realHover().find(".remove-tab-btn").click();
  169. cy.get(".tab-header .tabs .tab").should("have.length", 2);
  170. });
  171. it("Update Title field Label to New Title through Customize Form", () => {
  172. cy.visit(`/app/doctype/${doctype_name}`);
  173. cy.findByRole("tab", { name: "Form" }).click();
  174. let first_field =
  175. ".tab-content.active .section-columns-container:first .column:first .field:first";
  176. cy.get(first_field)
  177. .find("div[title='Double click to edit label']")
  178. .dblclick()
  179. .type("{selectall}New Title");
  180. cy.findByRole("button", { name: "Save" }).click({ force: true });
  181. cy.visit("/app/form-builder-doctype/new");
  182. cy.get("[data-fieldname='data3'] .clearfix label").should("have.text", "New Title");
  183. });
  184. it("Validate Duplicate Name & reqd + hidden without default logic", () => {
  185. cy.visit(`/app/doctype/${doctype_name}`);
  186. cy.findByRole("tab", { name: "Form" }).click();
  187. let first_column = ".tab-content.active .section-columns-container:first .column:first";
  188. let last_field = first_column + " .field:last";
  189. let add_new_field_btn = first_column + " .add-new-field-btn button";
  190. // add new field
  191. cy.get(add_new_field_btn).click();
  192. // type data and press enter
  193. cy.get(".combo-box-options:visible .search-box > input").type("data{enter}");
  194. cy.get(last_field).click();
  195. // validate duplicate name
  196. cy.get(".sidebar-container .xhiveframework-control[data-fieldname='fieldname'] input")
  197. .click()
  198. .as("input");
  199. cy.get(".sidebar-container .xhiveframework-control[data-fieldname='fieldname'] input")
  200. .clear({ force: true })
  201. .type("data3");
  202. cy.click_doc_primary_button("Save");
  203. cy.get_open_dialog().find(".msgprint").should("contain", "appears multiple times");
  204. cy.hide_dialog();
  205. cy.get(last_field).click();
  206. cy.get(".sidebar-container .xhiveframework-control[data-fieldname='fieldname'] input").clear({
  207. force: true,
  208. });
  209. // validate reqd + hidden without default
  210. cy.get(".sidebar-container .field label .label-area").contains("Mandatory").click();
  211. cy.get(".sidebar-container .field label .label-area").contains("Hidden").click();
  212. // save
  213. cy.click_doc_primary_button("Save");
  214. cy.get_open_dialog()
  215. .find(".msgprint")
  216. .should("contain", "cannot be hidden and mandatory without any default value");
  217. });
  218. });