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.

web_form.js 7.6 KiB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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.clear_notes");
  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.request("/api/method/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.login("Administrator");
  40. cy.visit("/app/web-form/note");
  41. cy.findByRole("tab", { name: "Settings" }).click();
  42. cy.get('input[data-fieldname="login_required"]').check({ force: true });
  43. cy.save();
  44. cy.visit("/note");
  45. cy.call("logout");
  46. cy.visit("/note");
  47. cy.get_open_dialog()
  48. .get(".modal-message")
  49. .contains("You are not permitted to access this page without login.");
  50. });
  51. it("Show List", () => {
  52. cy.login("Administrator");
  53. cy.visit("/app/web-form/note");
  54. cy.findByRole("tab", { name: "Settings" }).click();
  55. cy.get(".section-head").contains("List Settings").click();
  56. cy.get('input[data-fieldname="show_list"]').check();
  57. cy.save();
  58. cy.visit("/note");
  59. cy.url().should("include", "/note/list");
  60. cy.get(".web-list-table").should("be.visible");
  61. });
  62. it("Show Custom List Title", () => {
  63. cy.visit("/app/web-form/note");
  64. cy.findByRole("tab", { name: "Settings" }).click();
  65. cy.fill_field("list_title", "Note List");
  66. cy.save();
  67. cy.visit("/note");
  68. cy.url().should("include", "/note/list");
  69. cy.get(".web-list-header h1").should("contain.text", "Note List");
  70. });
  71. it("Show Custom List Columns", () => {
  72. cy.visit("/note");
  73. cy.url().should("include", "/note/list");
  74. cy.get(".web-list-table thead th").contains("Name");
  75. cy.get(".web-list-table thead th").contains("Title");
  76. cy.visit("/app/web-form/note");
  77. cy.findByRole("tab", { name: "Settings" }).click();
  78. cy.get('[data-fieldname="list_columns"] .grid-footer button')
  79. .contains("Add Row")
  80. .as("add-row");
  81. cy.get("@add-row").click();
  82. cy.get('[data-fieldname="list_columns"] .grid-body .rows').as("grid-rows");
  83. cy.get("@grid-rows").find('.grid-row:first [data-fieldname="fieldname"]').click();
  84. cy.get("@grid-rows")
  85. .find('.grid-row:first select[data-fieldname="fieldname"]')
  86. .select("Title");
  87. cy.get("@add-row").click();
  88. cy.get("@grid-rows").find('.grid-row[data-idx="2"] [data-fieldname="fieldname"]').click();
  89. cy.get("@grid-rows")
  90. .find('.grid-row[data-idx="2"] select[data-fieldname="fieldname"]')
  91. .select("Public");
  92. cy.get("@add-row").click();
  93. cy.get("@grid-rows").find('.grid-row:last [data-fieldname="fieldname"]').click();
  94. cy.get("@grid-rows")
  95. .find('.grid-row:last select[data-fieldname="fieldname"]')
  96. .select("Content");
  97. cy.save();
  98. cy.visit("/note");
  99. cy.url().should("include", "/note/list");
  100. cy.get(".web-list-table thead th").contains("Title");
  101. cy.get(".web-list-table thead th").contains("Public");
  102. cy.get(".web-list-table thead th").contains("Content");
  103. });
  104. it("Breadcrumbs", () => {
  105. cy.visit("/note/Note 1");
  106. cy.get(".breadcrumb-container .breadcrumb .breadcrumb-item:first a")
  107. .should("contain.text", "Note")
  108. .click();
  109. cy.url().should("include", "/note/list");
  110. });
  111. it("Custom Breadcrumbs", () => {
  112. cy.visit("/app/web-form/note");
  113. cy.findByRole("tab", { name: "Customization" }).click();
  114. cy.fill_field("breadcrumbs", '[{"label": _("Notes"), "route":"note"}]', "Code");
  115. cy.get(".form-tabs .nav-item .nav-link").contains("Customization").click();
  116. cy.save();
  117. cy.visit("/note/Note 1");
  118. cy.get(".breadcrumb-container .breadcrumb .breadcrumb-item:first a").should(
  119. "contain.text",
  120. "Notes"
  121. );
  122. });
  123. it("Read Only", () => {
  124. cy.login("Administrator");
  125. cy.visit("/note");
  126. cy.url().should("include", "/note/list");
  127. // Read Only Field
  128. cy.get('.web-list-table tbody tr[id="Note 1"]').click();
  129. cy.get('.xhiveframework-control[data-fieldname="title"] .control-input').should(
  130. "have.css",
  131. "display",
  132. "none"
  133. );
  134. });
  135. it("Edit Mode", () => {
  136. cy.visit("/app/web-form/note");
  137. cy.findByRole("tab", { name: "Settings" }).click();
  138. cy.get('input[data-fieldname="allow_edit"]').check();
  139. cy.save();
  140. cy.visit("/note/Note 1");
  141. cy.url().should("include", "/note/Note%201");
  142. cy.get(".web-form-actions a").contains("Edit Response").click();
  143. cy.url().should("include", "/note/Note%201/edit");
  144. // Editable Field
  145. cy.get_field("title").should("have.value", "Note 1");
  146. cy.fill_field("title", " Edited");
  147. cy.get(".web-form-actions button").contains("Save").click();
  148. cy.get(".success-page .edit-button").click();
  149. cy.get_field("title").should("have.value", "Note 1 Edited");
  150. });
  151. it("Allow Multiple Response", () => {
  152. cy.visit("/app/web-form/note");
  153. cy.findByRole("tab", { name: "Settings" }).click();
  154. cy.get('input[data-fieldname="allow_multiple"]').check();
  155. cy.save();
  156. cy.visit("/note");
  157. cy.url().should("include", "/note/list");
  158. cy.get(".web-list-actions a:visible").contains("New").click();
  159. cy.url().should("include", "/note/new");
  160. cy.fill_field("title", "Note 2");
  161. cy.get(".web-form-actions button").contains("Save").click();
  162. });
  163. it("Allow Delete", () => {
  164. cy.visit("/app/web-form/note");
  165. cy.findByRole("tab", { name: "Settings" }).click();
  166. cy.get('input[data-fieldname="allow_delete"]').check();
  167. cy.save();
  168. cy.visit("/note");
  169. cy.url().should("include", "/note/list");
  170. cy.get('.web-list-table tbody tr[id="Note 1"] .list-col-checkbox input').click();
  171. cy.get('.web-list-table tbody tr[id="Note 2"] .list-col-checkbox input').click();
  172. cy.get(".web-list-actions button:visible").contains("Delete").click({ force: true });
  173. cy.get(".web-list-actions button").contains("Delete").should("not.be.visible");
  174. cy.visit("/note");
  175. cy.get('.web-list-table tbody tr[id="Note 1"]').should("not.exist");
  176. cy.get('.web-list-table tbody tr[id="Note 2"]').should("not.exist");
  177. cy.get('.web-list-table tbody tr[id="Guest Note 1"]').should("exist");
  178. });
  179. it("Navigate and Submit a WebForm", () => {
  180. cy.visit("/update-profile");
  181. cy.get(".web-form-actions a").contains("Edit Response").click();
  182. cy.fill_field("middle_name", "_Test User");
  183. cy.get(".web-form-actions .btn-primary").click();
  184. cy.url().should("include", "/me");
  185. });
  186. it("Navigate and Submit a MultiStep WebForm", () => {
  187. cy.call("xhiveframework.tests.ui_test_helpers.update_webform_to_multistep").then(() => {
  188. cy.visit("/update-profile-duplicate");
  189. cy.get(".web-form-actions a").contains("Edit Response").click();
  190. cy.fill_field("middle_name", "_Test User");
  191. cy.get(".btn-next").should("be.visible");
  192. cy.get(".btn-next").click();
  193. cy.get(".btn-previous").should("be.visible");
  194. cy.get(".btn-next").should("not.be.visible");
  195. cy.get(".web-form-actions .btn-primary").click();
  196. cy.url().should("include", "/me");
  197. });
  198. });
  199. });