25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

58 satır
2.0 KiB

  1. context('FileUploader', () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit('/app');
  5. });
  6. function open_upload_dialog() {
  7. cy.window().its('frappe').then(frappe => {
  8. new frappe.ui.FileUploader();
  9. });
  10. }
  11. it('upload dialog api works', () => {
  12. open_upload_dialog();
  13. cy.get_open_dialog().should('contain', 'Drag and drop files');
  14. cy.hide_dialog();
  15. });
  16. it('should accept dropped files', () => {
  17. open_upload_dialog();
  18. cy.get_open_dialog().find('.file-upload-area').attachFile('example.json', {
  19. subjectType: 'drag-n-drop',
  20. });
  21. cy.get_open_dialog().find('.file-name').should('contain', 'example.json');
  22. cy.intercept('POST', '/api/method/upload_file').as('upload_file');
  23. cy.get_open_dialog().find('.btn-modal-primary').click();
  24. cy.wait('@upload_file').its('response.statusCode').should('eq', 200);
  25. cy.get('.modal:visible').should('not.exist');
  26. });
  27. it('should accept uploaded files', () => {
  28. open_upload_dialog();
  29. cy.get_open_dialog().find('.btn-file-upload div:contains("Library")').click();
  30. cy.get('.file-filter').type('example.json');
  31. cy.get_open_dialog().find('.tree-label:contains("example.json")').first().click();
  32. cy.intercept('POST', '/api/method/upload_file').as('upload_file');
  33. cy.get_open_dialog().find('.btn-primary').click();
  34. cy.wait('@upload_file').its('response.body.message')
  35. .should('have.property', 'file_name', 'example.json');
  36. cy.get('.modal:visible').should('not.exist');
  37. });
  38. it('should accept web links', () => {
  39. open_upload_dialog();
  40. cy.get_open_dialog().find('.btn-file-upload div:contains("Link")').click();
  41. cy.get_open_dialog().find('.file-web-link input').type('https://github.com', { delay: 100, force: true });
  42. cy.intercept('POST', '/api/method/upload_file').as('upload_file');
  43. cy.get_open_dialog().find('.btn-primary').click();
  44. cy.wait('@upload_file').its('response.body.message')
  45. .should('have.property', 'file_url', 'https://github.com');
  46. cy.get('.modal:visible').should('not.exist');
  47. });
  48. });