chore: _community e2e
This commit is contained in:
@@ -7,18 +7,17 @@ import { fileURLToPath } from 'url'
|
||||
import { initPageConsoleErrorCatch } from '../helpers.js'
|
||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||
import { initPayloadE2E } from '../helpers/configHelpers.js'
|
||||
import config from './config.js'
|
||||
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
const dirname = path.dirname(filename)
|
||||
|
||||
const { beforeAll, describe } = test
|
||||
|
||||
describe('Admin Panel', () => {
|
||||
let page: Page
|
||||
let url: AdminUrlUtil
|
||||
|
||||
beforeAll(async ({ browser }) => {
|
||||
const { serverURL } = await initPayloadE2E({ dirname })
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
const { payload, serverURL } = await initPayloadE2E({ config, dirname })
|
||||
url = new AdminUrlUtil(serverURL, 'posts')
|
||||
|
||||
const context = await browser.newContext()
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
import { spawn } from 'child_process'
|
||||
import getPort from 'get-port'
|
||||
import { nextDev } from 'next/dist/cli/next-dev.js'
|
||||
import path from 'path'
|
||||
|
||||
import type { SanitizedConfig } from '../../packages/payload/src/config/types.js'
|
||||
import type { Payload } from '../../packages/payload/src/index.js'
|
||||
|
||||
import { getPayload } from '../../packages/payload/src/index.js'
|
||||
import wait from '../../packages/payload/src/utilities/wait.js'
|
||||
|
||||
type Args = {
|
||||
config: Promise<SanitizedConfig>
|
||||
dirname: string
|
||||
}
|
||||
|
||||
type Result = {
|
||||
payload: Payload
|
||||
serverURL: string
|
||||
}
|
||||
|
||||
export async function initPayloadE2E({ dirname }: Args): Promise<Result> {
|
||||
export async function initPayloadE2E({ config, dirname }: Args): Promise<Result> {
|
||||
const port = await getPort()
|
||||
const serverURL = `http://localhost:${port}`
|
||||
process.env.NODE_OPTIONS = '--no-deprecation'
|
||||
@@ -21,6 +26,8 @@ export async function initPayloadE2E({ dirname }: Args): Promise<Result> {
|
||||
process.env.PAYLOAD_DROP_DATABASE = 'true'
|
||||
process.env.PORT = String(port)
|
||||
|
||||
const payload = await getPayload({ config })
|
||||
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = 'test'
|
||||
|
||||
@@ -33,29 +40,5 @@ export async function initPayloadE2E({ dirname }: Args): Promise<Result> {
|
||||
})
|
||||
|
||||
await wait(3000)
|
||||
return { serverURL }
|
||||
}
|
||||
|
||||
export async function initPayloadSpawn({ dirname }: Args): Promise<Result> {
|
||||
const port = await getPort()
|
||||
const serverURL = `http://localhost:${port}`
|
||||
|
||||
// Tried using a child process to get
|
||||
// turbopack to pick up our tsconfig aliases
|
||||
// but this didn't make a difference.
|
||||
// Keeping it here so we can continue to try.
|
||||
spawn('pnpm', ['dev', '--turbo'], {
|
||||
cwd: path.resolve(dirname, '../../'),
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_ENV: 'test',
|
||||
PORT: String(port),
|
||||
PAYLOAD_CONFIG_PATH: path.resolve(dirname, '../../config.js'),
|
||||
PAYLOAD_DROP_DATABASE: 'true',
|
||||
},
|
||||
})
|
||||
|
||||
await wait(3000)
|
||||
|
||||
return { serverURL }
|
||||
return { payload, serverURL }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user