Ghost/test/regression/settings/settings.test.js
Hannah Wolfe f08a55c21f
Renamed tests to .test.js & updated commands
refs: https://github.com/TryGhost/Team/issues/856
refs: https://github.com/TryGhost/Team/issues/756

- The .test.js extension is better than _spec.js as it's more obvious that it's an extension
- It also meaans we can use the --extension parameter in mocha, which should result in a better default behaviour for `yarn test`
- It also highlights that some of our tests were named incorrectly and were not (and still will not be) run (see https://github.com/TryGhost/Team/issues/856)
- Note: even with this change, `yarn test` is throwing errors, I believe because of this issue https://github.com/TryGhost/Team/issues/756
2021-07-06 20:45:01 +01:00

54 lines
1.8 KiB
JavaScript

const db = require('../../../core/server/data/db');
const testUtils = require('../../utils');
/**
* @NOTE
*
* If this test fails for you, you have modified the default settings.
* When you make a change or add new setting, please ensure that:
* - If a new `core` setting is added/removed/renamed, update the below whitelist
* - If a new non-`core` setting is added, it includes corresponding migration to populate its `group` and `flags`
*/
describe('Settings', function () {
before(function () {
return testUtils.startGhost();
});
// Allowlist: Only this list needs updating when a core setting is added/removed/renamed
const coreSettingKeys = [
'db_hash',
'routes_hash',
'next_update_check',
'notifications',
'session_secret',
'theme_session_secret',
'ghost_public_key',
'ghost_private_key',
'members_public_key',
'members_private_key',
'members_email_auth_secret',
'members_stripe_webhook_id',
'members_stripe_webhook_secret'
];
// If this test is failing, then it is likely a new setting has been added without group migration
// In case of `core` setting modifications, allowlist above needs to be updated
it('should not modify core keys without fixing this test', function () {
return db.knex('settings')
.where('group', 'core')
.whereNotIn('key', coreSettingKeys)
.count('*')
.then(function (data) {
const countResult = data[0]['count(*)'];
countResult.should.eql(0);
})
.catch(function (err) {
// CASE: table does not exist
if (err.errno === 1146) {
return Promise.resolve();
}
throw err;
});
});
});