Fix/alpha/int tests (#5311)

* chore: converts dynamic imports to esm require

* chore: adjusts require and import usage

* chore: reverts bin script change

* chore: adjust dataloaded tests to use slate editor

* fix: converts custom auth strategy

* chore: fixes to form builder int test config

* chore: adjusts plugin-stripe and int tests

---------

Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
This commit is contained in:
Dan Ribbens
2024-03-12 16:27:43 -04:00
committed by GitHub
parent 8436dd5851
commit 04fcf57d0a
18 changed files with 202 additions and 253 deletions

View File

@@ -1,6 +1,7 @@
import type { Block } from '../../packages/payload/src/fields/config/types.js'
import formBuilder, { fields as formFields } from '../../packages/plugin-form-builder/src/index.js'
import { slateEditor } from '../../packages/richtext-slate/src/index.js'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { devUser } from '../credentials.js'
import { Pages } from './collections/Pages.js'
@@ -9,20 +10,21 @@ import { seed } from './seed/index.js'
const colorField: Block = {
slug: 'color',
labels: {
singular: 'Color',
plural: 'Colors',
},
fields: [
{
name: 'value',
type: 'text',
},
],
labels: {
plural: 'Colors',
singular: 'Color',
},
}
export default buildConfigWithDefaults({
collections: [Pages, Users],
editor: slateEditor({}),
localization: {
defaultLocale: 'en',
fallback: true,
@@ -43,27 +45,14 @@ export default buildConfigWithDefaults({
formBuilder({
// handlePayment: handleFormPayments,
// beforeEmail: prepareFormEmails,
redirectRelationships: ['pages'],
formOverrides: {
// labels: {
// singular: 'Contact Form',
// plural: 'Contact Forms'
// },
fields: [
{
name: 'custom',
type: 'text',
},
],
},
fields: {
payment: true,
colorField,
payment: true,
text: {
...formFields.text,
labels: {
singular: 'Custom Text Field',
plural: 'Custom Text Fields',
singular: 'Custom Text Field',
},
},
// payment: {
@@ -78,6 +67,19 @@ export default buildConfigWithDefaults({
// },
// },
},
formOverrides: {
// labels: {
// singular: 'Contact Form',
// plural: 'Contact Forms'
// },
fields: [
{
name: 'custom',
type: 'text',
},
],
},
redirectRelationships: ['pages'],
}),
],
})

View File

@@ -18,19 +18,19 @@ describe('@payloadcms/plugin-form-builder', () => {
payload = await getPayload({ config })
const formConfig: Omit<Form, 'createdAt' | 'id' | 'updatedAt'> = {
title: 'Test Form',
fields: [
{
name: 'name',
blockType: 'text',
},
],
confirmationMessage: [
{
type: 'text',
text: 'Confirmed.',
},
],
fields: [
{
name: 'name',
blockType: 'text',
},
],
title: 'Test Form',
}
form = (await payload.create({
@@ -54,19 +54,19 @@ describe('@payloadcms/plugin-form-builder', () => {
describe('form building', () => {
it('can create a simple form', async () => {
const formConfig: Omit<Form, 'createdAt' | 'id' | 'updatedAt'> = {
title: 'Test Form',
fields: [
{
name: 'name',
blockType: 'text',
},
],
confirmationMessage: [
{
type: 'text',
text: 'Confirmed.',
},
],
fields: [
{
name: 'name',
blockType: 'text',
},
],
title: 'Test Form',
}
const testForm = await payload.create({
@@ -81,14 +81,14 @@ describe('@payloadcms/plugin-form-builder', () => {
it('can use form overrides', async () => {
const formConfig: Omit<Form, 'createdAt' | 'id' | 'updatedAt'> = {
custom: 'custom',
title: 'Test Form',
confirmationMessage: [
{
type: 'text',
text: 'Confirmed.',
},
],
custom: 'custom',
title: 'Test Form',
}
const testForm = await payload.create({
@@ -142,7 +142,7 @@ describe('@payloadcms/plugin-form-builder', () => {
await expect(req).rejects.toThrow(ValidationError)
})
it('replaces curly braces with data when using slate serializer', async () => {
it('replaces curly braces with data when using slate serializer', () => {
const mockName = 'Test Submission'
const mockEmail = 'dev@payloadcms.com'
@@ -150,12 +150,12 @@ describe('@payloadcms/plugin-form-builder', () => {
[
{ text: 'Welcome {{name}}. Here is a dynamic ' },
{
type: 'link',
children: [
{
text: 'link',
},
],
type: 'link',
url: 'www.test.com?email={{email}}',
},
],
@@ -177,24 +177,17 @@ describe('@payloadcms/plugin-form-builder', () => {
{
root: {
type: 'root',
format: '',
indent: 0,
version: 1,
children: [
{
type: 'paragraph',
direction: 'ltr',
format: '',
indent: 0,
version: 1,
children: [
{
type: 'text',
detail: 0,
format: 0,
mode: 'normal',
style: '',
text: 'Name: {{name}}',
type: 'text',
version: 1,
},
{
@@ -202,18 +195,25 @@ describe('@payloadcms/plugin-form-builder', () => {
version: 1,
},
{
type: 'text',
detail: 0,
format: 0,
mode: 'normal',
style: '',
text: 'Email: {{email}}',
type: 'text',
version: 1,
},
],
direction: 'ltr',
format: '',
indent: 0,
version: 1,
},
],
direction: 'ltr',
format: '',
indent: 0,
version: 1,
},
},
[