Files
payloadcms/test/fields-relationship/config.ts
Alessio Gravili 545d870650 chore: fix various e2e test setup issues (#12670)
I noticed a few issues when running e2e tests that will be resolved by
this PR:

- Most important: for some test suites (fields, fields-relationship,
versions, queues, lexical), the database was cleared and seeded
**twice** in between each test run. This is because the onInit function
was running the clear and seed script, when it should only have been
running the seed script. Clearing the database / the snapshot workflow
is being done by the reInit endpoint, which then calls onInit to seed
the actual data.
- The slowest part of `clearAndSeedEverything` is recreating indexes on
mongodb. This PR slightly improves performance here by:
- Skipping this process for the built-in `['payload-migrations',
'payload-preferences', 'payload-locked-documents']` collections
- Previously we were calling both `createIndexes` and `ensureIndexes`.
This was unnecessary - `ensureIndexes` is a deprecated alias of
`createIndexes`. This PR changes it to only call `createIndexes`
- Makes the reinit endpoint accept GET requests instead of POST requests
- this makes it easier to debug right in the browser
- Some typescript fixes
- Adds a `dev:memorydb` script to the package.json. For some reason,
`dev` is super unreliable on mongodb locally when running e2e tests - it
frequently fails during index creation. Using the memorydb fixes this
issue, with the bonus of more closely resembling the CI environment
- Previously, you were unable to run test suites using turbopack +
postgres. This fixes it, by explicitly installing `pg` as devDependency
in our monorepo
- Fixes jest open handles warning
2025-06-04 17:34:37 -03:00

59 lines
1.9 KiB
TypeScript

import { fileURLToPath } from 'node:url'
import path from 'path'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { Collection1 } from './collections/Collection1/index.js'
import { Collection2 } from './collections/Collection2/index.js'
import { RelationshipFilterFalse } from './collections/FilterFalse/index.js'
import { RelationshipFilterTrue } from './collections/FilterTrue/index.js'
import { MixedMedia } from './collections/MixedMedia/index.js'
import { Podcast } from './collections/Podcast/index.js'
import { Relation1 } from './collections/Relation1/index.js'
import { Relation2 } from './collections/Relation2/index.js'
import { Relationship } from './collections/Relationship/index.js'
import { RelationWithTitle } from './collections/RelationWithTitle/index.js'
import { Restricted } from './collections/Restricted/index.js'
import { RelationshipUpdatedExternally } from './collections/UpdatedExternally/index.js'
import { Versions } from './collections/Versions/index.js'
import { Video } from './collections/Video/index.js'
import { seed } from './seed.js'
export default buildConfigWithDefaults({
admin: {
importMap: {
baseDir: path.resolve(dirname),
},
},
collections: [
Relationship,
RelationshipFilterFalse,
RelationshipFilterTrue,
Relation1,
Relation2,
Restricted,
RelationWithTitle,
RelationshipUpdatedExternally,
Collection1,
Collection2,
Video,
Podcast,
MixedMedia,
Versions,
],
localization: {
locales: ['en'],
defaultLocale: 'en',
fallback: true,
},
onInit: async (payload) => {
if (process.env.SEED_IN_CONFIG_ONINIT !== 'false') {
await seed(payload)
}
},
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
})