Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

90 řádky
3.7 KiB

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