feat(proxy-server): add local fs middleware and make it the default (#3217)
This commit is contained in:
@ -3,12 +3,13 @@ import * as specUtils from './common/spec_utils';
|
||||
import { entry1, entry2, entry3 } from './common/entries';
|
||||
|
||||
const backend = 'proxy';
|
||||
const mode = 'git';
|
||||
|
||||
describe.skip('Proxy Backend Editorial Workflow', () => {
|
||||
describe.skip(`Proxy Backend Editorial Workflow - '${mode}' mode`, () => {
|
||||
let taskResult = { data: {} };
|
||||
|
||||
before(() => {
|
||||
specUtils.before(taskResult, { publish_mode: 'editorial_workflow' }, backend);
|
||||
specUtils.before(taskResult, { publish_mode: 'editorial_workflow', mode }, backend);
|
||||
Cypress.config('defaultCommandTimeout', 5 * 1000);
|
||||
});
|
||||
|
@ -3,12 +3,13 @@ import * as specUtils from './common/spec_utils';
|
||||
import { entry1 } from './common/entries';
|
||||
|
||||
const backend = 'proxy';
|
||||
const mode = 'git';
|
||||
|
||||
describe('Proxy Backend Media Library - REST API', () => {
|
||||
describe(`Proxy Backend Media Library - '${mode}' mode`, () => {
|
||||
let taskResult = { data: {} };
|
||||
|
||||
before(() => {
|
||||
specUtils.before(taskResult, { publish_mode: 'editorial_workflow' }, backend);
|
||||
specUtils.before(taskResult, { publish_mode: 'editorial_workflow', mode }, backend);
|
||||
Cypress.config('defaultCommandTimeout', 5 * 1000);
|
||||
});
|
||||
|
@ -3,12 +3,13 @@ import * as specUtils from './common/spec_utils';
|
||||
import { entry1, entry2, entry3 } from './common/entries';
|
||||
|
||||
const backend = 'proxy';
|
||||
const mode = 'fs';
|
||||
|
||||
describe('Proxy Backend Simple Workflow', () => {
|
||||
describe(`Proxy Backend Simple Workflow - '${mode}' mode`, () => {
|
||||
let taskResult = { data: {} };
|
||||
|
||||
before(() => {
|
||||
specUtils.before(taskResult, { publish_mode: 'simple' }, backend);
|
||||
specUtils.before(taskResult, { publish_mode: 'simple', mode }, backend);
|
||||
Cypress.config('defaultCommandTimeout', 5 * 1000);
|
||||
});
|
||||
|
@ -0,0 +1,32 @@
|
||||
import fixture from './common/simple_workflow';
|
||||
import * as specUtils from './common/spec_utils';
|
||||
import { entry1, entry2, entry3 } from './common/entries';
|
||||
|
||||
const backend = 'proxy';
|
||||
const mode = 'git';
|
||||
|
||||
describe(`Proxy Backend Simple Workflow - '${mode}' mode`, () => {
|
||||
let taskResult = { data: {} };
|
||||
|
||||
before(() => {
|
||||
specUtils.before(taskResult, { publish_mode: 'simple', mode }, backend);
|
||||
Cypress.config('defaultCommandTimeout', 5 * 1000);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
specUtils.after(taskResult, backend);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
specUtils.beforeEach(taskResult, backend);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
specUtils.afterEach(taskResult, backend);
|
||||
});
|
||||
|
||||
fixture({
|
||||
entries: [entry1, entry2, entry3],
|
||||
getUser: () => taskResult.data.user,
|
||||
});
|
||||
});
|
@ -19,13 +19,21 @@ const initRepo = async dir => {
|
||||
await git.commit('initial commit', readme, { '--no-verify': true, '--no-gpg-sign': true });
|
||||
};
|
||||
|
||||
const startServer = async repoDir => {
|
||||
const startServer = async (repoDir, mode) => {
|
||||
const tsNode = path.join(__dirname, '..', '..', 'node_modules', '.bin', 'ts-node');
|
||||
const serverDir = path.join(__dirname, '..', '..', 'packages', 'netlify-cms-proxy-server');
|
||||
const distIndex = path.join(serverDir, 'dist', 'index.js');
|
||||
const tsIndex = path.join(serverDir, 'src', 'index.ts');
|
||||
|
||||
const env = { ...process.env, GIT_REPO_DIRECTORY: path.resolve(repoDir), PORT: 8082 };
|
||||
const port = 8082;
|
||||
const env = {
|
||||
...process.env,
|
||||
GIT_REPO_DIRECTORY: path.resolve(repoDir),
|
||||
PORT: port,
|
||||
MODE: mode,
|
||||
};
|
||||
|
||||
console.log(`Starting proxy server on port '${port}' with mode ${mode}`);
|
||||
if (await fs.pathExists(distIndex)) {
|
||||
serverProcess = spawn('node', [distIndex], { env, cwd: serverDir });
|
||||
} else {
|
||||
@ -58,11 +66,13 @@ async function setupProxy(options) {
|
||||
const testRepoName = `proxy-test-repo-${Date.now()}-${postfix}`;
|
||||
const tempDir = path.join('.temp', testRepoName);
|
||||
|
||||
const { mode, ...rest } = options;
|
||||
|
||||
await updateConfig(config => {
|
||||
merge(config, options);
|
||||
merge(config, rest);
|
||||
});
|
||||
|
||||
return { tempDir };
|
||||
return { tempDir, mode };
|
||||
}
|
||||
|
||||
async function teardownProxy(taskData) {
|
||||
@ -76,7 +86,7 @@ async function teardownProxy(taskData) {
|
||||
|
||||
async function setupProxyTest(taskData) {
|
||||
await initRepo(taskData.tempDir);
|
||||
serverProcess = await startServer(taskData.tempDir);
|
||||
serverProcess = await startServer(taskData.tempDir, taskData.mode);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user