Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/tabs

This commit is contained in:
James
2022-07-15 16:24:59 -07:00
10 changed files with 56 additions and 52 deletions

View File

@@ -2,7 +2,7 @@ module.exports = {
verbose: true,
testTimeout: 15000,
testRegex: '(/src/admin/.*\\.(test|spec))\\.[jt]sx?$',
setupFilesAfterEnv: ['<rootDir>/test/components/globalSetup.js'],
setupFilesAfterEnv: ['<rootDir>/test/componentsSetup.js'],
testPathIgnorePatterns: [
'node_modules',
'dist',

View File

@@ -12,5 +12,5 @@
"test/"
],
"ext": "ts,js,json",
"exec": "node ./test/dev/index.js"
"exec": "node ./test/dev.js"
}

View File

@@ -38,7 +38,7 @@
"demo:generate:graphqlschema": "cross-env PAYLOAD_CONFIG_PATH=demo/payload.config.ts node dist/bin/generateGraphQLSchema",
"demo:serve": "cross-env PAYLOAD_CONFIG_PATH=demo/payload.config.ts NODE_ENV=production nodemon",
"dev": "nodemon",
"dev:generatetypes": "node ./test/dev/generateTypes.js",
"dev:generatetypes": "node ./test/generateTypes.js",
"test": "yarn test:int && yarn test:components",
"test:int": "cross-env NODE_ENV=test DISABLE_LOGGING=true jest --forceExit --detectOpenHandles",
"test:e2e": "cross-env NODE_ENV=test DISABLE_LOGGING=true playwright test",

View File

@@ -25,9 +25,7 @@ export function buildConfig(overrides?: Partial<Config>): SanitizedConfig {
};
}
console.log(process.env.PAYLOAD_DISABLE_ADMIN);
if (process.env.PAYLOAD_DISABLE_ADMIN === 'true') {
console.log('disabling admin');
if (typeof baseConfig.admin !== 'object') baseConfig.admin = {};
baseConfig.admin.disable = true;
}

View File

@@ -1,4 +1,4 @@
import { openAccess } from '../../helpers/configHelpers';
import { openAccess } from '../helpers/configHelpers';
import { buildConfig } from '../buildConfig';
export default buildConfig({

View File

@@ -1,5 +1,5 @@
const path = require('path');
const babelConfig = require('../../babel.config');
const babelConfig = require('../babel.config');
require('@babel/register')({
...babelConfig,
@@ -14,8 +14,8 @@ require('@babel/register')({
const [testSuiteDir] = process.argv.slice(2);
const configPath = path.resolve(__dirname, '../', testSuiteDir, 'config.ts');
const configPath = path.resolve(__dirname, testSuiteDir, 'config.ts');
process.env.PAYLOAD_CONFIG_PATH = configPath;
process.env.PAYLOAD_DROP_DATABASE = 'true';
require('./server');
require('./devServer');

View File

@@ -1,42 +0,0 @@
const path = require('path');
const fs = require('fs');
const babelConfig = require('../../babel.config');
require('@babel/register')({
...babelConfig,
extensions: ['.ts', '.tsx', '.js', '.jsx'],
env: {
development: {
sourceMaps: 'inline',
retainLines: true,
},
},
});
const { generateTypes } = require('../../src/bin/generateTypes');
const [testConfigDir] = process.argv.slice(2);
const testDir = path.resolve(__dirname, '../', testConfigDir);
// Generate types for entire directory
if (testConfigDir === 'int' || testConfigDir === 'e2e') {
fs.readdirSync(testDir, { withFileTypes: true })
.filter((f) => f.isDirectory())
.forEach((dir) => {
const suiteDir = path.resolve(testDir, dir.name);
setPaths(suiteDir);
generateTypes();
});
return;
}
// Generate for specific test suite directory
setPaths(testDir);
generateTypes();
// Set config path and TS output path using test dir
function setPaths(dir) {
const configPath = path.resolve(dir, 'config.ts');
process.env.PAYLOAD_CONFIG_PATH = configPath;
process.env.PAYLOAD_TS_OUTPUT_PATH = path.resolve(dir, 'payload-types.ts');
}

View File

@@ -1,6 +1,6 @@
import express from 'express';
import { v4 as uuid } from 'uuid';
import payload from '../../src';
import payload from '../src';
const expressApp = express();

48
test/generateTypes.js Normal file
View File

@@ -0,0 +1,48 @@
const path = require('path');
const fs = require('fs');
const babelConfig = require('../babel.config');
require('@babel/register')({
...babelConfig,
extensions: ['.ts', '.tsx', '.js', '.jsx'],
env: {
development: {
sourceMaps: 'inline',
retainLines: true,
},
},
});
const { generateTypes } = require('../src/bin/generateTypes');
const [testConfigDir] = process.argv.slice(2);
let testDir;
if (testConfigDir) {
testDir = path.resolve(__dirname, testConfigDir);
setPaths(testDir);
generateTypes();
} else {
// Generate types for entire directory
testDir = __dirname;
fs.readdirSync(__dirname, { withFileTypes: true })
.filter((f) => f.isDirectory())
.forEach((dir) => {
const suiteDir = path.resolve(testDir, dir.name);
const configFound = setPaths(suiteDir);
if (configFound) generateTypes();
});
}
// Set config path and TS output path using test dir
function setPaths(dir) {
const configPath = path.resolve(dir, 'config.ts');
const outputPath = path.resolve(dir, 'payload-types.ts');
if (fs.existsSync(configPath) && fs.existsSync(outputPath)) {
process.env.PAYLOAD_CONFIG_PATH = configPath;
process.env.PAYLOAD_TS_OUTPUT_PATH = outputPath;
return true;
}
return false;
}