From b89b57b6fb0a366b95b340de674c69ee38edb5c6 Mon Sep 17 00:00:00 2001 From: Naz Gargol Date: Thu, 18 Jul 2019 16:24:34 +0200 Subject: [PATCH] Added global site SEO fields in Admin API (#10923) refs #10921 - New SEO related fields will now be available as a part of Admin API /settings endpoint - The ordering of fields is taken from post's schema - Extended settings test suite with new SEO fields - Adjusted settings model unit test --- core/server/data/schema/default-settings.json | 64 +++++++++++++++++++ .../acceptance/old/admin/settings_spec.js | 59 +++++++++++++++++ core/test/unit/models/settings_spec.js | 6 +- 3 files changed, 126 insertions(+), 3 deletions(-) diff --git a/core/server/data/schema/default-settings.json b/core/server/data/schema/default-settings.json index 32291c95b1..3fb8e12795 100644 --- a/core/server/data/schema/default-settings.json +++ b/core/server/data/schema/default-settings.json @@ -99,6 +99,70 @@ }, "unsplash": { "defaultValue": "{\"isActive\": true}" + }, + "meta_title": { + "defaultValue": null, + "validations": { + "isLength": { + "max": 300 + } + } + }, + "meta_description": { + "defaultValue": null, + "validations": { + "isLength": { + "max": 500 + } + } + }, + "og_image": { + "defaultValue": null, + "validations": { + "isLength": { + "max": 2000 + } + } + }, + "og_title": { + "defaultValue": null, + "validations": { + "isLength": { + "max": 300 + } + } + }, + "og_description": { + "defaultValue": null, + "validations": { + "isLength": { + "max": 300 + } + } + }, + "twitter_image": { + "defaultValue": null, + "validations": { + "isLength": { + "max": 2000 + } + } + }, + "twitter_title": { + "defaultValue": null, + "validations": { + "isLength": { + "max": 300 + } + } + }, + "twitter_description": { + "defaultValue": null, + "validations": { + "isLength": { + "max": 300 + } + } } }, "theme": { diff --git a/core/test/acceptance/old/admin/settings_spec.js b/core/test/acceptance/old/admin/settings_spec.js index 6787779aa0..0220d09dc2 100644 --- a/core/test/acceptance/old/admin/settings_spec.js +++ b/core/test/acceptance/old/admin/settings_spec.js @@ -118,6 +118,38 @@ describe('Settings API', function () { { key: 'is_private', value: false + }, + { + key: 'meta_title', + value: 'SEO title' + }, + { + key: 'meta_description', + value: 'SEO description' + }, + { + key: 'og_image', + value: '/content/images/2019/07/facebook.png' + }, + { + key: 'og_title', + value: 'facebook title' + }, + { + key: 'og_description', + value: 'facebook description' + }, + { + key: 'twitter_image', + value: '/content/images/2019/07/twitter.png' + }, + { + key: 'twitter_title', + value: 'twitter title' + }, + { + key: 'twitter_description', + value: 'twitter description' } ] }; @@ -155,6 +187,33 @@ describe('Settings API', function () { putBody.settings[4].key.should.eql('is_private'); should.equal(putBody.settings[4].value, false); + putBody.settings[5].key.should.eql('meta_title'); + should.equal(putBody.settings[5].value, 'SEO title'); + + putBody.settings[6].key.should.eql('meta_description'); + should.equal(putBody.settings[6].value, 'SEO description'); + + putBody.settings[6].key.should.eql('meta_description'); + should.equal(putBody.settings[6].value, 'SEO description'); + + putBody.settings[7].key.should.eql('og_image'); + should.equal(putBody.settings[7].value, '/content/images/2019/07/facebook.png'); + + putBody.settings[8].key.should.eql('og_title'); + should.equal(putBody.settings[8].value, 'facebook title'); + + putBody.settings[9].key.should.eql('og_description'); + should.equal(putBody.settings[9].value, 'facebook description'); + + putBody.settings[10].key.should.eql('twitter_image'); + should.equal(putBody.settings[10].value, '/content/images/2019/07/twitter.png'); + + putBody.settings[11].key.should.eql('twitter_title'); + should.equal(putBody.settings[11].value, 'twitter title'); + + putBody.settings[12].key.should.eql('twitter_description'); + should.equal(putBody.settings[12].value, 'twitter description'); + localUtils.API.checkResponse(putBody, 'settings'); done(); }); diff --git a/core/test/unit/models/settings_spec.js b/core/test/unit/models/settings_spec.js index adf349f241..f5f65d47d2 100644 --- a/core/test/unit/models/settings_spec.js +++ b/core/test/unit/models/settings_spec.js @@ -113,7 +113,7 @@ describe('Unit: models/settings', function () { return models.Settings.populateDefaults() .then(() => { - eventSpy.callCount.should.equal(62); + eventSpy.callCount.should.equal(78); eventSpy.args[1][0].should.equal('settings.db_hash.added'); eventSpy.args[1][1].attributes.type.should.equal('core'); @@ -122,7 +122,7 @@ describe('Unit: models/settings', function () { eventSpy.args[13][1].attributes.type.should.equal('blog'); eventSpy.args[13][1].attributes.value.should.equal('The professional publishing platform'); - eventSpy.args[61][0].should.equal('settings.members_subscription_settings.added'); + eventSpy.args[77][0].should.equal('settings.members_subscription_settings.added'); }); }); @@ -136,7 +136,7 @@ describe('Unit: models/settings', function () { return models.Settings.populateDefaults() .then(() => { - eventSpy.callCount.should.equal(60); + eventSpy.callCount.should.equal(76); eventSpy.args[13][0].should.equal('settings.logo.added'); });