diff --git a/e2e/cypress/integration/dashboard-xhr.spec.ts b/e2e/cypress/integration/dashboard-xhr.spec.ts index 4a093c517a..9cb0752f35 100644 --- a/e2e/cypress/integration/dashboard-xhr.spec.ts +++ b/e2e/cypress/integration/dashboard-xhr.spec.ts @@ -1,5 +1,6 @@ import { interceptCompanionUrlMetaRequest, + interceptCompanionUrlRequest, runRemoteUrlImageUploadTest, runRemoteUnsplashUploadTest, } from './reusable-tests.ts' @@ -57,6 +58,17 @@ describe('Dashboard with XHR', () => { }) }) + it('should upload unknown size files', () => { + cy.get('[data-cy="Url"]').click() + cy.get('.uppy-Url-input').type('http://localhost:4678/unknown-size') + cy.get('.uppy-Url-importButton').click() + interceptCompanionUrlRequest() + cy.get('.uppy-StatusBar-actionBtn--upload').click() + cy.wait('@url').then(() => { + cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete') + }) + }) + it('should upload remote image with Unsplash plugin', () => { runRemoteUnsplashUploadTest() }) diff --git a/e2e/cypress/integration/reusable-tests.ts b/e2e/cypress/integration/reusable-tests.ts index d311b60e39..39031d8281 100644 --- a/e2e/cypress/integration/reusable-tests.ts +++ b/e2e/cypress/integration/reusable-tests.ts @@ -1,6 +1,6 @@ /* global cy */ -const interceptCompanionUrlRequest = () => +export const interceptCompanionUrlRequest = () => cy .intercept({ method: 'POST', url: 'http://localhost:3020/url/get' }) .as('url') diff --git a/e2e/mock-server.mjs b/e2e/mock-server.mjs index 02d84b77da..6678de6ff8 100644 --- a/e2e/mock-server.mjs +++ b/e2e/mock-server.mjs @@ -13,6 +13,31 @@ const requestListener = (req, res) => { } case '/file-no-headers': break + + case '/unknown-size': { + res.setHeader('Content-Type', 'text/html; charset=UTF-8'); + res.setHeader('Transfer-Encoding', 'chunked'); + const chunkSize = 1e5; + if (req.method === 'GET') { + let i = 0; + const interval = setInterval(() => { + if (i >= 10) { // 1MB + clearInterval(interval); + res.end(); + return; + } + res.write(Buffer.from(Array.from({ length: chunkSize }, () => '1').join(''))); + res.write('\n'); + i++; + }, 10); + } else if (req.method === 'HEAD') { + res.end(); + } else { + throw new Error('Unhandled method') + } + } + break; + default: res.writeHead(404).end('Unhandled request') }