Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Failing test for 59195 #59210

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/e2e/react-dnd-compile/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
transpilePackages: ['@react-dnd/invariant'],
}

module.exports = nextConfig
34 changes: 34 additions & 0 deletions test/e2e/react-dnd-compile/pages/DragDropProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'react'
import { createDragDropManager } from 'dnd-core'
import { HTML5Backend } from 'react-dnd-html5-backend'
import { DndContext } from 'react-dnd'

let dndHTML5BackendContext = null

function getOrCreateDndContext() {
if (dndHTML5BackendContext) {
return dndHTML5BackendContext
}

function simpleBackend(manager) {
return HTML5Backend(manager)
}

const dndContext = {
dragDropManager: createDragDropManager(simpleBackend),
}

dndHTML5BackendContext = dndContext

return dndContext
}

export default function DragDropProvider(props) {
const dndContextValue = getOrCreateDndContext()

return (
<DndContext.Provider value={dndContextValue}>
{props.children}
</DndContext.Provider>
)
}
3 changes: 3 additions & 0 deletions test/e2e/react-dnd-compile/pages/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />
}
3 changes: 3 additions & 0 deletions test/e2e/react-dnd-compile/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <h1 id="index-page-title">Hello, Next.js!</h1>
}
9 changes: 9 additions & 0 deletions test/e2e/react-dnd-compile/pages/oom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import DragDropProvider from './DragDropProvider'

export default function Page() {
return (
<DragDropProvider>
<h1 id="oom-page-title">Hello, Next.js!</h1>
</DragDropProvider>
)
}
26 changes: 26 additions & 0 deletions test/e2e/react-dnd-compile/react-dnd-compile.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createNextDescribe } from 'e2e-utils'

createNextDescribe(
'react-dnd-compile',
{
files: __dirname,
dependencies: {
'@react-dnd/asap': '^5.0.1',
'@react-dnd/invariant': '^4.0.2',
'dnd-core': '14.0.1',
'react-dnd': '^16.0.1',
'react-dnd-html5-backend': '^16.0.1',
},
},
({ next }) => {
it('should work', async () => {
const $ = await next.render$('/')
expect($('#index-page-title').text()).toBe('Hello, Next.js!')
})

it('should work on react-dnd import page', async () => {
const $ = await next.render$('/oom')
expect($('#oom-page-title').text()).toBe('Hello, Next.js!')
})
}
)