mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Improved test settings fixtures
no issue - the settings fixtures file was becoming hard to use because settings have been appended to it on an as-used basis which meant it was difficult to reason about the base-state in acceptance tests and was never really in sync with the default settings state for a Ghost site - added a utility function to create a settings object with the `id` defined to avoid problems with manually updating the ids in the list - updated to include all default settings with their default values if not already set to a specific testing value in the old fixtures
This commit is contained in:
parent
3d0e4c9380
commit
b123b297b6
4 changed files with 141 additions and 289 deletions
|
@ -1,278 +1,117 @@
|
|||
/* eslint-disable camelcase */
|
||||
import moment from 'moment';
|
||||
|
||||
let id = 0;
|
||||
|
||||
function setting(group, key, value) {
|
||||
id = id + 1;
|
||||
|
||||
return {
|
||||
id,
|
||||
group,
|
||||
key,
|
||||
value,
|
||||
updated_at: moment.utc().format(),
|
||||
updated_by: 1,
|
||||
created_at: moment.utc().format(),
|
||||
created_by: 1
|
||||
};
|
||||
}
|
||||
|
||||
// These settings represent a default new site setup
|
||||
// Real default settings can be found in https://github.com/TryGhost/Ghost/blob/main/core/server/data/schema/default-settings/default-settings.json
|
||||
export default [
|
||||
{
|
||||
id: 1,
|
||||
created_at: '2015-09-11T09:44:30.805Z',
|
||||
created_by: 1,
|
||||
key: 'title',
|
||||
group: 'site',
|
||||
updated_at: '2015-10-04T16:26:05.195Z',
|
||||
updated_by: 1,
|
||||
value: 'Test Blog'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
created_at: '2015-09-11T09:44:30.806Z',
|
||||
created_by: 1,
|
||||
key: 'description',
|
||||
group: 'site',
|
||||
updated_at: '2015-10-04T16:26:05.198Z',
|
||||
updated_by: 1,
|
||||
value: 'Thoughts, stories and ideas.'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
key: 'logo',
|
||||
value: '/content/images/2013/Nov/logo.png',
|
||||
group: 'site',
|
||||
created_at: '2013-11-25T14:48:11.000Z',
|
||||
created_by: 1,
|
||||
updated_at: '2015-10-27T17:39:58.273Z',
|
||||
updated_by: 1
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
key: 'cover_image',
|
||||
value: '/content/images/2014/Feb/cover.jpg',
|
||||
group: 'site',
|
||||
created_at: '2013-11-25T14:48:11.000Z',
|
||||
created_by: 1,
|
||||
updated_at: '2015-10-27T17:39:58.276Z',
|
||||
updated_by: 1
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
key: 'locale',
|
||||
value: 'en',
|
||||
group: 'site',
|
||||
created_at: '2013-11-25T14:48:11.000Z',
|
||||
created_by: 1,
|
||||
updated_at: '2015-10-27T17:39:58.278Z',
|
||||
updated_by: 1
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
created_at: '2015-09-11T09:44:30.809Z',
|
||||
created_by: 1,
|
||||
key: 'codeinjection_head',
|
||||
group: 'site',
|
||||
updated_at: '2015-09-23T13:32:49.858Z',
|
||||
updated_by: 1,
|
||||
value: ''
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
created_at: '2015-09-11T09:44:30.809Z',
|
||||
created_by: 1,
|
||||
key: 'codeinjection_foot',
|
||||
group: 'site',
|
||||
updated_at: '2015-09-23T13:32:49.858Z',
|
||||
updated_by: 1,
|
||||
value: ''
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
key: 'labs',
|
||||
value: JSON.stringify({
|
||||
// Keep the GA flags that are not yet cleaned up in frontend code here
|
||||
}),
|
||||
group: 'labs',
|
||||
created_at: '2015-01-12T18:29:01.000Z',
|
||||
created_by: 1,
|
||||
updated_at: '2015-10-27T17:39:58.288Z',
|
||||
updated_by: 1
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
created_at: '2015-09-11T09:44:30.810Z',
|
||||
created_by: 1,
|
||||
key: 'navigation',
|
||||
group: 'site',
|
||||
updated_at: '2015-09-23T13:32:49.868Z',
|
||||
updated_by: 1,
|
||||
value: JSON.stringify([
|
||||
{label: 'Home', url: '/'},
|
||||
{label: 'About', url: '/about'}
|
||||
])
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
created_at: '2015-09-11T09:44:30.810Z',
|
||||
created_by: 1,
|
||||
key: 'is_private',
|
||||
group: 'private',
|
||||
updated_at: '2015-09-23T13:32:49.868Z',
|
||||
updated_by: 1,
|
||||
value: false
|
||||
},
|
||||
{
|
||||
id: 15,
|
||||
created_at: '2015-09-11T09:44:30.810Z',
|
||||
created_by: 1,
|
||||
key: 'password',
|
||||
group: 'private',
|
||||
updated_at: '2015-09-23T13:32:49.868Z',
|
||||
updated_by: 1,
|
||||
value: ''
|
||||
},
|
||||
{
|
||||
id: 16,
|
||||
created_at: '2016-05-05T15:04:03.115Z',
|
||||
created_by: 1,
|
||||
key: 'slack_username',
|
||||
group: 'slack',
|
||||
updated_at: '2022-05-05T18:33:09.168Z',
|
||||
updated_by: 1,
|
||||
value: 'Ghost'
|
||||
},
|
||||
{
|
||||
id: 17,
|
||||
created_at: '2016-05-05T15:40:12.133Z',
|
||||
created_by: 1,
|
||||
key: 'facebook',
|
||||
group: 'site',
|
||||
updated_at: '2016-05-08T15:20:25.953Z',
|
||||
updated_by: 1,
|
||||
value: 'test'
|
||||
},
|
||||
{
|
||||
id: 18,
|
||||
created_at: '2016-05-05T15:40:12.134Z',
|
||||
created_by: 1,
|
||||
key: 'twitter',
|
||||
group: 'site',
|
||||
updated_at: '2016-05-08T15:20:25.954Z',
|
||||
updated_by: 1,
|
||||
value: '@test'
|
||||
},
|
||||
{
|
||||
id: 19,
|
||||
created_at: '2015-09-11T09:44:30.810Z',
|
||||
created_by: 1,
|
||||
key: 'timezone',
|
||||
group: 'site',
|
||||
updated_at: '2015-09-23T13:32:49.868Z',
|
||||
updated_by: 1,
|
||||
value: 'Etc/UTC'
|
||||
},
|
||||
{
|
||||
id: 21,
|
||||
created_at: '2017-01-09T08:40:59.000Z',
|
||||
created_by: 1,
|
||||
key: 'amp',
|
||||
group: 'amp',
|
||||
updated_at: '2017-01-09T08:49:42.991Z',
|
||||
updated_by: 1,
|
||||
value: 'true'
|
||||
},
|
||||
{
|
||||
id: 22,
|
||||
key: 'icon',
|
||||
value: '/content/images/2014/Feb/favicon.ico',
|
||||
group: 'site',
|
||||
created_at: '2013-11-25T14:48:11.000Z',
|
||||
created_by: 1,
|
||||
updated_at: '2015-10-27T17:39:58.276Z',
|
||||
updated_by: 1
|
||||
},
|
||||
{
|
||||
id: 23,
|
||||
group: 'members',
|
||||
key: 'members_subscription_settings',
|
||||
value: '{"allowSelfSignup":true,"fromAddress":"noreply","paymentProcessors":[{"adapter":"stripe","config":{"secret_token":"","public_token":"","tier":{"name":"Ghost Subscription"},"plans":[{"name":"Monthly","currency":"usd","interval":"month","amount":""},{"name":"Yearly","currency":"usd","interval":"year","amount":""}]}}]}',
|
||||
created_at: '2019-10-09T09:49:00.000Z',
|
||||
created_by: 1,
|
||||
updated_at: '2019-10-09T09:49:00.000Z',
|
||||
updated_by: 1
|
||||
},
|
||||
{
|
||||
id: 24,
|
||||
group: 'email',
|
||||
key: 'bulk_email_settings',
|
||||
value: '{"provider":"mailgun","apiKey":"","domain":"","baseUrl":""}',
|
||||
created_at: '2019-10-09T09:49:00.000Z',
|
||||
created_by: 1,
|
||||
updated_at: '2019-10-09T09:49:00.000Z',
|
||||
updated_by: 1
|
||||
},
|
||||
{
|
||||
id: 25,
|
||||
key: 'secondary_navigation',
|
||||
group: 'site',
|
||||
created_at: '2019-11-20T09:44:30.810Z',
|
||||
created_by: 1,
|
||||
updated_at: '2019-11-20T13:32:49.868Z',
|
||||
updated_by: 1,
|
||||
value: JSON.stringify([])
|
||||
},
|
||||
{
|
||||
id: 26,
|
||||
created_at: '2020-01-09T08:40:59.000Z',
|
||||
created_by: 1,
|
||||
key: 'unsplash',
|
||||
group: 'unsplash',
|
||||
updated_at: '2020-01-09T08:49:42.991Z',
|
||||
updated_by: 1,
|
||||
value: 'true'
|
||||
},
|
||||
{
|
||||
id: 27,
|
||||
created_at: '2021-11-01T15:44:43.494Z',
|
||||
created_by: 1,
|
||||
key: 'active_theme',
|
||||
group: 'theme',
|
||||
updated_at: '2021-11-01T15:44:43.494Z',
|
||||
updated_by: 1,
|
||||
value: 'casper'
|
||||
},
|
||||
{
|
||||
id: 28,
|
||||
created_at: '2022-02-16T09:38:00.000Z',
|
||||
created_by: 1,
|
||||
key: 'members_signup_access',
|
||||
group: 'members',
|
||||
updated_at: '2022-02-16T09:38:00.000Z',
|
||||
updated_by: 1,
|
||||
value: 'all'
|
||||
},
|
||||
{
|
||||
id: 29,
|
||||
created_at: '2022-02-16T09:38:00.000Z',
|
||||
created_by: 1,
|
||||
key: 'default_content_visibility',
|
||||
group: 'members',
|
||||
updated_at: '2022-02-16T09:38:00.000Z',
|
||||
updated_by: 1,
|
||||
value: 'public'
|
||||
},
|
||||
{
|
||||
id: 30,
|
||||
created_at: '2022-02-16T09:38:00.000Z',
|
||||
created_by: 1,
|
||||
key: 'default_content_visibility_tiers',
|
||||
group: 'members',
|
||||
updated_at: '2022-02-16T09:38:00.000Z',
|
||||
updated_by: 1,
|
||||
value: '[]'
|
||||
},
|
||||
{
|
||||
id: 31,
|
||||
created_at: '2022-02-21T13:47:00.000Z',
|
||||
created_by: 1,
|
||||
key: 'email_track_opens',
|
||||
group: 'email',
|
||||
updated_at: '2022-02-21T13:47:00.000Z',
|
||||
updated_by: 1,
|
||||
value: 'true'
|
||||
},
|
||||
{
|
||||
id: 33,
|
||||
created_at: '2016-05-05T15:04:03.115Z',
|
||||
created_by: 1,
|
||||
key: 'slack_url',
|
||||
group: 'slack',
|
||||
updated_at: '2022-05-05T18:33:09.168Z',
|
||||
updated_by: 1,
|
||||
value: ''
|
||||
}
|
||||
// SITE
|
||||
setting('site', 'title', 'Test Blog'),
|
||||
setting('site', 'description', 'Thoughts, stories and ideas'),
|
||||
setting('site', 'logo', '/content/images/2013/Nov/logo.png'),
|
||||
setting('site', 'cover_image', '/content/images/2014/Feb/cover.jpg'),
|
||||
setting('site', 'icon', '/content/images/2014/Feb/favicon.ico'),
|
||||
setting('site', 'accent_color', '#ff1a75'),
|
||||
setting('site', 'locale', 'en'),
|
||||
setting('site', 'timezone', 'Etc/UTC'),
|
||||
setting('site', 'codeinjection_head', null),
|
||||
setting('site', 'codeinjection_foot', null),
|
||||
setting('site', 'facebook', 'test'),
|
||||
setting('site', 'twitter', '@test'),
|
||||
setting('site', 'navigation', JSON.stringify([
|
||||
{label: 'Home', url: '/'},
|
||||
{label: 'About', url: '/about'}
|
||||
])),
|
||||
setting('site', 'secondary_navigation', JSON.stringify([])),
|
||||
setting('site', 'meta_title', null),
|
||||
setting('site', 'meta_description', null),
|
||||
setting('site', 'og_image', null),
|
||||
setting('site', 'og_title', null),
|
||||
setting('site', 'og_description', null),
|
||||
setting('site', 'twitter_image', null),
|
||||
setting('site', 'twitter_title', null),
|
||||
setting('site', 'twitter_description', null),
|
||||
|
||||
// THEME
|
||||
setting('theme', 'active_theme', 'Casper'),
|
||||
|
||||
// PRIVATE
|
||||
setting('private', 'is_private', 'false'),
|
||||
setting('private', 'password', ''),
|
||||
setting('private', 'public_hash', ''),
|
||||
|
||||
// MEMBERS
|
||||
setting('members', 'default_content_visibility', 'public'),
|
||||
setting('members', 'default_content_visibility_tiers', JSON.stringify([])),
|
||||
setting('members', 'members_signup_access', 'all'),
|
||||
setting('members', 'members_support_address', 'noreply'),
|
||||
setting('members', 'stripe_secret_key', null),
|
||||
setting('members', 'stripe_publishable_key', null),
|
||||
setting('members', 'stripe_plans', JSON.stringify([])),
|
||||
setting('members', 'stripe_connect_publishable_key', 'pk_test_for_stripe'),
|
||||
setting('members', 'stripe_connect_secret_key', 'sk_test_for_stripe'),
|
||||
setting('members', 'stripe_connect_livemode', null),
|
||||
setting('members', 'stripe_connect_display_name', null),
|
||||
setting('members', 'stripe_connect_account_id', null),
|
||||
setting('members', 'members_monthly_price_id', null),
|
||||
setting('members', 'members_yearly_price_id', null),
|
||||
|
||||
// PORTAL
|
||||
setting('portal', 'portal_name', 'true'),
|
||||
setting('portal', 'portal_button', 'true'),
|
||||
setting('portal', 'portal_plans', JSON.stringify(['free'])),
|
||||
setting('portal', 'portal_products', JSON.stringify([])),
|
||||
setting('portal', 'portal_button_style', 'icon-and-text'),
|
||||
setting('portal', 'portal_button_icon', null),
|
||||
setting('portal', 'portal_button_signup_text', 'Subscribe'),
|
||||
|
||||
// EMAIL
|
||||
setting('email', 'mailgun_domain', null),
|
||||
setting('email', 'mailgun_api_key', null),
|
||||
setting('email', 'mailgun_base_url', null),
|
||||
setting('email', 'email_track_opens', 'true'),
|
||||
setting('email', 'email_verification_required', 'false'),
|
||||
|
||||
// AMP
|
||||
setting('amp', 'amp', 'false'),
|
||||
setting('amp', 'amp_gtag_id', null),
|
||||
|
||||
// FIRSTPROMOTER
|
||||
setting('firstpromoter', 'firstpromoter', 'false'),
|
||||
setting('firstpromoter', 'firstpromoter_id', null),
|
||||
|
||||
// LABS
|
||||
setting('labs', 'labs', JSON.stringify({
|
||||
// Keep the GA flags that are not yet cleaned up in frontend code here
|
||||
})),
|
||||
|
||||
// SLACK
|
||||
setting('slack', 'slack_url', ''),
|
||||
setting('slack', 'slack_username', 'Ghost'),
|
||||
|
||||
// UNSPLASH
|
||||
setting('unsplash', 'unsplash', 'true'),
|
||||
|
||||
// VIEWS
|
||||
setting('views', 'shared_views', JSON.stringify([])),
|
||||
|
||||
// EDITOR
|
||||
setting('editor', 'editor_default_email_recipients', 'visibility'),
|
||||
setting('editor', 'editor_default_email_recipients_filter', 'all')
|
||||
];
|
||||
|
|
|
@ -66,19 +66,19 @@ describe('Acceptance: Settings - Integrations - AMP', function () {
|
|||
// has correct url
|
||||
expect(currentURL(), 'currentURL').to.equal('/settings/integrations/amp');
|
||||
|
||||
// AMP is enabled by default
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox').to.be.true;
|
||||
// AMP is disabled by default
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox').to.be.false;
|
||||
|
||||
await click('[data-test-amp-checkbox]');
|
||||
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox').to.be.false;
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox').to.be.true;
|
||||
|
||||
await click('[data-test-save-button]');
|
||||
|
||||
let [lastRequest] = this.server.pretender.handledRequests.slice(-1);
|
||||
let params = JSON.parse(lastRequest.requestBody);
|
||||
|
||||
expect(params.settings.findBy('key', 'amp').value).to.equal(false);
|
||||
expect(params.settings.findBy('key', 'amp').value).to.equal(true);
|
||||
|
||||
// CMD-S shortcut works
|
||||
await click('[data-test-amp-checkbox]');
|
||||
|
@ -93,8 +93,8 @@ describe('Acceptance: Settings - Integrations - AMP', function () {
|
|||
let [newRequest] = this.server.pretender.handledRequests.slice(-1);
|
||||
params = JSON.parse(newRequest.requestBody);
|
||||
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox').to.be.true;
|
||||
expect(params.settings.findBy('key', 'amp').value).to.equal(true);
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox').to.be.false;
|
||||
expect(params.settings.findBy('key', 'amp').value).to.equal(false);
|
||||
});
|
||||
|
||||
it('warns when leaving without saving', async function () {
|
||||
|
@ -103,12 +103,12 @@ describe('Acceptance: Settings - Integrations - AMP', function () {
|
|||
// has correct url
|
||||
expect(currentURL(), 'currentURL').to.equal('/settings/integrations/amp');
|
||||
|
||||
// AMP is enabled by default
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox default').to.be.true;
|
||||
// AMP is disabled by default
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox default').to.be.false;
|
||||
|
||||
await click('[data-test-amp-checkbox]');
|
||||
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox after click').to.be.false;
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox after click').to.be.true;
|
||||
|
||||
await visit('/settings/staff');
|
||||
|
||||
|
@ -124,7 +124,7 @@ describe('Acceptance: Settings - Integrations - AMP', function () {
|
|||
expect(currentURL(), 'currentURL after return').to.equal('/settings/integrations/amp');
|
||||
|
||||
// settings were not saved
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox').to.be.true;
|
||||
expect(find('[data-test-amp-checkbox]').checked, 'AMP checkbox').to.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -82,7 +82,7 @@ describe('Acceptance: Settings - Code-Injection', function () {
|
|||
let [lastRequest] = this.server.pretender.handledRequests.slice(-1);
|
||||
let params = JSON.parse(lastRequest.requestBody);
|
||||
|
||||
expect(params.settings.findBy('key', 'codeinjection_head').value).to.equal('');
|
||||
expect(params.settings.findBy('key', 'codeinjection_head').value).to.equal(null);
|
||||
expect(find('[data-test-save-button]').textContent.trim(), 'save button text').to.equal('Save');
|
||||
|
||||
// CMD-S shortcut works
|
||||
|
@ -96,7 +96,7 @@ describe('Acceptance: Settings - Code-Injection', function () {
|
|||
let [newRequest] = this.server.pretender.handledRequests.slice(-1);
|
||||
params = JSON.parse(newRequest.requestBody);
|
||||
|
||||
expect(params.settings.findBy('key', 'codeinjection_head').value).to.equal('');
|
||||
expect(params.settings.findBy('key', 'codeinjection_head').value).to.equal(null);
|
||||
expect(find('[data-test-save-button]').textContent.trim(), 'save button text').to.equal('Save');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -92,13 +92,15 @@ describe('Acceptance: Settings - Integrations - Custom', function () {
|
|||
|
||||
describe('navigation', function () {
|
||||
beforeEach(async function () {
|
||||
this.server.loadFixtures('settings');
|
||||
|
||||
let role = this.server.create('role', {name: 'Administrator'});
|
||||
this.server.create('user', {roles: [role]});
|
||||
|
||||
return await authenticateSession();
|
||||
});
|
||||
|
||||
it('renders correctly', async function () {
|
||||
it('renders defaults correctly', async function () {
|
||||
await visit('/settings/integrations');
|
||||
|
||||
// slack is not configured in the fixtures
|
||||
|
@ -107,7 +109,18 @@ describe('Acceptance: Settings - Integrations - Custom', function () {
|
|||
'slack app status'
|
||||
).to.equal('Configure');
|
||||
|
||||
// amp is enabled in the fixtures
|
||||
// amp is disabled in the fixtures
|
||||
expect(
|
||||
find('[data-test-app="amp"] [data-test-app-status]').textContent.trim(),
|
||||
'amp app status'
|
||||
).to.equal('Configure');
|
||||
});
|
||||
|
||||
it('renders AMP active state', async function () {
|
||||
this.server.db.settings.update({key: 'amp', value: true});
|
||||
await visit('/settings/integrations');
|
||||
|
||||
// amp switches to active when enabled
|
||||
expect(
|
||||
find('[data-test-app="amp"] [data-test-app-status]').textContent.trim(),
|
||||
'amp app status'
|
||||
|
|
Loading…
Add table
Reference in a new issue