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.
 
 
 
 
 
 

145 lines
4.5 KiB

  1. const verify_attachment_visibility = (document, is_private) => {
  2. cy.visit(`/app/${document}`);
  3. const assertion = is_private ? "be.checked" : "not.be.checked";
  4. cy.get(".add-attachment-btn").click();
  5. cy.get_open_dialog()
  6. .find(".file-upload-area")
  7. .selectFile("cypress/fixtures/sample_image.jpg", {
  8. action: "drag-drop",
  9. });
  10. cy.get_open_dialog().findByRole("checkbox", { name: "Private" }).should(assertion);
  11. };
  12. const attach_file = (file, no_of_files = 1) => {
  13. let files = [];
  14. if (file) {
  15. files = [file];
  16. } else if (no_of_files > 1) {
  17. // attach n files
  18. files = [...Array(no_of_files)].map(
  19. (el, idx) =>
  20. "cypress/fixtures/sample_attachments/attachment-" +
  21. (idx + 1) +
  22. (idx == 0 ? ".jpg" : ".txt")
  23. );
  24. }
  25. cy.get(".add-attachment-btn").click();
  26. cy.get_open_dialog().find(".file-upload-area").selectFile(files, {
  27. action: "drag-drop",
  28. });
  29. cy.get_open_dialog().findByRole("button", { name: "Upload" }).click();
  30. };
  31. context("Sidebar", () => {
  32. before(() => {
  33. cy.visit("/");
  34. cy.login();
  35. cy.visit("/app");
  36. return cy
  37. .window()
  38. .its("xhiveframework")
  39. .then((xhiveframework) => {
  40. return xhiveframework.call("xhiveframework.tests.ui_test_helpers.create_blog_post");
  41. });
  42. });
  43. it("Verify attachment visibility config", () => {
  44. cy.call("xhiveframework.tests.ui_test_helpers.create_todo", {
  45. description: "Sidebar Attachment ToDo",
  46. }).then((todo) => {
  47. verify_attachment_visibility(`todo/${todo.message.name}`, true);
  48. });
  49. verify_attachment_visibility("blog-post/test-blog-attachment-post", false);
  50. });
  51. it("Verify attachment accessibility UX", () => {
  52. cy.call("xhiveframework.tests.ui_test_helpers.create_todo_with_attachment_limit", {
  53. description: "Sidebar Attachment Access Test ToDo",
  54. }).then((todo) => {
  55. cy.visit(`/app/todo/${todo.message.name}`);
  56. attach_file("cypress/fixtures/sample_image.jpg");
  57. cy.get(".explore-link").should("be.visible");
  58. cy.get(".show-all-btn").should("be.hidden");
  59. // attach 10 images
  60. attach_file(null, 10);
  61. cy.get(".show-all-btn").should("be.visible");
  62. // attach 1 more image to reach attachment limit
  63. attach_file("cypress/fixtures/sample_attachments/attachment-11.txt");
  64. cy.get(".add-attachment-btn").should("be.hidden");
  65. cy.get(".explore-link").should("be.visible");
  66. // test "Show All" button
  67. cy.get(".attachment-row").should("have.length", 10);
  68. cy.get(".show-all-btn").click({ force: true });
  69. cy.get(".attachment-row").should("have.length", 12);
  70. });
  71. });
  72. it('Test for checking "Assigned To" counter value, adding filter and adding & removing an assignment', () => {
  73. cy.call("xhiveframework.tests.ui_test_helpers.create_todo", {
  74. description: "Sidebar Attachment ToDo",
  75. }).then((todo) => {
  76. let todo_name = todo.message.name;
  77. cy.visit("/app/todo");
  78. cy.click_sidebar_button("Assigned To");
  79. //To check if no filter is available in "Assigned To" dropdown
  80. cy.get(".empty-state").should("contain", "No filters found");
  81. //Assigning a doctype to a user
  82. cy.visit(`/app/todo/${todo_name}`);
  83. cy.get(".add-assignment-btn").click();
  84. cy.get_field("assign_to_me", "Check").click();
  85. cy.wait(1000);
  86. cy.get(".modal-footer > .standard-actions > .btn-primary").click();
  87. cy.visit("/app/todo");
  88. cy.click_sidebar_button("Assigned To");
  89. //To check if filter is added in "Assigned To" dropdown after assignment
  90. cy.get(
  91. ".group-by-field.show > .dropdown-menu > .group-by-item > .dropdown-item"
  92. ).should("contain", "1");
  93. //To check if there is no filter added to the listview
  94. cy.get(".filter-button").should("contain", "Filter");
  95. //To add a filter to display data into the listview
  96. cy.get(
  97. ".group-by-field.show > .dropdown-menu > .group-by-item > .dropdown-item"
  98. ).click();
  99. //To check if filter is applied
  100. cy.click_filter_button().get(".filter-label").should("contain", "1");
  101. cy.get(".fieldname-select-area > .awesomplete > .form-control").should(
  102. "have.value",
  103. "Assigned To"
  104. );
  105. cy.get(".condition").should("have.value", "like");
  106. cy.get(".filter-field > .form-group > .input-with-feedback").should(
  107. "have.value",
  108. `%${cy.config("testUser")}%`
  109. );
  110. cy.click_filter_button();
  111. //To remove the applied filter
  112. cy.clear_filters();
  113. //To remove the assignment
  114. cy.visit(`/app/todo/${todo_name}`);
  115. cy.get(".assignments > .avatar-group > .avatar > .avatar-frame").click();
  116. cy.get(".remove-btn").click({ force: true });
  117. cy.hide_dialog();
  118. cy.visit("/app/todo");
  119. cy.click_sidebar_button("Assigned To");
  120. cy.get(".empty-state").should("contain", "No filters found");
  121. });
  122. });
  123. });