get e2e and dev to work with test as new root directory

This commit is contained in:
Alessio Gravili
2024-03-19 11:31:50 -04:00
parent 9877fe2eed
commit 72c6200f17
103 changed files with 153 additions and 48 deletions

View File

@@ -1,8 +1,8 @@
{ {
"name": "@payloadcms/next", "name": "@payloadcms/next",
"version": "3.0.0-alpha.48", "version": "3.0.0-alpha.48",
"main": "./src/index.ts", "main": "./src/index.js",
"types": "./src/index.d.ts", "types": "./src/index.js",
"type": "module", "type": "module",
"bin": { "bin": {
"@payloadcms/next": "./dist/bin/index.js" "@payloadcms/next": "./dist/bin/index.js"
@@ -20,29 +20,15 @@
"prepublishOnly": "pnpm clean && pnpm turbo build" "prepublishOnly": "pnpm clean && pnpm turbo build"
}, },
"exports": { "exports": {
".": {
"import": "./src/index.js",
"require": "./src/index.js",
"types": "./src/index.js"
},
"./*": { "./*": {
"import": "./dist/exports/*.js", "import": "./src/exports/*.ts",
"require": "./dist/exports/*.js", "require": "./src/exports/*.ts",
"types": "./dist/exports/*.ts" "types": "./src/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"
} }
}, },
"devDependencies": { "devDependencies": {

View File

@@ -1 +0,0 @@
export { default as withPayload } from '../withPayload.js'

View 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'

View File

@@ -0,0 +1,2 @@
export { NotFoundView } from '../views/NotFound/index.js'
export { type GenerateViewMetadata, RootPage, generatePageMetadata } from '../views/Root/index.js'

View File

@@ -25,6 +25,7 @@ export const buildFormState = async ({ req }: { req: PayloadRequest }) => {
const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs
const incomingUserSlug = req.user?.collection const incomingUserSlug = req.user?.collection
console.log('teest')
const adminUserSlug = req.payload.config.admin.user const adminUserSlug = req.payload.config.admin.user
// If we have a user slug, test it against the functions // If we have a user slug, test it against the functions

3
pnpm-lock.yaml generated
View File

@@ -1511,6 +1511,9 @@ importers:
payload: payload:
specifier: workspace:* specifier: workspace:*
version: link:../packages/payload version: link:../packages/payload
typescript:
specifier: 5.4.2
version: 5.4.2
packages: packages:

15
test/.swcrc Normal file
View 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"
}
}

View File

@@ -1,7 +1,7 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import config from '@payload-config' import config from '@payload-config'
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */ /* 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 = { type Args = {
params: { params: {

View File

@@ -3,7 +3,7 @@ import type { Metadata } from 'next'
import config from '@payload-config' import config from '@payload-config'
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */ /* 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 = { type Args = {
params: { params: {

View File

@@ -1,7 +1,7 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
/* DO NOT MODIFY it because it could be re-written at any time. */ /* DO NOT MODIFY it because it could be re-written at any time. */
import config from '@payload-config' 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 GET = REST_GET(config)
export const POST = REST_POST(config) export const POST = REST_POST(config)

View File

@@ -1,6 +1,6 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
/* DO NOT MODIFY it because it could be re-written at any time. */ /* DO NOT MODIFY it because it could be re-written at any time. */
import config from '@payload-config' 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) export const GET = GRAPHQL_PLAYGROUND_GET(config)

View File

@@ -1,6 +1,6 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
/* DO NOT MODIFY it because it could be re-written at any time. */ /* DO NOT MODIFY it because it could be re-written at any time. */
import config from '@payload-config' 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) export const POST = GRAPHQL_POST(config)

View File

@@ -1,6 +1,6 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */ /* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
import configPromise from '@payload-config' 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. */ /* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */
import React from 'react' import React from 'react'

View File

@@ -1,11 +1,10 @@
import type { Page } from '@playwright/test' import type { Page } from '@playwright/test'
import type { Payload } from 'payload'
import { expect, test } from '@playwright/test' import { expect, test } from '@playwright/test'
import path from 'path' import path from 'path'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'url'
import type { Payload } from 'payload'
import { initPageConsoleErrorCatch, login, saveDocAndAssert } from '../helpers.js' import { initPageConsoleErrorCatch, login, saveDocAndAssert } from '../helpers.js'
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js' import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
import { initPayloadE2E } from '../helpers/initPayloadE2E.js' import { initPayloadE2E } from '../helpers/initPayloadE2E.js'

21
test/jest.config.js Normal file
View 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
View 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
View 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
},
}),
)

View File

@@ -4,7 +4,7 @@
"description": "Payload test suite", "description": "Payload test suite",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "pnpm -C \"../\" run dev", "dev": "cross-env NODE_OPTIONS=--no-deprecation node ./dev.js",
"test": "pnpm -C \"../\" run test", "test": "pnpm -C \"../\" run test",
"test:e2e": "pnpm -C \"../\" run test:e2e", "test:e2e": "pnpm -C \"../\" run test:e2e",
"test:int": "pnpm -C \"../\" run test:int", "test:int": "pnpm -C \"../\" run test:int",
@@ -12,6 +12,7 @@
}, },
"type": "module", "type": "module",
"devDependencies": { "devDependencies": {
"typescript": "5.4.2",
"@payloadcms/db-mongodb": "workspace:*", "@payloadcms/db-mongodb": "workspace:*",
"@payloadcms/db-postgres": "workspace:*", "@payloadcms/db-postgres": "workspace:*",
"@payloadcms/eslint-config": "workspace:*", "@payloadcms/eslint-config": "workspace:*",

View 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
View 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