Files
payloadcms/test/fields-relationship/config.ts
Jacob Fletcher 694c76d51a test: cleans up fields-relationship test suite (#11003)
The `fields-relationship` test suite is disorganized to the point of
being unusable. This makes it very difficult to digest at a high level
and add new tests.

This PR cleans it up in the following ways:

- Moves collection configs to their own standalone files
- Moves the seed function to its own file
- Consolidates collection slugs in their own file
- Uses generated types instead of defining them statically
- Wraps the `filterOptions` e2e tests within a describe block

Related, there are three distinct test suites where we manage
relationships: `relationships`, `fields-relationship`, and `fields >
relationships`. In the future we ought to consolidate at least two of
these. IMO the `fields > relationship` suite should remain in place for
general _component level_ UI tests for the field itself, whereas the
other suite could run the integration tests and test the more complex UI
patterns that exist outside of the field component.
2025-02-05 17:03:35 -05: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 { clearAndSeedEverything } 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 clearAndSeedEverything(payload)
}
},
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
})