chore: cherry pick missing from migrations

This commit is contained in:
Dan Ribbens
2023-06-19 00:16:07 -04:00
committed by Elliot DeNolf
parent 2198445df9
commit fc1f4c494f
16 changed files with 582 additions and 41 deletions

View File

@@ -11,6 +11,8 @@ export const globalSlug = 'global-endpoints';
export const globalEndpoint = 'global';
export const applicationEndpoint = 'path';
export const rootEndpoint = 'root';
export const noEndpointsCollectionSlug = 'no-endpoints';
export const noEndpointsGlobalSlug = 'global-no-endpoints';
const MyConfig: Config = {
collections: [
@@ -57,6 +59,17 @@ const MyConfig: Config = {
},
],
},
{
slug: noEndpointsCollectionSlug,
graphQL: false,
endpoints: false,
fields: [
{
name: 'name',
type: 'text',
},
],
},
],
globals: [
{
@@ -70,6 +83,17 @@ const MyConfig: Config = {
}],
fields: [],
},
{
slug: noEndpointsGlobalSlug,
graphQL: false,
endpoints: false,
fields: [
{
name: 'name',
type: 'text',
},
],
},
],
endpoints: [
{

View File

@@ -1,6 +1,14 @@
import { initPayloadTest } from '../helpers/configHelpers';
import { RESTClient } from '../helpers/rest';
import { applicationEndpoint, collectionSlug, globalEndpoint, globalSlug, rootEndpoint } from './config';
import {
applicationEndpoint,
collectionSlug,
globalEndpoint,
globalSlug,
noEndpointsCollectionSlug,
noEndpointsGlobalSlug,
rootEndpoint,
} from './config';
require('isomorphic-fetch');
@@ -34,6 +42,16 @@ describe('Endpoints', () => {
expect(data.name).toStrictEqual(params.name);
expect(data.age).toStrictEqual(params.age);
});
it('should disable built-in endpoints when false', async () => {
let result;
try {
result = await client.endpoint(`/api/${noEndpointsCollectionSlug}`, 'get');
} catch (err: unknown) {
result = err;
}
expect(result instanceof Error).toBe(true);
});
});
describe('Globals', () => {
@@ -44,6 +62,15 @@ describe('Endpoints', () => {
expect(status).toBe(200);
expect(params).toMatchObject(data);
});
it('should disable built-in endpoints when false', async () => {
let result;
try {
result = await client.endpoint(`/api/globals/${noEndpointsGlobalSlug}`, 'get');
} catch (err: unknown) {
result = err;
}
expect(result instanceof Error).toBe(true);
});
});
describe('API', () => {