-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support React 18 in @uppy/react (#3680)
* Support React 18 * Remove unit tests * Create e2e tests Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
- Loading branch information
Showing
24 changed files
with
117 additions
and
862 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
/* eslint-disable react/react-in-jsx-scope */ | ||
import Uppy from '@uppy/core' | ||
/* eslint-disable-next-line no-unused-vars */ | ||
import React, { useState } from 'react' | ||
import { Dashboard, DashboardModal, DragDrop } from '@uppy/react' | ||
import ThumbnailGenerator from '@uppy/thumbnail-generator' | ||
|
||
import '@uppy/core/dist/style.css' | ||
import '@uppy/dashboard/dist/style.css' | ||
import '@uppy/drag-drop/dist/style.css' | ||
|
||
export default function App () { | ||
const uppyDashboard = new Uppy({ id: 'dashboard' }) | ||
const uppyModal = new Uppy({ id: 'modal' }) | ||
const uppyDragDrop = new Uppy({ id: 'drag-drop' }).use(ThumbnailGenerator) | ||
const [open, setOpen] = useState(false) | ||
|
||
// drag-drop has no visual output so we test it via the uppy instance | ||
window.uppy = uppyDragDrop | ||
|
||
return ( | ||
<div style={{ maxWidth: '30em', margin: '5em 0', display: 'grid', gridGap: '2em' }}> | ||
<button type="button" id="open" onClick={() => setOpen(!open)}> | ||
Open Modal | ||
</button> | ||
|
||
<Dashboard id="dashboard" uppy={uppyDashboard} /> | ||
<DashboardModal id="modal" open={open} uppy={uppyModal} /> | ||
<DragDrop id="drag-drop" uppy={uppyDragDrop} /> | ||
</div> | ||
) | ||
} |
File renamed without changes.
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,8 @@ | ||
/* eslint-disable react/react-in-jsx-scope */ | ||
import { createRoot } from 'react-dom/client' | ||
import App from './App.jsx' | ||
|
||
const container = document.getElementById('app') | ||
const root = createRoot(container) | ||
|
||
root.render(<App />) |
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
describe('@uppy/react', () => { | ||
beforeEach(() => { | ||
cy.visit('/react') | ||
cy.get('#dashboard .uppy-Dashboard-input').as('dashboard-input') | ||
cy.get('#modal .uppy-Dashboard-input').as('modal-input') | ||
cy.get('#drag-drop .uppy-DragDrop-input').as('dragdrop-input') | ||
}) | ||
|
||
it('should render Dashboard in React and show thumbnails', () => { | ||
cy.get('@dashboard-input').attachFile(['images/cat.jpg', 'images/traffic.jpg']) | ||
cy.get('#dashboard .uppy-Dashboard-Item-previewImg') | ||
.should('have.length', 2) | ||
.each((element) => expect(element).attr('src').to.include('blob:')) | ||
}) | ||
|
||
it('should render Modal in React and show thumbnails', () => { | ||
cy.get('#open').click() | ||
cy.get('@modal-input').attachFile(['images/cat.jpg', 'images/traffic.jpg']) | ||
cy.get('#modal .uppy-Dashboard-Item-previewImg') | ||
.should('have.length', 2) | ||
.each((element) => expect(element).attr('src').to.include('blob:')) | ||
}) | ||
|
||
it('should render Drag & Drop in React and create a thumbail with @uppy/thumbnail-generator', () => { | ||
const spy = cy.spy() | ||
|
||
cy.window().then(({ uppy }) => uppy.on('thumbnail:generated', spy)) | ||
cy.get('@dragdrop-input').attachFile(['images/cat.jpg', 'images/traffic.jpg']) | ||
// not sure how I can accurately wait for the thumbnail | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(1000).then(() => expect(spy).to.be.called) | ||
}) | ||
}) |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.