feat(core): auto detect proxy server on load (#3195)

* feat: auto detect proxy server on load

* fix: opt-in for auto proxy server detection
This commit is contained in:
Erez Rokah
2020-02-05 17:56:11 +02:00
committed by GitHub
parent 2043c0b782
commit 614f1aea63
6 changed files with 158 additions and 13 deletions

View File

@ -126,5 +126,31 @@ describe('config', () => {
});
}).toThrowError("'collections[0]' should be object");
});
it('should throw if local_backend is not a boolean or plain object', () => {
expect(() => {
validateConfig(merge(validConfig, { local_backend: [] }));
}).toThrowError("'local_backend' should be boolean");
});
it('should throw if local_backend is a plain object but missing url property', () => {
expect(() => {
validateConfig(merge(validConfig, { local_backend: {} }));
}).toThrowError("'local_backend' should be object");
});
it('should not throw if local_backend is a boolean', () => {
expect(() => {
validateConfig(merge(validConfig, { local_backend: true }));
}).not.toThrowError();
});
it('should not throw if local_backend is a plain object with url property', () => {
expect(() => {
validateConfig(
merge(validConfig, { local_backend: { url: 'http://localhost:8081/api/v1' } }),
);
}).not.toThrowError();
});
});
});

View File

@ -42,6 +42,18 @@ const getConfigSchema = () => ({
},
required: ['name'],
},
local_backend: {
oneOf: [
{ type: 'boolean' },
{
type: 'object',
properties: {
url: { type: 'string', examples: ['http://localhost:8081/api/v1'] },
},
required: ['url'],
},
],
},
locale: { type: 'string', examples: ['en', 'fr', 'de'] },
site_url: { type: 'string', examples: ['https://example.com'] },
display_url: { type: 'string', examples: ['https://example.com'] },