Files
payloadcms/test/_community/config.ts
Alessio Gravili 7880fb402a chore: playwright support (#5262)
* working playwright

* chore: use zipped, local build of playwright instead of patching it

* chore: remove bloat

* chore: get playwright and lexical to work by fixing imports from cjs modules
2024-03-08 10:56:13 -05:00

49 lines
1.3 KiB
TypeScript

import path from 'path'
import getFileByPath from '../../packages/payload/src/uploads/getFileByPath.js'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { devUser } from '../credentials.js'
import { MediaCollection } from './collections/Media/index.js'
import { PostsCollection, postsSlug } from './collections/Posts/index.js'
import { MenuGlobal } from './globals/Menu/index.js'
export default buildConfigWithDefaults({
// ...extend config here
collections: [PostsCollection, MediaCollection],
globals: [
MenuGlobal,
// ...add more globals here
],
graphQL: {
schemaOutputFile: './test/_community/schema.graphql',
},
onInit: async (payload) => {
console.log('onInit')
await payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
await payload.create({
collection: postsSlug,
data: {
text: 'example post',
},
})
// Create image
const imageFilePath = path.resolve(process.cwd(), './test/uploads/image.png')
const imageFile = await getFileByPath(imageFilePath)
const { id: uploadedImage } = await payload.create({
collection: 'media',
data: {},
file: imageFile,
})
},
})