Added initial stats config to API (#20875)
closes https://linear.app/tryghost/issue/ANAL-8/flag-and-config - This checks if tinybird:stats is set, and if so passes through the config that is set via the config API - This is used by Ghost admin to configure where to pull charts from
This commit is contained in:
parent
0a6cd75993
commit
3e25370ebe
@ -20,7 +20,8 @@ module.exports = {
|
||||
'hostSettings',
|
||||
'tenor',
|
||||
'pintura',
|
||||
'signupForm'
|
||||
'signupForm',
|
||||
'stats'
|
||||
];
|
||||
|
||||
frame.response = {
|
||||
|
@ -23,5 +23,10 @@ module.exports = function getConfigProperties() {
|
||||
signupForm: config.get('signupForm')
|
||||
};
|
||||
|
||||
// WIP tinybird stats feature - it's entirely config driven instead of using an alpha flag for now
|
||||
if (config.get('tinybird') && config.get('tinybird:stats')) {
|
||||
configProperties.stats = config.get('tinybird:stats');
|
||||
}
|
||||
|
||||
return configProperties;
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Config API Can retrieve config and all expected properties 1: [body] 1`] = `
|
||||
exports[`Config API As Owner Can retrieve config and all expected properties 1: [body] 1`] = `
|
||||
Object {
|
||||
"config": Object {
|
||||
"clientExtensions": Object {},
|
||||
@ -54,7 +54,7 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Config API Can retrieve config and all expected properties 2: [headers] 1`] = `
|
||||
exports[`Config API As Owner Can retrieve config and all expected properties 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
|
@ -11,7 +11,18 @@ describe('Config API', function () {
|
||||
|
||||
before(async function () {
|
||||
agent = await agentProvider.getAdminAPIAgent();
|
||||
await fixtureManager.init();
|
||||
await fixtureManager.init('users');
|
||||
});
|
||||
|
||||
describe('As Unauthorized User', function () {
|
||||
it('Cannot fetch the config endpoint', async function () {
|
||||
await agent.get('/config/')
|
||||
.expectStatus(403);
|
||||
});
|
||||
});
|
||||
|
||||
describe('As Owner', function () {
|
||||
before(async function () {
|
||||
await agent.loginAsOwner();
|
||||
});
|
||||
|
||||
@ -32,4 +43,5 @@ describe('Config API', function () {
|
||||
etag: anyEtag
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -67,5 +67,33 @@ describe('Public-config Service', function () {
|
||||
|
||||
assert.equal(configProperties.mailgunIsConfigured, false);
|
||||
});
|
||||
|
||||
it('should NOT return stats by default', function () {
|
||||
let configProperties = getConfigProperties();
|
||||
|
||||
assert.equal(configProperties.stats, undefined);
|
||||
});
|
||||
|
||||
it('should return stats when tinybird config is set with the stats key', function () {
|
||||
configUtils.set('tinybird', {
|
||||
stats: {
|
||||
endpoint: 'xxx'
|
||||
}
|
||||
});
|
||||
|
||||
let configProperties = getConfigProperties();
|
||||
|
||||
assert.deepEqual(configProperties.stats, {endpoint: 'xxx'});
|
||||
});
|
||||
|
||||
it('should NOT return stats when tinybird config is set without the stats key', function () {
|
||||
configUtils.set('tinybird', {
|
||||
url: 'xxx'
|
||||
});
|
||||
|
||||
let configProperties = getConfigProperties();
|
||||
|
||||
assert.equal(configProperties.stats, undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user