import type { Payload } from 'payload' import config from '@payload-config' import { createPayloadRequest, getPayload } from 'payload' import { afterAll, beforeAll, describe, expect, test } from 'vitest' // import { customEndpointHandler } from '../src/endpoints/customEndpointHandler.js' let payload: Payload afterAll(async () => { await payload.destroy() }) beforeAll(async () => { payload = await getPayload({ config }) }) describe('Plugin integration tests', () => { test('should have mailing plugin initialized', async () => { expect(payload).toBeDefined() expect((payload as any).mailing).toBeDefined() expect((payload as any).mailing.service).toBeDefined() expect((payload as any).mailing.config).toBeDefined() }) test('can create post with custom text field added by plugin', async () => { const post = await payload.create({ collection: 'posts', data: { addedByPlugin: 'added by plugin', }, }) expect(post.addedByPlugin).toBe('added by plugin') }) test('plugin creates and seeds plugin-collection', async () => { expect(payload.collections['plugin-collection']).toBeDefined() const { docs } = await payload.find({ collection: 'plugin-collection' }) expect(docs).toHaveLength(1) }) })