mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Switched AMP to be 'off' by default in all new Ghost instances (#13907)
refs https://github.com/TryGhost/Team/issues/1189 Support for AMP is slowly in decline, and makes developing new cards trickier, since AMP no longer has an effect of SEO we're going to disable it by default as a first step toward moving away from it. Co-authored-by: Thibaut Patel <thibaut@ghost.org>
This commit is contained in:
parent
8df29f6574
commit
10c214c148
@ -397,7 +397,7 @@
|
||||
},
|
||||
"amp": {
|
||||
"amp": {
|
||||
"defaultValue": "true",
|
||||
"defaultValue": "false",
|
||||
"validations": {
|
||||
"isIn": [["true", "false"]]
|
||||
},
|
||||
|
@ -35,7 +35,7 @@ describe('Settings API', function () {
|
||||
localUtils.API.checkResponse(jsonResponse, 'settings');
|
||||
|
||||
JSON.parse(_.find(jsonResponse.settings, {key: 'unsplash'}).value).should.eql(true);
|
||||
JSON.parse(_.find(jsonResponse.settings, {key: 'amp'}).value).should.eql(true);
|
||||
JSON.parse(_.find(jsonResponse.settings, {key: 'amp'}).value).should.eql(false);
|
||||
should.not.exist(_.find(jsonResponse.settings, {key: 'permalinks'}));
|
||||
should.not.exist(_.find(jsonResponse.settings, {key: 'ghost_head'}));
|
||||
should.not.exist(_.find(jsonResponse.settings, {key: 'ghost_foot'}));
|
||||
|
@ -1,8 +1,10 @@
|
||||
const should = require('should');
|
||||
const sinon = require('sinon');
|
||||
const supertest = require('supertest');
|
||||
const testUtils = require('../utils');
|
||||
const configUtils = require('../utils/configUtils');
|
||||
const urlUtils = require('../utils/urlUtils');
|
||||
const settings = require('../../core/shared/settings-cache');
|
||||
|
||||
let request;
|
||||
|
||||
@ -31,6 +33,10 @@ describe('Advanced URL Configurations', function () {
|
||||
urlUtils.restore();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
it('http://localhost should 404', async function () {
|
||||
await request.get('/')
|
||||
.expect(404);
|
||||
@ -67,11 +73,22 @@ describe('Advanced URL Configurations', function () {
|
||||
.expect(404);
|
||||
});
|
||||
|
||||
it('/blog/welcome/amp/ should 200', async function () {
|
||||
it('/blog/welcome/amp/ should 200 if amp is enabled', async function () {
|
||||
sinon.stub(settings, 'get').callsFake(function (key, ...rest) {
|
||||
if (key === 'amp') {
|
||||
return true;
|
||||
}
|
||||
return settings.get.wrappedMethod.call(settings, key, ...rest);
|
||||
});
|
||||
await request.get('/blog/welcome/amp/')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/blog/welcome/amp/ should 301', async function () {
|
||||
await request.get('/blog/welcome/amp/')
|
||||
.expect(301);
|
||||
});
|
||||
|
||||
it('/welcome/amp/ should 404', async function () {
|
||||
await request.get('/welcome/amp/')
|
||||
.expect(404);
|
||||
|
@ -190,6 +190,15 @@ describe('Default Frontend routing', function () {
|
||||
});
|
||||
|
||||
describe('AMP post', function () {
|
||||
describe('AMP Enabled', function () {
|
||||
beforeEach(function () {
|
||||
sinon.stub(settingsCache, 'get').callsFake(function (key, options) {
|
||||
if (key === 'amp' && !options) {
|
||||
return true;
|
||||
}
|
||||
return origCache.get(key, options);
|
||||
});
|
||||
});
|
||||
it('should respond with html for valid url', async function () {
|
||||
await request.get('/welcome/amp/')
|
||||
.expect('Content-Type', /html/)
|
||||
@ -226,16 +235,18 @@ describe('Default Frontend routing', function () {
|
||||
.expect(/Page not found/)
|
||||
.expect(assertCorrectFrontendHeaders);
|
||||
});
|
||||
});
|
||||
|
||||
describe('AMP Disabled', function () {
|
||||
it('/amp/ should redirect to regular post, including any query params', async function () {
|
||||
beforeEach(function () {
|
||||
sinon.stub(settingsCache, 'get').callsFake(function (key, options) {
|
||||
if (key === 'amp' && !options) {
|
||||
return false;
|
||||
}
|
||||
return origCache.get(key, options);
|
||||
});
|
||||
|
||||
});
|
||||
it('/amp/ should redirect to regular post, including any query params', async function () {
|
||||
await request.get('/welcome/amp/?q=a')
|
||||
.expect('Location', '/welcome/?q=a')
|
||||
.expect(301)
|
||||
|
@ -66,7 +66,9 @@ describe('Integration - Web - Site canary', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('AMP enabled', function () {
|
||||
it('serve amp', function () {
|
||||
localUtils.defaultMocks(sinon, {amp: true});
|
||||
const req = {
|
||||
secure: true,
|
||||
method: 'GET',
|
||||
@ -81,6 +83,24 @@ describe('Integration - Web - Site canary', function () {
|
||||
response.body.should.match(/<h1>HTML Ipsum Presents<\/h1>/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('AMP disabled', function () {
|
||||
it('serve amp', function () {
|
||||
localUtils.defaultMocks(sinon, {amp: false});
|
||||
const req = {
|
||||
secure: true,
|
||||
method: 'GET',
|
||||
url: '/html-ipsum/amp/',
|
||||
host: 'example.com'
|
||||
};
|
||||
|
||||
return localUtils.mockExpress.invoke(app, req)
|
||||
.then(function (response) {
|
||||
response.statusCode.should.eql(301);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('post not found', function () {
|
||||
const req = {
|
||||
|
@ -66,7 +66,9 @@ describe('Integration - Web - Site v2', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('AMP enabled', function () {
|
||||
it('serve amp', function () {
|
||||
localUtils.defaultMocks(sinon, {amp: true});
|
||||
const req = {
|
||||
secure: true,
|
||||
method: 'GET',
|
||||
@ -81,6 +83,24 @@ describe('Integration - Web - Site v2', function () {
|
||||
response.body.should.match(/<h1>HTML Ipsum Presents<\/h1>/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('AMP disabled', function () {
|
||||
it('serve amp', function () {
|
||||
localUtils.defaultMocks(sinon, {amp: false});
|
||||
const req = {
|
||||
secure: true,
|
||||
method: 'GET',
|
||||
url: '/html-ipsum/amp/',
|
||||
host: 'example.com'
|
||||
};
|
||||
|
||||
return localUtils.mockExpress.invoke(app, req)
|
||||
.then(function (response) {
|
||||
response.statusCode.should.eql(301);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('post not found', function () {
|
||||
const req = {
|
||||
|
@ -66,7 +66,9 @@ describe('Integration - Web - Site v3', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('AMP enabled', function () {
|
||||
it('serve amp', function () {
|
||||
localUtils.defaultMocks(sinon, {amp: true});
|
||||
const req = {
|
||||
secure: true,
|
||||
method: 'GET',
|
||||
@ -81,6 +83,24 @@ describe('Integration - Web - Site v3', function () {
|
||||
response.body.should.match(/<h1>HTML Ipsum Presents<\/h1>/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('AMP disabled', function () {
|
||||
it('serve amp', function () {
|
||||
localUtils.defaultMocks(sinon, {amp: false});
|
||||
const req = {
|
||||
secure: true,
|
||||
method: 'GET',
|
||||
url: '/html-ipsum/amp/',
|
||||
host: 'example.com'
|
||||
};
|
||||
|
||||
return localUtils.mockExpress.invoke(app, req)
|
||||
.then(function (response) {
|
||||
response.statusCode.should.eql(301);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('post not found', function () {
|
||||
const req = {
|
||||
|
@ -11,6 +11,7 @@ const _ = require('lodash');
|
||||
const testUtils = require('../../utils');
|
||||
const configUtils = require('../../utils/configUtils');
|
||||
const config = require('../../../core/shared/config');
|
||||
const settingsCache = require('../../../core/shared/settings-cache');
|
||||
let request;
|
||||
|
||||
describe('Frontend Routing', function () {
|
||||
@ -218,6 +219,10 @@ describe('Frontend Routing', function () {
|
||||
});
|
||||
|
||||
describe('amp', function () {
|
||||
describe('amp enabled', function (){
|
||||
beforeEach(function () {
|
||||
sinon.stub(settingsCache, 'get').withArgs('amp').returns(true);
|
||||
});
|
||||
it('should 404 for amp parameter', function (done) {
|
||||
// NOTE: only post pages are supported so the router doesn't have a way to distinguish if
|
||||
// the request was done after AMP 'Page' or 'Post'
|
||||
@ -228,6 +233,19 @@ describe('Frontend Routing', function () {
|
||||
.end(doEnd(done));
|
||||
});
|
||||
});
|
||||
describe('amp disabled', function (){
|
||||
beforeEach(function () {
|
||||
sinon.stub(settingsCache, 'get').withArgs('amp').returns(false);
|
||||
});
|
||||
it('should 301 for amp parameter', function (done) {
|
||||
// NOTE: only post pages are supported so the router doesn't have a way to distinguish if
|
||||
// the request was done after AMP 'Page' or 'Post'
|
||||
request.get('/static-page-test/amp/')
|
||||
.expect(301)
|
||||
.end(doEnd(done));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Post with Ghost in the url', function () {
|
||||
|
@ -37,7 +37,7 @@ describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
const currentSchemaHash = 'e649797a5de92d417744f6f2623c79cf';
|
||||
const currentFixturesHash = '07d4b0c4cf159b34344a6b5e88c74e9f';
|
||||
const currentSettingsHash = 'b06316ebbf62381158e1c46c97c0b77a';
|
||||
const currentSettingsHash = 'd73b63e33153c9256bca42ebfd376779';
|
||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||
|
||||
// If this test is failing, then it is likely a change has been made that requires a DB version bump,
|
||||
|
Loading…
Reference in New Issue
Block a user