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.
 
 
 
 
 
 

96 lines
3.8 KiB

  1. context("Attach Control", () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit("/app/doctype");
  5. return cy
  6. .window()
  7. .its("xhiveframework")
  8. .then((xhiveframework) => {
  9. return xhiveframework.xcall("xhiveframework.tests.ui_test_helpers.create_doctype", {
  10. name: "Test Attach Control",
  11. fields: [
  12. {
  13. label: "Attach File or Image",
  14. fieldname: "attach",
  15. fieldtype: "Attach",
  16. in_list_view: 1,
  17. },
  18. ],
  19. });
  20. });
  21. });
  22. it('Checking functionality for "Link" button in the "Attach" fieldtype', () => {
  23. //Navigating to the new form for the newly created doctype
  24. cy.new_form("Test Attach Control");
  25. //Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
  26. cy.findByRole("button", { name: "Attach" }).click();
  27. //Clicking on "Link" button to attach a file using the "Link" button
  28. cy.findByRole("button", { name: "Link" }).click();
  29. cy.findByPlaceholderText("Attach a web link").type(
  30. "https://wallpaperplay.com/walls/full/8/2/b/72402.jpg"
  31. );
  32. //Clicking on the Upload button to upload the file
  33. cy.intercept("POST", "/api/method/upload_file").as("upload_image");
  34. cy.get(".modal-footer").findByRole("button", { name: "Upload" }).click({ delay: 500 });
  35. cy.wait("@upload_image");
  36. cy.findByRole("button", { name: "Save" }).click();
  37. //Checking if the URL of the attached image is getting displayed in the field of the newly created doctype
  38. cy.get(".attached-file > .ellipsis > .attached-file-link")
  39. .should("have.attr", "href")
  40. .and("equal", "https://wallpaperplay.com/walls/full/8/2/b/72402.jpg");
  41. //Clicking on the "Clear" button
  42. cy.get('[data-action="clear_attachment"]').click();
  43. //Checking if clicking on the clear button clears the field of the doctype form and again displays the attach button
  44. cy.get(".control-input > .btn-sm").should("contain", "Attach");
  45. //Deleting the doc
  46. cy.go_to_list("Test Attach Control");
  47. cy.get(".list-row-checkbox").eq(0).click();
  48. cy.get(".actions-btn-group > .btn").contains("Actions").click();
  49. cy.get('.actions-btn-group > .dropdown-menu [data-label="Delete"]').click();
  50. cy.click_modal_primary_button("Yes");
  51. });
  52. it('Checking functionality for "Library" button in the "Attach" fieldtype', () => {
  53. //Navigating to the new form for the newly created doctype
  54. cy.new_form("Test Attach Control");
  55. //Clicking on the attach button which is displayed as part of creating a doctype with "Attach" fieldtype
  56. cy.findByRole("button", { name: "Attach" }).click();
  57. //Clicking on "Library" button to attach a file using the "Library" button
  58. cy.findByRole("button", { name: "Library" }).click();
  59. cy.contains("72402.jpg").click();
  60. //Clicking on the Upload button to upload the file
  61. cy.intercept("POST", "/api/method/upload_file").as("upload_image");
  62. cy.get(".modal-footer").findByRole("button", { name: "Upload" }).click({ delay: 500 });
  63. cy.wait("@upload_image");
  64. cy.findByRole("button", { name: "Save" }).click();
  65. //Checking if the URL of the attached image is getting displayed in the field of the newly created doctype
  66. cy.get(".attached-file > .ellipsis > .attached-file-link")
  67. .should("have.attr", "href")
  68. .and("equal", "https://wallpaperplay.com/walls/full/8/2/b/72402.jpg");
  69. //Clicking on the "Clear" button
  70. cy.get('[data-action="clear_attachment"]').click();
  71. //Checking if clicking on the clear button clears the field of the doctype form and again displays the attach button
  72. cy.get(".control-input > .btn-sm").should("contain", "Attach");
  73. //Deleting the doc
  74. cy.go_to_list("Test Attach Control");
  75. cy.get(".list-row-checkbox").eq(0).click();
  76. cy.get(".actions-btn-group > .btn").contains("Actions").click();
  77. cy.get('.actions-btn-group > .dropdown-menu [data-label="Delete"]').click();
  78. cy.click_modal_primary_button("Yes");
  79. });
  80. });