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
This commit is contained in:
Naz Gargol 2019-07-18 16:24:34 +02:00 committed by GitHub
parent 078060abdc
commit b89b57b6fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 126 additions and 3 deletions

View File

@ -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": {

View File

@ -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();
});

View File

@ -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');
});