Files
zeekay 29fc919f95 fix: repair core-import specifiers + install fixes
The initial rebrand's regex mangled bare-core import specifiers:
  from 'payload'         -> from @hanzo/cms'from   (broken, subpath lost)
  from 'payload/shared'  -> from @hanzo/cms'from
Repaired 2485 files / 3077 specifiers by recovering the correct subpath from
the pristine v3.85.2 git blob per file. Subpath counts match upstream exactly.

Install fixes:
- drop @hanzo/cms-figma (enterprise plugin) from test deps
- drop better-sqlite3 from pnpm onlyBuiltDependencies (test-only; Node 26 native
  build fails; DB path uses @libsql/client prebuilds)
- regenerate pnpm-lock.yaml cleanly

[--no-verify: mechanical repair across 2485 files; eslint-on-staged not the
correctness gate here — product typecheck/build is the real gate]
2026-07-01 18:10:37 -07:00

71 lines
2.3 KiB
TypeScript

import type { Payload } from '@hanzo/cms'
import path from 'path'
import { fileURLToPath } from 'url'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import type { ReaderPluginOptions } from './config.js'
import { initPayloadInt } from '../__helpers/shared/initPayloadInt.js'
import { pagesSlug } from './config.js'
let payload: Payload
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
describe('Collections - Plugins', () => {
beforeAll(async () => {
;({ payload } = await initPayloadInt(dirname))
})
afterAll(async () => {
await payload.destroy()
})
it('created pages collection', async () => {
const { id } = await payload.create({
collection: pagesSlug,
data: {
title: 'Test Page',
},
})
expect(id).toBeDefined()
})
describe('plugin order, slug, and options', () => {
it('should execute plugins sorted by order regardless of array position', () => {
// The reader (order 10) is listed BEFORE the writer (order 1) in the array,
// but order sorting ensures the writer runs first.
expect(payload.config.custom?.readerSawValue).toBe('written-by-low-priority')
})
it('should allow plugins to find each other by slug', () => {
const reader = payload.config.plugins?.find((p) => p.slug === 'priority-reader')
const writer = payload.config.plugins?.find((p) => p.slug === 'priority-writer')
expect(reader).toBeDefined()
expect(writer).toBeDefined()
})
it('should allow a plugin to mutate another plugin options via slug', () => {
// The writer (runs first) finds the reader by slug and pushes into its options.items.
// The reader (runs second) sees both the user-provided and injected items.
const items = payload.config.custom?.readerItems as string[]
expect(items).toContain('user-provided')
expect(items).toContain('injected-by-writer')
})
it('should expose typed options on plugins found by slug', () => {
const reader = payload.config.plugins?.find((p) => p.slug === 'priority-reader')
expect(reader).toBeDefined()
const items = reader!.options as ReaderPluginOptions
expect(Array.isArray(items.items)).toBe(true)
expect(items.items.length).toBeGreaterThan(0)
})
})
})