feat: async plugins (#2030)
* feat: async plugins * wip: async config * fix: async config
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import type { IndexDirection, IndexOptions } from 'mongoose';
|
||||
import { initPayloadTest } from '../helpers/configHelpers';
|
||||
import { RESTClient } from '../helpers/rest';
|
||||
import config from '../uploads/config';
|
||||
import configPromise from '../uploads/config';
|
||||
import payload from '../../src';
|
||||
import { pointDoc } from './collections/Point';
|
||||
import type { ArrayField, GroupField, TabsField } from './payload-types';
|
||||
import { arrayFieldsSlug, arrayDefaultValue, arrayDoc } from './collections/Array';
|
||||
import { groupFieldsSlug, groupDefaultChild, groupDefaultValue, groupDoc } from './collections/Group';
|
||||
import { defaultText } from './collections/Text';
|
||||
@@ -17,6 +16,7 @@ let client;
|
||||
describe('Fields', () => {
|
||||
beforeAll(async () => {
|
||||
const { serverURL } = await initPayloadTest({ __dirname, init: { local: false } });
|
||||
const config = await configPromise;
|
||||
client = new RESTClient(config, { serverURL, defaultSlug: 'point-fields' });
|
||||
await client.login();
|
||||
});
|
||||
@@ -268,14 +268,14 @@ describe('Fields', () => {
|
||||
const collection = arrayFieldsSlug;
|
||||
|
||||
beforeAll(async () => {
|
||||
doc = await payload.create<ArrayField>({
|
||||
doc = await payload.create({
|
||||
collection,
|
||||
data: {},
|
||||
});
|
||||
});
|
||||
|
||||
it('should return undefined arrays when no data present', async () => {
|
||||
const document = await payload.create<ArrayField>({
|
||||
const document = await payload.create({
|
||||
collection: arrayFieldsSlug,
|
||||
data: arrayDoc,
|
||||
});
|
||||
@@ -284,7 +284,7 @@ describe('Fields', () => {
|
||||
});
|
||||
|
||||
it('should create with ids and nested ids', async () => {
|
||||
const docWithIDs = await payload.create<GroupField>({
|
||||
const docWithIDs = await payload.create({
|
||||
collection: groupFieldsSlug,
|
||||
data: groupDoc,
|
||||
});
|
||||
@@ -300,14 +300,14 @@ describe('Fields', () => {
|
||||
const localized = [{ text: 'unique' }];
|
||||
const enText = 'english';
|
||||
const esText = 'spanish';
|
||||
const { id } = await payload.create<ArrayField>({
|
||||
const { id } = await payload.create({
|
||||
collection,
|
||||
data: {
|
||||
localized,
|
||||
},
|
||||
});
|
||||
|
||||
const enDoc = await payload.update<ArrayField>({
|
||||
const enDoc = await payload.update({
|
||||
collection,
|
||||
id,
|
||||
locale: 'en',
|
||||
@@ -316,7 +316,7 @@ describe('Fields', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const esDoc = await payload.update<ArrayField>({
|
||||
const esDoc = await payload.update({
|
||||
collection,
|
||||
id,
|
||||
locale: 'es',
|
||||
@@ -342,7 +342,7 @@ describe('Fields', () => {
|
||||
let document;
|
||||
|
||||
beforeAll(async () => {
|
||||
document = await payload.create<GroupField>({
|
||||
document = await payload.create({
|
||||
collection: groupFieldsSlug,
|
||||
data: {},
|
||||
});
|
||||
@@ -358,7 +358,7 @@ describe('Fields', () => {
|
||||
let document;
|
||||
|
||||
beforeAll(async () => {
|
||||
document = await payload.create<TabsField>({
|
||||
document = await payload.create({
|
||||
collection: tabsSlug,
|
||||
data: tabsDoc,
|
||||
});
|
||||
@@ -395,7 +395,7 @@ describe('Fields', () => {
|
||||
});
|
||||
|
||||
it('should allow hooks on a named tab', async () => {
|
||||
const newDocument = await payload.create<TabsField>({
|
||||
const newDocument = await payload.create({
|
||||
collection: tabsSlug,
|
||||
data: tabsDoc,
|
||||
});
|
||||
@@ -406,7 +406,7 @@ describe('Fields', () => {
|
||||
});
|
||||
|
||||
it('should return empty object for groups when no data present', async () => {
|
||||
const doc = await payload.create<GroupField>({
|
||||
const doc = await payload.create({
|
||||
collection: groupFieldsSlug,
|
||||
data: groupDoc,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user