Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Companion: bring back default upload protocol (#3967)
* add (failing) e2e test for remote xhr (multipart) regression caused by #3834 * Revert "do not use a default upload protocol" This reverts commit c7e61dd. * add note on todo * dry code a bit * explicitly add protocol: 'multipart' in the client * fix review comment
- Loading branch information
Showing
11 changed files
with
97 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Uppy } from '@uppy/core' | ||
import Dashboard from '@uppy/dashboard' | ||
import XHRUpload from '@uppy/xhr-upload' | ||
import Unsplash from '@uppy/unsplash' | ||
import Url from '@uppy/url' | ||
|
||
import '@uppy/core/dist/style.css' | ||
import '@uppy/dashboard/dist/style.css' | ||
|
||
const companionUrl = 'http://localhost:3020' | ||
const uppy = new Uppy() | ||
.use(Dashboard, { target: '#app', inline: true }) | ||
.use(XHRUpload, { endpoint: 'https://xhr-server.herokuapp.com/upload', limit: 6 }) | ||
.use(Url, { target: Dashboard, companionUrl }) | ||
.use(Unsplash, { target: Dashboard, companionUrl }) | ||
|
||
// Keep this here to access uppy in tests | ||
window.uppy = uppy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>dashboard-xhr</title> | ||
<script defer type="module" src="app.js"></script> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { interceptCompanionUrlRequest, interceptCompanionUnsplashRequest, runRemoteUrlImageUploadTest, runRemoteUnsplashUploadTest } from './reusable-tests' | ||
|
||
describe('Dashboard with XHR', () => { | ||
beforeEach(() => { | ||
cy.visit('/dashboard-xhr') | ||
interceptCompanionUrlRequest() | ||
interceptCompanionUnsplashRequest() | ||
}) | ||
|
||
it('should upload remote image with URL plugin', () => { | ||
runRemoteUrlImageUploadTest() | ||
}) | ||
|
||
it('should upload remote image with Unsplash plugin', () => { | ||
runRemoteUnsplashUploadTest() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* global cy */ | ||
|
||
export const interceptCompanionUrlRequest = () => cy.intercept('http://localhost:3020/url/*').as('url') | ||
export const interceptCompanionUnsplashRequest = () => cy.intercept('http://localhost:3020/search/unsplash/*').as('unsplash') | ||
|
||
export function runRemoteUrlImageUploadTest () { | ||
cy.get('[data-cy="Url"]').click() | ||
cy.get('.uppy-Url-input').type('https://raw.githubusercontent.com/transloadit/uppy/main/e2e/cypress/fixtures/images/cat.jpg') | ||
cy.get('.uppy-Url-importButton').click() | ||
cy.get('.uppy-StatusBar-actionBtn--upload').click() | ||
cy.wait('@url') | ||
cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete') | ||
} | ||
|
||
export function runRemoteUnsplashUploadTest () { | ||
cy.get('[data-cy="Unsplash"]').click() | ||
cy.get('.uppy-SearchProvider-input').type('book') | ||
cy.get('.uppy-SearchProvider-searchButton').click() | ||
cy.wait('@unsplash') | ||
// Test that the author link is visible | ||
cy.get('.uppy-ProviderBrowserItem') | ||
.first() | ||
.within(() => { | ||
cy.root().click() | ||
// We have hover states that show the author | ||
// but we don't have hover in e2e, so we focus after the click | ||
// to get the same effect. Also tests keyboard users this way. | ||
cy.get('input[type="checkbox"]').focus() | ||
cy.get('a').should('have.css', 'display', 'block') | ||
}) | ||
cy.get('.uppy-c-btn-primary').click() | ||
cy.get('.uppy-StatusBar-actionBtn--upload').click() | ||
cy.wait('@unsplash') | ||
cy.get('.uppy-StatusBar-statusPrimary').should('contain', 'Complete') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters