chore: run prettier on entire test dir
This commit is contained in:
@@ -1,24 +1,26 @@
|
|||||||
import { buildConfig } from '../buildConfig';
|
import { buildConfig } from '../buildConfig';
|
||||||
|
|
||||||
export default buildConfig({
|
export default buildConfig({
|
||||||
collections: [{
|
collections: [
|
||||||
slug: 'arrays',
|
{
|
||||||
fields: [
|
slug: 'arrays',
|
||||||
{
|
fields: [
|
||||||
name: 'array',
|
{
|
||||||
type: 'array',
|
name: 'array',
|
||||||
fields: [
|
type: 'array',
|
||||||
{
|
fields: [
|
||||||
type: 'text',
|
{
|
||||||
name: 'required',
|
type: 'text',
|
||||||
required: true,
|
name: 'required',
|
||||||
},
|
required: true,
|
||||||
{
|
},
|
||||||
type: 'text',
|
{
|
||||||
name: 'optional',
|
type: 'text',
|
||||||
},
|
name: 'optional',
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
}],
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,9 +36,7 @@ describe('array-update', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const arrayWithExistingValues = [
|
const arrayWithExistingValues = [...doc.array];
|
||||||
...doc.array,
|
|
||||||
];
|
|
||||||
|
|
||||||
const updatedText = 'this is some new text for the first item in array';
|
const updatedText = 'this is some new text for the first item in array';
|
||||||
|
|
||||||
@@ -47,7 +45,6 @@ describe('array-update', () => {
|
|||||||
required: updatedText,
|
required: updatedText,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const updatedDoc = await payload.update<ArrayCollection>({
|
const updatedDoc = await payload.update<ArrayCollection>({
|
||||||
id: doc.id,
|
id: doc.id,
|
||||||
collection,
|
collection,
|
||||||
|
|||||||
@@ -6,14 +6,15 @@ export default buildConfig({
|
|||||||
admin: {
|
admin: {
|
||||||
user: 'users',
|
user: 'users',
|
||||||
},
|
},
|
||||||
collections: [{
|
collections: [
|
||||||
slug,
|
{
|
||||||
auth: {
|
slug,
|
||||||
verify: true,
|
auth: {
|
||||||
useAPIKey: true,
|
verify: true,
|
||||||
maxLoginAttempts: 2,
|
useAPIKey: true,
|
||||||
|
maxLoginAttempts: 2,
|
||||||
|
},
|
||||||
|
fields: [],
|
||||||
},
|
},
|
||||||
fields: [],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { initPayloadTest } from '../helpers/configHelpers';
|
|||||||
import { firstRegister } from '../helpers';
|
import { firstRegister } from '../helpers';
|
||||||
import { slug } from './config';
|
import { slug } from './config';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Auth
|
* TODO: Auth
|
||||||
* change password
|
* change password
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import merge from 'deepmerge';
|
|||||||
import { Config, SanitizedConfig } from '../src/config/types';
|
import { Config, SanitizedConfig } from '../src/config/types';
|
||||||
import { buildConfig as buildPayloadConfig } from '../src/config/build';
|
import { buildConfig as buildPayloadConfig } from '../src/config/build';
|
||||||
|
|
||||||
|
|
||||||
const baseConfig: Config = {
|
const baseConfig: Config = {
|
||||||
typescript: {
|
typescript: {
|
||||||
outputFile: process.env.PAYLOAD_TS_OUTPUT_PATH,
|
outputFile: process.env.PAYLOAD_TS_OUTPUT_PATH,
|
||||||
@@ -12,9 +11,10 @@ const baseConfig: Config = {
|
|||||||
export function buildConfig(overrides?: Partial<Config>): SanitizedConfig {
|
export function buildConfig(overrides?: Partial<Config>): SanitizedConfig {
|
||||||
if (process.env.NODE_ENV === 'test') {
|
if (process.env.NODE_ENV === 'test') {
|
||||||
baseConfig.admin = {
|
baseConfig.admin = {
|
||||||
...baseConfig.admin || {},
|
...(baseConfig.admin || {}),
|
||||||
webpack: (config) => {
|
webpack: (config) => {
|
||||||
const existingConfig = typeof overrides?.admin?.webpack === 'function' ? overrides.admin.webpack(config) : config;
|
const existingConfig =
|
||||||
|
typeof overrides?.admin?.webpack === 'function' ? overrides.admin.webpack(config) : config;
|
||||||
return {
|
return {
|
||||||
...existingConfig,
|
...existingConfig,
|
||||||
cache: {
|
cache: {
|
||||||
@@ -30,6 +30,5 @@ export function buildConfig(overrides?: Partial<Config>): SanitizedConfig {
|
|||||||
baseConfig.admin.disable = true;
|
baseConfig.admin.disable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return buildPayloadConfig(merge(baseConfig, overrides || {}));
|
return buildPayloadConfig(merge(baseConfig, overrides || {}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,9 +191,7 @@ describe('collections-graphql', () => {
|
|||||||
const response = await client.request(query);
|
const response = await client.request(query);
|
||||||
const { docs } = response.Posts;
|
const { docs } = response.Posts;
|
||||||
|
|
||||||
expect(docs).toContainEqual(
|
expect(docs).toContainEqual(expect.objectContaining({ id: withDescription.id, title: withDescription.title }));
|
||||||
expect.objectContaining({ id: withDescription.id, title: withDescription.title }),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('exists - false', async () => {
|
it('exists - false', async () => {
|
||||||
|
|||||||
@@ -5,27 +5,29 @@ import { buildConfig } from '../buildConfig';
|
|||||||
export const slug = 'posts';
|
export const slug = 'posts';
|
||||||
|
|
||||||
export interface Post {
|
export interface Post {
|
||||||
id: string,
|
id: string;
|
||||||
title: string,
|
title: string;
|
||||||
description: string,
|
description: string;
|
||||||
createdAt: Date,
|
createdAt: Date;
|
||||||
updatedAt: Date,
|
updatedAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default buildConfig({
|
export default buildConfig({
|
||||||
collections: [{
|
collections: [
|
||||||
slug,
|
{
|
||||||
fields: [
|
slug,
|
||||||
{
|
fields: [
|
||||||
name: 'title',
|
{
|
||||||
type: 'text',
|
name: 'title',
|
||||||
},
|
type: 'text',
|
||||||
{
|
},
|
||||||
name: 'description',
|
{
|
||||||
type: 'text',
|
name: 'description',
|
||||||
},
|
type: 'text',
|
||||||
],
|
},
|
||||||
}],
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
onInit: async (payload) => {
|
onInit: async (payload) => {
|
||||||
await payload.create({
|
await payload.create({
|
||||||
collection: 'users',
|
collection: 'users',
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ describe('collections', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('CRUD', () => {
|
describe('CRUD', () => {
|
||||||
test('should create', async () => {
|
test('should create', async () => {
|
||||||
await page.goto(url.create);
|
await page.goto(url.create);
|
||||||
@@ -182,8 +181,7 @@ describe('collections', () => {
|
|||||||
await wait(1000);
|
await wait(1000);
|
||||||
|
|
||||||
await expect(page.locator(tableRowLocator)).toHaveCount(1);
|
await expect(page.locator(tableRowLocator)).toHaveCount(1);
|
||||||
const firstId = await page.locator(tableRowLocator).first().locator('td').first()
|
const firstId = await page.locator(tableRowLocator).first().locator('td').first().innerText();
|
||||||
.innerText();
|
|
||||||
expect(firstId).toEqual(id);
|
expect(firstId).toEqual(id);
|
||||||
|
|
||||||
// Remove filter
|
// Remove filter
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export interface FieldsRelationship {
|
|||||||
id: string;
|
id: string;
|
||||||
relationship: RelationOne;
|
relationship: RelationOne;
|
||||||
relationshipHasMany: RelationOne[];
|
relationshipHasMany: RelationOne[];
|
||||||
relationshipHasManyMultiple: Array<RelationOne | RelationTwo | { relationTo: string, value: string }>;
|
relationshipHasManyMultiple: Array<RelationOne | RelationTwo | { relationTo: string; value: string }>;
|
||||||
relationshipMultiple: Array<RelationOne | RelationTwo>;
|
relationshipMultiple: Array<RelationOne | RelationTwo>;
|
||||||
relationshipRestricted: RelationRestricted;
|
relationshipRestricted: RelationRestricted;
|
||||||
relationshipWithTitle: RelationWithTitle;
|
relationshipWithTitle: RelationWithTitle;
|
||||||
@@ -42,7 +42,13 @@ export default buildConfig({
|
|||||||
{
|
{
|
||||||
slug,
|
slug,
|
||||||
admin: {
|
admin: {
|
||||||
defaultColumns: ['id', 'relationship', 'relationshipRestricted', 'relationshipHasManyMultiple', 'relationshipWithTitle'],
|
defaultColumns: [
|
||||||
|
'id',
|
||||||
|
'relationship',
|
||||||
|
'relationshipRestricted',
|
||||||
|
'relationshipHasManyMultiple',
|
||||||
|
'relationshipWithTitle',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
@@ -170,7 +176,10 @@ export default buildConfig({
|
|||||||
data: {
|
data: {
|
||||||
relationship: relationOneDocId,
|
relationship: relationOneDocId,
|
||||||
relationshipRestricted: restrictedDocId,
|
relationshipRestricted: restrictedDocId,
|
||||||
relationshipHasManyMultiple: relationOneIDs.map((id) => ({ relationTo: relationOneSlug, value: id })),
|
relationshipHasManyMultiple: relationOneIDs.map((id) => ({
|
||||||
|
relationTo: relationOneSlug,
|
||||||
|
value: id,
|
||||||
|
})),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,13 +12,7 @@ import type {
|
|||||||
RelationTwo,
|
RelationTwo,
|
||||||
RelationWithTitle,
|
RelationWithTitle,
|
||||||
} from './config';
|
} from './config';
|
||||||
import {
|
import { relationOneSlug, relationRestrictedSlug, relationTwoSlug, relationWithTitleSlug, slug } from './config';
|
||||||
relationOneSlug,
|
|
||||||
relationRestrictedSlug,
|
|
||||||
relationTwoSlug,
|
|
||||||
relationWithTitleSlug,
|
|
||||||
slug,
|
|
||||||
} from './config';
|
|
||||||
import wait from '../../src/utilities/wait';
|
import wait from '../../src/utilities/wait';
|
||||||
|
|
||||||
const { beforeAll, describe } = test;
|
const { beforeAll, describe } = test;
|
||||||
|
|||||||
@@ -62,9 +62,7 @@ export const blocksField: Field = {
|
|||||||
|
|
||||||
const BlockFields: CollectionConfig = {
|
const BlockFields: CollectionConfig = {
|
||||||
slug: 'block-fields',
|
slug: 'block-fields',
|
||||||
fields: [
|
fields: [blocksField],
|
||||||
blocksField,
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const blocksFieldSeedData = [
|
export const blocksFieldSeedData = [
|
||||||
|
|||||||
@@ -32,5 +32,4 @@ export const conditionalLogicDoc = {
|
|||||||
fieldToToggle: 'spiderman',
|
fieldToToggle: 'spiderman',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default ConditionalLogic;
|
export default ConditionalLogic;
|
||||||
|
|||||||
@@ -37,5 +37,4 @@ export const pointDoc = {
|
|||||||
group: { point: [1, 9] },
|
group: { point: [1, 9] },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default PointFields;
|
export default PointFields;
|
||||||
|
|||||||
@@ -166,5 +166,4 @@ export const richTextDoc = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default RichTextFields;
|
export default RichTextFields;
|
||||||
|
|||||||
@@ -33,9 +33,7 @@ const TabsFields: CollectionConfig = {
|
|||||||
{
|
{
|
||||||
label: 'Tab with Blocks',
|
label: 'Tab with Blocks',
|
||||||
description: 'Blocks are rendered here to ensure they populate and render correctly.',
|
description: 'Blocks are rendered here to ensure they populate and render correctly.',
|
||||||
fields: [
|
fields: [blocksField],
|
||||||
blocksField,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Tab with Group',
|
label: 'Tab with Group',
|
||||||
@@ -95,7 +93,7 @@ const TabsFields: CollectionConfig = {
|
|||||||
export const tabsDoc = {
|
export const tabsDoc = {
|
||||||
array: [
|
array: [
|
||||||
{
|
{
|
||||||
text: 'Hello, I\'m the first row',
|
text: "Hello, I'm the first row",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Second row here',
|
text: 'Second row here',
|
||||||
|
|||||||
@@ -18,5 +18,4 @@ export const textDoc = {
|
|||||||
text: 'Seeded text document',
|
text: 'Seeded text document',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export default TextFields;
|
export default TextFields;
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import wait from '../src/utilities/wait';
|
|||||||
import { devUser } from './credentials';
|
import { devUser } from './credentials';
|
||||||
|
|
||||||
type FirstRegisterArgs = {
|
type FirstRegisterArgs = {
|
||||||
page: Page,
|
page: Page;
|
||||||
serverURL: string,
|
serverURL: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
type LoginArgs = {
|
type LoginArgs = {
|
||||||
page: Page,
|
page: Page;
|
||||||
serverURL: string,
|
serverURL: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export async function firstRegister(args: FirstRegisterArgs): Promise<void> {
|
export async function firstRegister(args: FirstRegisterArgs): Promise<void> {
|
||||||
const { page, serverURL } = args;
|
const { page, serverURL } = args;
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import type { InitOptions } from '../../src/config/types';
|
|||||||
import payload from '../../src';
|
import payload from '../../src';
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
__dirname: string
|
__dirname: string;
|
||||||
init?: Partial<InitOptions>
|
init?: Partial<InitOptions>;
|
||||||
}
|
};
|
||||||
|
|
||||||
export async function initPayloadE2E(__dirname: string): Promise<{ serverURL: string }> {
|
export async function initPayloadE2E(__dirname: string): Promise<{ serverURL: string }> {
|
||||||
return initPayloadTest({
|
return initPayloadTest({
|
||||||
@@ -25,7 +25,7 @@ export async function initPayloadTest(options: Options): Promise<{ serverURL: st
|
|||||||
local: true,
|
local: true,
|
||||||
secret: uuid(),
|
secret: uuid(),
|
||||||
mongoURL: `mongodb://localhost/${uuid()}`,
|
mongoURL: `mongodb://localhost/${uuid()}`,
|
||||||
...options.init || {},
|
...(options.init || {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
process.env.PAYLOAD_DISABLE_ADMIN = 'true';
|
process.env.PAYLOAD_DISABLE_ADMIN = 'true';
|
||||||
|
|||||||
@@ -8,46 +8,46 @@ import { devUser } from '../credentials';
|
|||||||
require('isomorphic-fetch');
|
require('isomorphic-fetch');
|
||||||
|
|
||||||
type Args = {
|
type Args = {
|
||||||
serverURL: string
|
serverURL: string;
|
||||||
defaultSlug: string
|
defaultSlug: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
type LoginArgs = {
|
type LoginArgs = {
|
||||||
email: string
|
email: string;
|
||||||
password: string
|
password: string;
|
||||||
collection: string
|
collection: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
type CreateArgs<T = any> = {
|
type CreateArgs<T = any> = {
|
||||||
slug?: string
|
slug?: string;
|
||||||
data: T
|
data: T;
|
||||||
auth?: boolean
|
auth?: boolean;
|
||||||
file?: boolean
|
file?: boolean;
|
||||||
}
|
};
|
||||||
|
|
||||||
type FindArgs = {
|
type FindArgs = {
|
||||||
slug?: string
|
slug?: string;
|
||||||
query?: Where
|
query?: Where;
|
||||||
auth?: boolean
|
auth?: boolean;
|
||||||
}
|
};
|
||||||
|
|
||||||
type UpdateArgs<T = any> = {
|
type UpdateArgs<T = any> = {
|
||||||
slug?: string
|
slug?: string;
|
||||||
id: string
|
id: string;
|
||||||
data: Partial<T>
|
data: Partial<T>;
|
||||||
auth?: boolean
|
auth?: boolean;
|
||||||
query?: any
|
query?: any;
|
||||||
}
|
};
|
||||||
type DeleteArgs = {
|
type DeleteArgs = {
|
||||||
slug?: string
|
slug?: string;
|
||||||
id: string
|
id: string;
|
||||||
auth?: boolean
|
auth?: boolean;
|
||||||
}
|
};
|
||||||
|
|
||||||
type DocResponse<T> = {
|
type DocResponse<T> = {
|
||||||
status: number
|
status: number;
|
||||||
doc: T
|
doc: T;
|
||||||
}
|
};
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -148,14 +148,11 @@ export class RESTClient {
|
|||||||
if (args?.auth) {
|
if (args?.auth) {
|
||||||
headers.Authorization = `JWT ${this.token}`;
|
headers.Authorization = `JWT ${this.token}`;
|
||||||
}
|
}
|
||||||
const response = await fetch(
|
const response = await fetch(`${this.serverURL}/api/${slug || this.defaultSlug}/${id}${formattedQs}`, {
|
||||||
`${this.serverURL}/api/${slug || this.defaultSlug}/${id}${formattedQs}`,
|
body: JSON.stringify(data),
|
||||||
{
|
headers,
|
||||||
body: JSON.stringify(data),
|
method: 'put',
|
||||||
headers,
|
});
|
||||||
method: 'put',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
const { status } = response;
|
const { status } = response;
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
return { status, doc: json.doc };
|
return { status, doc: json.doc };
|
||||||
|
|||||||
@@ -7,55 +7,63 @@ const Hooks: CollectionConfig = {
|
|||||||
slug: hooksSlug,
|
slug: hooksSlug,
|
||||||
access: openAccess,
|
access: openAccess,
|
||||||
hooks: {
|
hooks: {
|
||||||
beforeValidate: [({ data }) => (validateHookOrder('collectionBeforeValidate', data))],
|
beforeValidate: [({ data }) => validateHookOrder('collectionBeforeValidate', data)],
|
||||||
beforeChange: [({ data }) => (validateHookOrder('collectionBeforeChange', data))],
|
beforeChange: [({ data }) => validateHookOrder('collectionBeforeChange', data)],
|
||||||
afterChange: [({ doc }) => (validateHookOrder('collectionAfterChange', doc))],
|
afterChange: [({ doc }) => validateHookOrder('collectionAfterChange', doc)],
|
||||||
beforeRead: [({ doc }) => (validateHookOrder('collectionBeforeRead', doc))],
|
beforeRead: [({ doc }) => validateHookOrder('collectionBeforeRead', doc)],
|
||||||
afterRead: [({ doc }) => (validateHookOrder('collectionAfterRead', doc))],
|
afterRead: [({ doc }) => validateHookOrder('collectionAfterRead', doc)],
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'fieldBeforeValidate',
|
name: 'fieldBeforeValidate',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
hooks: {
|
hooks: {
|
||||||
beforeValidate: [({ data }) => {
|
beforeValidate: [
|
||||||
data.fieldBeforeValidate = true;
|
({ data }) => {
|
||||||
validateHookOrder('fieldBeforeValidate', data);
|
data.fieldBeforeValidate = true;
|
||||||
return true;
|
validateHookOrder('fieldBeforeValidate', data);
|
||||||
}],
|
return true;
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'fieldBeforeChange',
|
name: 'fieldBeforeChange',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
hooks: {
|
hooks: {
|
||||||
beforeChange: [({ data }) => {
|
beforeChange: [
|
||||||
data.fieldBeforeChange = true;
|
({ data }) => {
|
||||||
validateHookOrder('fieldBeforeChange', data);
|
data.fieldBeforeChange = true;
|
||||||
return true;
|
validateHookOrder('fieldBeforeChange', data);
|
||||||
}],
|
return true;
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'fieldAfterChange',
|
name: 'fieldAfterChange',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
hooks: {
|
hooks: {
|
||||||
afterChange: [({ data }) => {
|
afterChange: [
|
||||||
data.fieldAfterChange = true;
|
({ data }) => {
|
||||||
validateHookOrder('fieldAfterChange', data);
|
data.fieldAfterChange = true;
|
||||||
return true;
|
validateHookOrder('fieldAfterChange', data);
|
||||||
}],
|
return true;
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'fieldAfterRead',
|
name: 'fieldAfterRead',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
hooks: {
|
hooks: {
|
||||||
afterRead: [({ data }) => {
|
afterRead: [
|
||||||
data.fieldAfterRead = true;
|
({ data }) => {
|
||||||
validateHookOrder('fieldAfterRead', data);
|
data.fieldAfterRead = true;
|
||||||
return true;
|
validateHookOrder('fieldAfterRead', data);
|
||||||
}],
|
return true;
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ const TransformHooks: CollectionConfig = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
hooks: {
|
hooks: {
|
||||||
beforeRead: [
|
beforeRead: [(operation) => operation.doc],
|
||||||
(operation) => operation.doc,
|
|
||||||
],
|
|
||||||
beforeChange: [
|
beforeChange: [
|
||||||
(operation) => {
|
(operation) => {
|
||||||
operation.data.beforeChange = !operation.data.location?.coordinates;
|
operation.data.beforeChange = !operation.data.location?.coordinates;
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ import TransformHooks from './collections/Transform';
|
|||||||
import Hooks, { hooksSlug } from './collections/Hook';
|
import Hooks, { hooksSlug } from './collections/Hook';
|
||||||
|
|
||||||
export default buildConfig({
|
export default buildConfig({
|
||||||
collections: [
|
collections: [TransformHooks, Hooks],
|
||||||
TransformHooks,
|
|
||||||
Hooks,
|
|
||||||
],
|
|
||||||
onInit: async (payload) => {
|
onInit: async (payload) => {
|
||||||
await payload.create({
|
await payload.create({
|
||||||
collection: hooksSlug,
|
collection: hooksSlug,
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ export default buildConfig({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [],
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
slug: 'unstored-media',
|
slug: 'unstored-media',
|
||||||
|
|||||||
@@ -27,10 +27,7 @@ describe('Collections - Uploads', () => {
|
|||||||
describe('create', () => {
|
describe('create', () => {
|
||||||
it('creates from form data', async () => {
|
it('creates from form data', async () => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append(
|
formData.append('file', fs.createReadStream(path.join(__dirname, './image.png')));
|
||||||
'file',
|
|
||||||
fs.createReadStream(path.join(__dirname, './image.png')),
|
|
||||||
);
|
|
||||||
|
|
||||||
const { status, doc } = await client.create({
|
const { status, doc } = await client.create({
|
||||||
file: true,
|
file: true,
|
||||||
@@ -62,10 +59,7 @@ describe('Collections - Uploads', () => {
|
|||||||
|
|
||||||
it('creates images that do not require all sizes', async () => {
|
it('creates images that do not require all sizes', async () => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append(
|
formData.append('file', fs.createReadStream(path.join(__dirname, './small.png')));
|
||||||
'file',
|
|
||||||
fs.createReadStream(path.join(__dirname, './small.png')),
|
|
||||||
);
|
|
||||||
|
|
||||||
const { status, doc } = await client.create({
|
const { status, doc } = await client.create({
|
||||||
file: true,
|
file: true,
|
||||||
@@ -88,10 +82,7 @@ describe('Collections - Uploads', () => {
|
|||||||
|
|
||||||
it('creates media without storing a file', async () => {
|
it('creates media without storing a file', async () => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append(
|
formData.append('file', fs.createReadStream(path.join(__dirname, './small.png')));
|
||||||
'file',
|
|
||||||
fs.createReadStream(path.join(__dirname, './small.png')),
|
|
||||||
);
|
|
||||||
|
|
||||||
// unstored media
|
// unstored media
|
||||||
const { status, doc } = await client.create({
|
const { status, doc } = await client.create({
|
||||||
@@ -125,10 +116,7 @@ describe('Collections - Uploads', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append(
|
formData.append('file', fs.createReadStream(path.join(__dirname, './small.png')));
|
||||||
'file',
|
|
||||||
fs.createReadStream(path.join(__dirname, './small.png')),
|
|
||||||
);
|
|
||||||
|
|
||||||
const { status, doc } = await client.update({
|
const { status, doc } = await client.update({
|
||||||
id: mediaDoc.id,
|
id: mediaDoc.id,
|
||||||
@@ -147,10 +135,7 @@ describe('Collections - Uploads', () => {
|
|||||||
|
|
||||||
it('delete', async () => {
|
it('delete', async () => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append(
|
formData.append('file', fs.createReadStream(path.join(__dirname, './image.png')));
|
||||||
'file',
|
|
||||||
fs.createReadStream(path.join(__dirname, './image.png')),
|
|
||||||
);
|
|
||||||
|
|
||||||
const { doc } = await client.create({
|
const { doc } = await client.create({
|
||||||
file: true,
|
file: true,
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ import { buildConfig } from '../buildConfig';
|
|||||||
export const slug = 'slugname';
|
export const slug = 'slugname';
|
||||||
|
|
||||||
export default buildConfig({
|
export default buildConfig({
|
||||||
collections: [{
|
collections: [
|
||||||
slug,
|
{
|
||||||
fields: [],
|
slug,
|
||||||
}],
|
fields: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
17
test/versions/e2e.spec.ts
Normal file
17
test/versions/e2e.spec.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* TODO: Versions, 3 separate collections
|
||||||
|
* - drafts
|
||||||
|
* - save draft before publishing
|
||||||
|
* - publish immediately
|
||||||
|
* - validation should be skipped when creating a draft
|
||||||
|
*
|
||||||
|
* - autosave
|
||||||
|
* - versions (no drafts)
|
||||||
|
* - version control shown
|
||||||
|
* - assert version counts increment
|
||||||
|
* - navigate to versions
|
||||||
|
* - versions view accurately shows number of versions
|
||||||
|
* - compare
|
||||||
|
* - restore version
|
||||||
|
* - specify locales to show
|
||||||
|
*/
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
import type { Page } from '@playwright/test';
|
|
||||||
import { expect, test } from '@playwright/test';
|
|
||||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil';
|
|
||||||
import { initPayloadTest } from '../helpers/configHelpers';
|
|
||||||
import { firstRegister } from '../helpers';
|
|
||||||
import { slug } from './config';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Versions, 3 separate collections
|
|
||||||
* - drafts
|
|
||||||
* - save draft before publishing
|
|
||||||
* - publish immediately
|
|
||||||
* - validation should be skipped when creating a draft
|
|
||||||
*
|
|
||||||
* - autosave
|
|
||||||
* - versions (no drafts)
|
|
||||||
* - version control shown
|
|
||||||
* - assert version counts increment
|
|
||||||
* - navigate to versions
|
|
||||||
* - versions view accurately shows number of versions
|
|
||||||
* - compare
|
|
||||||
* - restore version
|
|
||||||
* - specify locales to show
|
|
||||||
*/
|
|
||||||
|
|
||||||
const { beforeAll, describe } = test;
|
|
||||||
let url: AdminUrlUtil;
|
|
||||||
|
|
||||||
describe('suite name', () => {
|
|
||||||
let page: Page;
|
|
||||||
|
|
||||||
beforeAll(async ({ browser }) => {
|
|
||||||
const { serverURL } = await initPayloadTest({
|
|
||||||
__dirname,
|
|
||||||
init: {
|
|
||||||
local: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
// await clearDocs(); // Clear any seeded data from onInit
|
|
||||||
|
|
||||||
url = new AdminUrlUtil(serverURL, slug);
|
|
||||||
|
|
||||||
const context = await browser.newContext();
|
|
||||||
page = await context.newPage();
|
|
||||||
|
|
||||||
await firstRegister({ page, serverURL });
|
|
||||||
});
|
|
||||||
|
|
||||||
// afterEach(async () => {
|
|
||||||
// });
|
|
||||||
|
|
||||||
describe('feature', () => {
|
|
||||||
it('testname', () => {
|
|
||||||
expect(1).toEqual(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user