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.
 
 
 
 
 
 

265 line
7.4 KiB

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