Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

172 rader
5.2 KiB

  1. const jump_to_field = (field_label) => {
  2. cy.get("body")
  3. .type("{esc}") // lose focus if any
  4. .type("{ctrl+j}") // jump to field
  5. .type(field_label)
  6. .wait(500)
  7. .type("{enter}")
  8. .wait(200)
  9. .type("{enter}")
  10. .wait(500);
  11. };
  12. const type_value = (value) => {
  13. cy.focused().clear().type(value).type("{esc}");
  14. };
  15. context("Form", () => {
  16. before(() => {
  17. cy.login();
  18. cy.visit("/app/website");
  19. return cy
  20. .window()
  21. .its("xhiveframework")
  22. .then((xhiveframework) => {
  23. return xhiveframework.call("xhiveframework.tests.ui_test_helpers.create_contact_records");
  24. });
  25. });
  26. beforeEach(() => {
  27. cy.login();
  28. cy.visit("/app/website");
  29. });
  30. it("create a new form", () => {
  31. cy.visit("/app/todo/new");
  32. cy.get_field("description", "Text Editor")
  33. .type("this is a test todo", { force: true })
  34. .wait(1000);
  35. cy.get(".page-title").should("contain", "Not Saved");
  36. cy.intercept({
  37. method: "POST",
  38. url: "api/method/xhiveframework.desk.form.save.savedocs",
  39. }).as("form_save");
  40. cy.get(".primary-action").click();
  41. cy.wait("@form_save").its("response.statusCode").should("eq", 200);
  42. cy.go_to_list("ToDo");
  43. cy.clear_filters();
  44. cy.get(".page-head").findByTitle("To Do").should("exist");
  45. cy.get(".list-row").should("contain", "this is a test todo");
  46. });
  47. it("navigates between documents with child table list filters applied", () => {
  48. cy.visit("/app/contact");
  49. cy.clear_filters();
  50. cy.get('.standard-filter-section [data-fieldname="name"] input')
  51. .type("Test Form Contact 3")
  52. .blur();
  53. cy.click_listview_row_item_with_text("Test Form Contact 3");
  54. cy.scrollTo(0);
  55. cy.get("#page-Contact .page-head").findByTitle("Test Form Contact 3").should("exist");
  56. cy.get(".prev-doc").should("be.visible").click();
  57. cy.get(".msgprint-dialog .modal-body").contains("No further records").should("be.visible");
  58. cy.hide_dialog();
  59. cy.scrollTo(0);
  60. cy.get("#page-Contact .page-head").findByTitle("Test Form Contact 3").should("exist");
  61. cy.get(".next-doc").should("be.visible").click();
  62. cy.get(".msgprint-dialog .modal-body").contains("No further records").should("be.visible");
  63. cy.hide_dialog();
  64. cy.get("#page-Contact .page-head").findByTitle("Test Form Contact 3").should("exist");
  65. // clear filters
  66. cy.visit("/app/contact");
  67. cy.clear_filters();
  68. });
  69. it("validates behaviour of Data options validations in child table", () => {
  70. // test email validations for set_invalid controller
  71. let website_input = "website.in";
  72. let valid_email = "user@email.com";
  73. let expectBackgroundColor = "rgb(255, 245, 245)";
  74. cy.visit("/app/contact/new");
  75. cy.get('.xhiveframework-control[data-fieldname="email_ids"]').as("table");
  76. cy.get("@table").find("button.grid-add-row").click();
  77. cy.get("@table").find("button.grid-add-row").click();
  78. cy.get("@table").find('[data-idx="1"]').as("row1");
  79. cy.get("@table").find('[data-idx="2"]').as("row2");
  80. cy.get("@row1").click();
  81. cy.get("@row1").find("input.input-with-feedback.form-control").as("email_input1");
  82. cy.get("@email_input1").type(website_input, { waitForAnimations: false });
  83. cy.fill_field("company_name", "Test Company");
  84. cy.get("@row2").click();
  85. cy.get("@row2").find("input.input-with-feedback.form-control").as("email_input2");
  86. cy.get("@email_input2").type(valid_email, { waitForAnimations: false });
  87. cy.get("@row1").click();
  88. cy.get("@email_input1").should("have.class", "invalid");
  89. cy.get("@row2").click();
  90. cy.get("@email_input2").should("not.have.class", "invalid");
  91. });
  92. it("Jump to field in collapsed section", { scrollBehavior: false }, () => {
  93. cy.new_form("User");
  94. jump_to_field("Location"); // this is in collapsed section
  95. type_value("Bermuda");
  96. cy.get_field("location").should("have.value", "Bermuda");
  97. });
  98. it("update docfield property using set_df_property in child table", () => {
  99. cy.visit("/app/contact/Test Form Contact 1");
  100. cy.window()
  101. .its("cur_frm")
  102. .then((frm) => {
  103. cy.get('.xhiveframework-control[data-fieldname="phone_nos"]').as("table");
  104. // set property before form_render event of child table
  105. cy.get("@table")
  106. .find('[data-idx="1"]')
  107. .invoke("attr", "data-name")
  108. .then((cdn) => {
  109. frm.set_df_property(
  110. "phone_nos",
  111. "hidden",
  112. 1,
  113. "Contact Phone",
  114. "is_primary_phone",
  115. cdn
  116. );
  117. });
  118. cy.get("@table").find('[data-idx="1"] .btn-open-row').click();
  119. cy.get(".grid-row-open").as("table-form");
  120. cy.get("@table-form")
  121. .find('.xhiveframework-control[data-fieldname="is_primary_phone"]')
  122. .should("be.hidden");
  123. cy.get("@table-form").find(".grid-footer-toolbar").click();
  124. // set property on form_render event of child table
  125. cy.get("@table").find('[data-idx="1"] .btn-open-row').click();
  126. cy.get("@table")
  127. .find('[data-idx="1"]')
  128. .invoke("attr", "data-name")
  129. .then((cdn) => {
  130. frm.set_df_property(
  131. "phone_nos",
  132. "hidden",
  133. 0,
  134. "Contact Phone",
  135. "is_primary_phone",
  136. cdn
  137. );
  138. });
  139. cy.get(".grid-row-open").as("table-form");
  140. cy.get("@table-form")
  141. .find('.xhiveframework-control[data-fieldname="is_primary_phone"]')
  142. .should("be.visible");
  143. cy.get("@table-form").find(".grid-footer-toolbar").click();
  144. });
  145. });
  146. });