get e2e and dev to work with test as new root directory
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@payloadcms/next",
|
||||
"version": "3.0.0-alpha.48",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.d.ts",
|
||||
"main": "./src/index.js",
|
||||
"types": "./src/index.js",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"@payloadcms/next": "./dist/bin/index.js"
|
||||
@@ -20,29 +20,15 @@
|
||||
"prepublishOnly": "pnpm clean && pnpm turbo build"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./src/index.js",
|
||||
"require": "./src/index.js",
|
||||
"types": "./src/index.js"
|
||||
},
|
||||
"./*": {
|
||||
"import": "./dist/exports/*.js",
|
||||
"require": "./dist/exports/*.js",
|
||||
"types": "./dist/exports/*.ts"
|
||||
},
|
||||
"./utilities/*": {
|
||||
"import": "./dist/utilities/*.js",
|
||||
"require": "./dist/utilities/*.js",
|
||||
"types": "./src/utilities/*.ts"
|
||||
},
|
||||
"./layouts/*": {
|
||||
"import": "./dist/layouts/*.js",
|
||||
"require": "./dist/layouts/*.js",
|
||||
"types": "./src/layouts/*.ts"
|
||||
},
|
||||
"./views/*": {
|
||||
"import": "./dist/views/*.js",
|
||||
"require": "./dist/views/*.js",
|
||||
"types": "./src/views/*.ts"
|
||||
},
|
||||
"./routes": {
|
||||
"import": "./dist/routes/index.js",
|
||||
"require": "./dist/routes/index.js"
|
||||
"import": "./src/exports/*.ts",
|
||||
"require": "./src/exports/*.ts",
|
||||
"types": "./src/exports/*.ts"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export { default as withPayload } from '../withPayload.js'
|
||||
8
packages/next/src/exports/routes.ts
Normal file
8
packages/next/src/exports/routes.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from '../routes/graphql/index.js'
|
||||
|
||||
export {
|
||||
DELETE as REST_DELETE,
|
||||
GET as REST_GET,
|
||||
PATCH as REST_PATCH,
|
||||
POST as REST_POST,
|
||||
} from '../routes/rest/index.js'
|
||||
2
packages/next/src/exports/views.ts
Normal file
2
packages/next/src/exports/views.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { NotFoundView } from '../views/NotFound/index.js'
|
||||
export { type GenerateViewMetadata, RootPage, generatePageMetadata } from '../views/Root/index.js'
|
||||
@@ -25,6 +25,7 @@ export const buildFormState = async ({ req }: { req: PayloadRequest }) => {
|
||||
const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs
|
||||
|
||||
const incomingUserSlug = req.user?.collection
|
||||
console.log('teest')
|
||||
const adminUserSlug = req.payload.config.admin.user
|
||||
|
||||
// If we have a user slug, test it against the functions
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -1511,6 +1511,9 @@ importers:
|
||||
payload:
|
||||
specifier: workspace:*
|
||||
version: link:../packages/payload
|
||||
typescript:
|
||||
specifier: 5.4.2
|
||||
version: 5.4.2
|
||||
|
||||
packages:
|
||||
|
||||
|
||||
15
test/.swcrc
Normal file
15
test/.swcrc
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/swcrc",
|
||||
"sourceMaps": "inline",
|
||||
"jsc": {
|
||||
"target": "esnext",
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"tsx": true,
|
||||
"dts": true
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "es6"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
import config from '@payload-config'
|
||||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||
import { NotFoundView } from '@payloadcms/next/views/NotFound/index.js'
|
||||
import { NotFoundView } from '@payloadcms/next/views'
|
||||
|
||||
type Args = {
|
||||
params: {
|
||||
@@ -3,7 +3,7 @@ import type { Metadata } from 'next'
|
||||
|
||||
import config from '@payload-config'
|
||||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||
import { RootPage, generatePageMetadata } from '@payloadcms/next/views/Root/index.js'
|
||||
import { RootPage, generatePageMetadata } from '@payloadcms/next/views'
|
||||
|
||||
type Args = {
|
||||
params: {
|
||||
@@ -1,7 +1,7 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
/* DO NOT MODIFY it because it could be re-written at any time. */
|
||||
import config from '@payload-config'
|
||||
import { REST_DELETE, REST_GET, REST_PATCH, REST_POST } from '@payloadcms/next/routes/index.js'
|
||||
import { REST_DELETE, REST_GET, REST_PATCH, REST_POST } from '@payloadcms/next/routes'
|
||||
|
||||
export const GET = REST_GET(config)
|
||||
export const POST = REST_POST(config)
|
||||
@@ -1,6 +1,6 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
/* DO NOT MODIFY it because it could be re-written at any time. */
|
||||
import config from '@payload-config'
|
||||
import { GRAPHQL_PLAYGROUND_GET } from '@payloadcms/next/routes/index.js'
|
||||
import { GRAPHQL_PLAYGROUND_GET } from '@payloadcms/next/routes'
|
||||
|
||||
export const GET = GRAPHQL_PLAYGROUND_GET(config)
|
||||
@@ -1,6 +1,6 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
/* DO NOT MODIFY it because it could be re-written at any time. */
|
||||
import config from '@payload-config'
|
||||
import { GRAPHQL_POST } from '@payloadcms/next/routes/index.js'
|
||||
import { GRAPHQL_POST } from '@payloadcms/next/routes'
|
||||
|
||||
export const POST = GRAPHQL_POST(config)
|
||||
@@ -1,6 +1,6 @@
|
||||
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
|
||||
import configPromise from '@payload-config'
|
||||
import { RootLayout } from '@payloadcms/next/layouts/Root/index.js'
|
||||
import { RootLayout } from '@payloadcms/next/layouts'
|
||||
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
|
||||
import React from 'react'
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import type { Page } from '@playwright/test'
|
||||
import type { Payload } from 'payload'
|
||||
|
||||
import { expect, test } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
import type { Payload } from 'payload'
|
||||
|
||||
import { initPageConsoleErrorCatch, login, saveDocAndAssert } from '../helpers.js'
|
||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||
|
||||
21
test/jest.config.js
Normal file
21
test/jest.config.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/** @type {import('jest').Config} */
|
||||
const customJestConfig = {
|
||||
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
|
||||
moduleNameMapper: {
|
||||
'\\.(css|scss)$': '<rootDir>/helpers/mocks/emptyModule.js',
|
||||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
||||
'<rootDir>/test/helpers/mocks/fileMock.js',
|
||||
'^(\\.{1,2}/.*)\\.js$': '$1',
|
||||
},
|
||||
reporters: ['default', ['github-actions', { silent: false }], 'summary'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['<rootDir>/**/*int.spec.ts'],
|
||||
testTimeout: 90000,
|
||||
transform: {
|
||||
'^.+\\.(t|j)sx?$': ['@swc/jest'],
|
||||
},
|
||||
verbose: true,
|
||||
}
|
||||
|
||||
export default customJestConfig
|
||||
5
test/next-env.d.ts
vendored
Normal file
5
test/next-env.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
34
test/next.config.mjs
Normal file
34
test/next.config.mjs
Normal file
@@ -0,0 +1,34 @@
|
||||
import bundleAnalyzer from '@next/bundle-analyzer'
|
||||
|
||||
import { withPayload } from '@payloadcms/next'
|
||||
|
||||
const withBundleAnalyzer = bundleAnalyzer({
|
||||
enabled: process.env.ANALYZE === 'true',
|
||||
})
|
||||
|
||||
// eslint-disable-next-line no-restricted-exports
|
||||
export default withBundleAnalyzer(
|
||||
withPayload({
|
||||
reactStrictMode: false,
|
||||
async redirects() {
|
||||
return [
|
||||
{
|
||||
destination: '/admin',
|
||||
permanent: true,
|
||||
source: '/',
|
||||
},
|
||||
]
|
||||
},
|
||||
images: {
|
||||
domains: ['localhost'],
|
||||
},
|
||||
webpack: (webpackConfig) => {
|
||||
webpackConfig.resolve.extensionAlias = {
|
||||
'.cjs': ['.cts', '.cjs'],
|
||||
'.js': ['.ts', '.tsx', '.js', '.jsx'],
|
||||
'.mjs': ['.mts', '.mjs'],
|
||||
}
|
||||
return webpackConfig
|
||||
},
|
||||
}),
|
||||
)
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "Payload test suite",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "pnpm -C \"../\" run dev",
|
||||
"dev": "cross-env NODE_OPTIONS=--no-deprecation node ./dev.js",
|
||||
"test": "pnpm -C \"../\" run test",
|
||||
"test:e2e": "pnpm -C \"../\" run test:e2e",
|
||||
"test:int": "pnpm -C \"../\" run test:int",
|
||||
@@ -12,6 +12,7 @@
|
||||
},
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"typescript": "5.4.2",
|
||||
"@payloadcms/db-mongodb": "workspace:*",
|
||||
"@payloadcms/db-postgres": "workspace:*",
|
||||
"@payloadcms/eslint-config": "workspace:*",
|
||||
|
||||
10
test/playwright.bail.config.ts
Normal file
10
test/playwright.bail.config.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { PlaywrightTestConfig } from '@playwright/test'
|
||||
|
||||
import baseConfig from './playwright.config.js'
|
||||
|
||||
const config: PlaywrightTestConfig = {
|
||||
...baseConfig,
|
||||
maxFailures: 1,
|
||||
}
|
||||
|
||||
export default config
|
||||
17
test/playwright.config.ts
Normal file
17
test/playwright.config.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { defineConfig } from '@playwright/test'
|
||||
|
||||
export default defineConfig({
|
||||
// Look for test files in the "test" directory, relative to this configuration file
|
||||
testDir: '',
|
||||
testMatch: '*e2e.spec.ts',
|
||||
timeout: 180000, // 3 minutes
|
||||
use: {
|
||||
screenshot: 'only-on-failure',
|
||||
trace: 'retain-on-failure',
|
||||
video: 'retain-on-failure',
|
||||
},
|
||||
expect: {
|
||||
timeout: 45000,
|
||||
},
|
||||
workers: 16,
|
||||
})
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user