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.
 
 
 
 
 
 

279 lines
7.7 KiB

  1. context("Web Form", () => {
  2. before(() => {
  3. cy.login("Administrator");
  4. cy.visit("/app/");
  5. return cy
  6. .window()
  7. .its("xhiveframework")
  8. .then((xhiveframework) => {
  9. return xhiveframework.xcall("xhiveframework.tests.ui_test_helpers.prepare_webform_test");
  10. });
  11. });
  12. it("Create Web Form", () => {
  13. cy.visit("/app/web-form/new");
  14. cy.intercept("POST", "/api/method/xhiveframework.desk.form.save.savedocs").as("save_form");
  15. cy.fill_field("title", "Note");
  16. cy.fill_field("doc_type", "Note", "Link");
  17. cy.fill_field("module", "Website", "Link");
  18. cy.click_custom_action_button("Get Fields");
  19. cy.click_custom_action_button("Publish");
  20. cy.wait("@save_form");
  21. cy.get_field("route").should("have.value", "note");
  22. cy.get(".title-area .indicator-pill").contains("Published");
  23. });
  24. it("Open Web Form", () => {
  25. cy.visit("/note");
  26. cy.fill_field("title", "Note 1");
  27. cy.get(".web-form-actions button").contains("Save").click();
  28. cy.url().should("include", "/note/new");
  29. cy.call("logout");
  30. cy.visit("/note");
  31. cy.url().should("include", "/note/new");
  32. cy.fill_field("title", "Guest Note 1");
  33. cy.get(".web-form-actions button").contains("Save").click();
  34. cy.url().should("include", "/note/new");
  35. cy.visit("/note");
  36. cy.url().should("include", "/note/new");
  37. });
  38. it("Login Required", () => {
  39. cy.call("logout");
  40. cy.login("Administrator");
  41. cy.visit("/app/web-form/note");
  42. cy.findByRole("tab", { name: "Settings" }).click();
  43. cy.get('input[data-fieldname="login_required"]').check({ force: true });
  44. cy.save();
  45. cy.visit("/note");
  46. cy.call("logout");
  47. cy.visit("/note");
  48. cy.get_open_dialog()
  49. .get(".modal-message")
  50. .contains("You are not permitted to access this page without login.");
  51. });
  52. it("Show List", () => {
  53. cy.login("Administrator");
  54. cy.visit("/app/web-form/note");
  55. cy.findByRole("tab", { name: "Settings" }).click();
  56. cy.get(".section-head").contains("List Settings").click();
  57. cy.get('input[data-fieldname="show_list"]').check();
  58. cy.save();
  59. cy.visit("/note");
  60. cy.url().should("include", "/note/list");
  61. cy.get(".web-list-table").should("be.visible");
  62. });
  63. it("Show Custom List Title", () => {
  64. cy.visit("/app/web-form/note");
  65. cy.findByRole("tab", { name: "Settings" }).click();
  66. cy.fill_field("list_title", "Note List");
  67. cy.save();
  68. cy.visit("/note");
  69. cy.url().should("include", "/note/list");
  70. cy.get(".web-list-header h1").should("contain.text", "Note List");
  71. });
  72. it("Show Custom List Columns", () => {
  73. cy.visit("/note");
  74. cy.url().should("include", "/note/list");
  75. cy.get(".web-list-table thead th").contains("Sr.");
  76. cy.get(".web-list-table thead th").contains("Title");
  77. cy.visit("/app/web-form/note");
  78. cy.findByRole("tab", { name: "Settings" }).click();
  79. cy.get('[data-fieldname="list_columns"] .grid-footer button')
  80. .contains("Add Row")
  81. .as("add-row");
  82. cy.get("@add-row").click();
  83. cy.get('[data-fieldname="list_columns"] .grid-body .rows').as("grid-rows");
  84. cy.get("@grid-rows").find('.grid-row:first [data-fieldname="fieldname"]').click();
  85. cy.get("@grid-rows")
  86. .find('.grid-row:first select[data-fieldname="fieldname"]')
  87. .select("Title");
  88. cy.get("@add-row").click();
  89. cy.get("@grid-rows").find('.grid-row[data-idx="2"] [data-fieldname="fieldname"]').click();
  90. cy.get("@grid-rows")
  91. .find('.grid-row[data-idx="2"] select[data-fieldname="fieldname"]')
  92. .select("Public");
  93. cy.get("@add-row").click();
  94. cy.get("@grid-rows").find('.grid-row:last [data-fieldname="fieldname"]').click();
  95. cy.get("@grid-rows")
  96. .find('.grid-row:last select[data-fieldname="fieldname"]')
  97. .select("Content");
  98. cy.save();
  99. cy.visit("/note");
  100. cy.url().should("include", "/note/list");
  101. cy.get(".web-list-table thead th").contains("Sr.");
  102. cy.get(".web-list-table thead th").contains("Title");
  103. cy.get(".web-list-table thead th").contains("Public");
  104. cy.get(".web-list-table thead th").contains("Content");
  105. });
  106. it("Breadcrumbs", () => {
  107. cy.visit("/note");
  108. cy.url().should("include", "/note/list");
  109. cy.get(".web-list-table tbody tr:last").click();
  110. cy.get(".breadcrumb-container .breadcrumb .breadcrumb-item:first a")
  111. .should("contain.text", "Note")
  112. .click();
  113. cy.url().should("include", "/note/list");
  114. });
  115. it("Custom Breadcrumbs", () => {
  116. cy.visit("/app/web-form/note");
  117. cy.findByRole("tab", { name: "Customization" }).click();
  118. cy.fill_field("breadcrumbs", '[{"label": _("Notes"), "route":"note"}]', "Code");
  119. cy.wait(2000);
  120. cy.get(".form-tabs .nav-item .nav-link").contains("Customization").click();
  121. cy.save();
  122. cy.visit("/note");
  123. cy.url().should("include", "/note/list");
  124. cy.get(".web-list-table tbody tr:last").click();
  125. cy.get(".breadcrumb-container .breadcrumb .breadcrumb-item:first a").should(
  126. "contain.text",
  127. "Notes"
  128. );
  129. });
  130. it("Read Only", () => {
  131. cy.login("Administrator");
  132. cy.visit("/note");
  133. cy.url().should("include", "/note/list");
  134. // Read Only Field
  135. cy.get(".web-list-table tbody tr:last").click();
  136. cy.get('.xhiveframework-control[data-fieldname="title"] .control-input').should(
  137. "have.css",
  138. "display",
  139. "none"
  140. );
  141. });
  142. it("Edit Mode", () => {
  143. cy.visit("/app/web-form/note");
  144. cy.findByRole("tab", { name: "Settings" }).click();
  145. cy.get('input[data-fieldname="allow_edit"]').check();
  146. cy.save();
  147. cy.visit("/note");
  148. cy.url().should("include", "/note/list");
  149. cy.get(".web-list-table tbody tr:last").click();
  150. cy.get(".web-form-actions a").contains("Edit Response").click();
  151. cy.url().should("include", "/edit");
  152. // Editable Field
  153. cy.get_field("title").should("have.value", "Note 1");
  154. cy.fill_field("title", " Edited");
  155. cy.get(".web-form-actions button").contains("Save").click();
  156. cy.get(".success-page .edit-button").click();
  157. cy.get_field("title").should("have.value", "Note 1 Edited");
  158. });
  159. it("Allow Multiple Response", () => {
  160. cy.visit("/app/web-form/note");
  161. cy.findByRole("tab", { name: "Settings" }).click();
  162. cy.get('input[data-fieldname="allow_multiple"]').check();
  163. cy.save();
  164. cy.visit("/note");
  165. cy.url().should("include", "/note/list");
  166. cy.get(".web-list-actions a:visible").contains("New").click();
  167. cy.url().should("include", "/note/new");
  168. cy.fill_field("title", "Note 2");
  169. cy.get(".web-form-actions button").contains("Save").click();
  170. });
  171. it("Allow Delete", () => {
  172. cy.visit("/app/web-form/note");
  173. cy.findByRole("tab", { name: "Settings" }).click();
  174. cy.get('input[data-fieldname="allow_delete"]').check();
  175. cy.save();
  176. cy.visit("/note");
  177. cy.url().should("include", "/note/list");
  178. cy.get(".web-list-table tbody tr:nth-child(1) .list-col-checkbox input").click();
  179. cy.get(".web-list-table tbody tr:nth-child(2) .list-col-checkbox input").click();
  180. cy.get(".web-list-actions button:visible").contains("Delete").click({ force: true });
  181. cy.get(".web-list-actions button").contains("Delete").should("not.be.visible");
  182. cy.visit("/note");
  183. cy.get(".web-list-table tbody tr:nth-child(1)").should("not.exist");
  184. });
  185. it("Navigate and Submit a WebForm", () => {
  186. cy.visit("/update-profile");
  187. cy.get(".web-form-actions a").contains("Edit Response").click();
  188. cy.fill_field("middle_name", "_Test User");
  189. cy.get(".web-form-actions .btn-primary").click();
  190. cy.url().should("include", "/me");
  191. });
  192. it("Navigate and Submit a MultiStep WebForm", () => {
  193. cy.call("xhiveframework.tests.ui_test_helpers.update_webform_to_multistep").then(() => {
  194. cy.visit("/update-profile-duplicate");
  195. cy.get(".web-form-actions a").contains("Edit Response").click();
  196. cy.fill_field("middle_name", "_Test User");
  197. cy.get(".btn-next").should("be.visible");
  198. cy.get(".btn-next").click();
  199. cy.get(".btn-previous").should("be.visible");
  200. cy.get(".btn-next").should("not.be.visible");
  201. cy.get(".web-form-actions .btn-primary").click();
  202. cy.url().should("include", "/me");
  203. });
  204. });
  205. });