Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

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