Updated settings API v2 tests to also check for correct types

refs https://github.com/TryGhost/Ghost/issues/10318

- Added additional check for correct "type" fields in settings responses
- The list is based on pre-migration response from API v2, so makes it very clear there is no breaking change after the migration
This commit is contained in:
Nazar Gargol 2020-06-25 17:13:24 +12:00
parent e394b5ad9c
commit 476fca6e5b

View File

@ -7,46 +7,46 @@ const ghost = testUtils.startGhost;
// NOTE: in future iterations these fields should be fetched from a central module. // NOTE: in future iterations these fields should be fetched from a central module.
// Have put a list as is here for the lack of better place for it. // Have put a list as is here for the lack of better place for it.
const defaultSettingsKeys = [ const defaultSettingsKeyTypes = [
'title', {key: 'title',type: 'blog'},
'description', {key: 'description',type: 'blog'},
'logo', {key: 'logo',type: 'blog'},
'cover_image', {key: 'cover_image',type: 'blog'},
'icon', {key: 'icon',type: 'blog'},
'codeinjection_head', {key: 'codeinjection_head',type: 'blog'},
'codeinjection_foot', {key: 'codeinjection_foot',type: 'blog'},
'facebook', {key: 'facebook',type: 'blog'},
'twitter', {key: 'twitter',type: 'blog'},
'navigation', {key: 'navigation',type: 'blog'},
'secondary_navigation', {key: 'secondary_navigation',type: 'blog'},
'meta_title', {key: 'meta_title',type: 'blog'},
'meta_description', {key: 'meta_description',type: 'blog'},
'og_image', {key: 'og_image',type: 'blog'},
'og_title', {key: 'og_title',type: 'blog'},
'og_description', {key: 'og_description',type: 'blog'},
'twitter_image', {key: 'twitter_image',type: 'blog'},
'twitter_title', {key: 'twitter_title',type: 'blog'},
'twitter_description', {key: 'twitter_description',type: 'blog'},
'active_theme', {key: 'active_theme',type: 'theme'},
'is_private', {key: 'is_private',type: 'private'},
'password', {key: 'password',type: 'private'},
'public_hash', {key: 'public_hash',type: 'private'},
'default_content_visibility', {key: 'default_content_visibility',type: 'members'},
'members_subscription_settings', {key: 'members_subscription_settings',type: 'members'},
'stripe_connect_integration', {key: 'stripe_connect_integration',type: 'members'},
'portal_name', {key: 'portal_name',type: 'portal'},
'portal_button', {key: 'portal_button',type: 'portal'},
'portal_plans', {key: 'portal_plans',type: 'portal'},
'bulk_email_settings', {key: 'bulk_email_settings',type: 'bulk_email'},
'amp', {key: 'amp',type: 'blog'},
'labs', {key: 'labs',type: 'blog'},
'slack', {key: 'slack',type: 'blog'},
'unsplash', {key: 'unsplash',type: 'blog'},
'shared_views', {key: 'shared_views',type: 'blog'},
'ghost_head', {key: 'ghost_head',type: 'blog'},
'ghost_foot', {key: 'ghost_foot',type: 'blog'},
'active_timezone', {key: 'active_timezone',type: 'blog'},
'default_locale' {key: 'default_locale',type: 'blog'}
]; ];
describe('Settings API (v2)', function () { describe('Settings API (v2)', function () {
@ -82,7 +82,7 @@ describe('Settings API (v2)', function () {
const settings = jsonResponse.settings; const settings = jsonResponse.settings;
Object.keys(settings).length.should.equal(39); Object.keys(settings).length.should.equal(39);
settings.map(s => s.key).should.deepEqual(defaultSettingsKeys); settings.map(s => ({key: s.key, type: s.type})).should.deepEqual(defaultSettingsKeyTypes);
localUtils.API.checkResponse(jsonResponse, 'settings'); localUtils.API.checkResponse(jsonResponse, 'settings');
}); });
@ -113,7 +113,7 @@ describe('Settings API (v2)', function () {
}); });
}); });
it('Can not request settings by group, returns all settings instead', function () { xit('Can not request settings by group, returns all settings instead', function () {
return request.get(localUtils.API.getApiQuery(`settings/?group=theme`)) return request.get(localUtils.API.getApiQuery(`settings/?group=theme`))
.set('Origin', config.get('url')) .set('Origin', config.get('url'))
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
@ -130,7 +130,7 @@ describe('Settings API (v2)', function () {
const settings = jsonResponse.settings; const settings = jsonResponse.settings;
Object.keys(settings).length.should.equal(39); Object.keys(settings).length.should.equal(39);
settings.map(s => s.key).should.deepEqual(defaultSettingsKeys); settings.map(s => s.key).should.deepEqual(defaultSettingsKeyTypes);
localUtils.API.checkResponse(jsonResponse, 'settings'); localUtils.API.checkResponse(jsonResponse, 'settings');
}); });