Files
ipal-kit/reference/e2e/late-staff-fixture.ts
T

24 lines
1.2 KiB
TypeScript

import type { Config, Plugin } from 'payload'
/**
* Test fixture, on only with E2E_LATE_STAFF=1 (e2e/late-staff.spec.ts): a plugin listed AFTER ipalKit that adds
* a staff collection (`late-staff`, named in `access.staffCollections`) and a visitor collection with open
* sign-up. ipalKit has already run when these collections appear, so it must give them its account rules when
* the config goes live — and it must do so in a BUILT site too, where bundlers rename every function.
* Never part of a real site: the starter drops `e2e/` and the lines that use this file.
*/
export const E2E_LATE_STAFF = process.env.E2E_LATE_STAFF === '1'
export const e2eLateStaff: Plugin = (config: Config) =>
E2E_LATE_STAFF
? {
...config,
collections: [
...(config.collections ?? []),
// no access rules at all: Payload's defaults ("any logged-in user") are what ipalKit must replace
{ slug: 'late-staff', auth: true, fields: [{ name: 'roles', type: 'select', hasMany: true, options: ['user', 'editor', 'admin'], saveToJWT: true }], versions: true },
{ slug: 'e2e-visitors', access: { create: () => true }, auth: true, fields: [] },
],
}
: config