您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

69 行
2.2 KiB

  1. context('FileUploader', () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit('/app/website');
  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. cy.get('body').click();
  16. });
  17. it('should accept dropped files', () => {
  18. open_upload_dialog();
  19. cy.fixture('example.json').then(fileContent => {
  20. cy.get_open_dialog().find('.file-upload-area').upload({
  21. fileContent,
  22. fileName: 'example.json',
  23. mimeType: 'application/json'
  24. }, {
  25. subjectType: 'drag-n-drop',
  26. force: true
  27. });
  28. cy.get_open_dialog().find('.file-name').should('contain', 'example.json');
  29. cy.server();
  30. cy.route('POST', '/api/method/upload_file').as('upload_file');
  31. cy.get_open_dialog().find('.btn-modal-primary').click();
  32. cy.wait('@upload_file').its('status').should('be', 200);
  33. cy.get('.modal:visible').should('not.exist');
  34. });
  35. });
  36. it('should accept uploaded files', () => {
  37. open_upload_dialog();
  38. cy.get_open_dialog().find('.btn-file-upload div:contains("Library")').click();
  39. cy.get('.file-filter').type('example.json');
  40. cy.get_open_dialog().find('.tree-label:contains("example.json")').first().click();
  41. cy.server();
  42. cy.route('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', '/private/files/example.json');
  46. cy.get('.modal:visible').should('not.exist');
  47. });
  48. it('should accept web links', () => {
  49. open_upload_dialog();
  50. cy.get_open_dialog().find('.btn-file-upload div:contains("Link")').click();
  51. cy.get_open_dialog().find('.file-web-link input').type('https://github.com', { delay: 100, force: true });
  52. cy.server();
  53. cy.route('POST', '/api/method/upload_file').as('upload_file');
  54. cy.get_open_dialog().find('.btn-primary').click();
  55. cy.wait('@upload_file').its('response.body.message')
  56. .should('have.property', 'file_url', 'https://github.com');
  57. cy.get('.modal:visible').should('not.exist');
  58. });
  59. });