2013-12-31 21:09:49 +04:00
|
|
|
// # Frontend Route tests
|
|
|
|
// As it stands, these tests depend on the database, and as such are integration tests.
|
|
|
|
// Mocking out the models to not touch the DB would turn these into unit tests, and should probably be done in future,
|
|
|
|
// But then again testing real code, rather than mock code, might be more useful...
|
|
|
|
|
2016-09-13 21:23:22 +03:00
|
|
|
var request = require('supertest'),
|
|
|
|
should = require('should'),
|
|
|
|
moment = require('moment'),
|
|
|
|
cheerio = require('cheerio'),
|
|
|
|
testUtils = require('../../utils'),
|
|
|
|
ghost = require('../../../../core');
|
2013-12-31 21:09:49 +04:00
|
|
|
|
|
|
|
describe('Frontend Routing', function () {
|
|
|
|
function doEnd(done) {
|
|
|
|
return function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
2013-12-31 03:13:25 +04:00
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
should.not.exist(res.headers['X-CSRF-Token']);
|
|
|
|
should.not.exist(res.headers['set-cookie']);
|
|
|
|
should.exist(res.headers.date);
|
|
|
|
|
2013-12-31 21:09:49 +04:00
|
|
|
done();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-04-16 22:40:32 +03:00
|
|
|
function addPosts(done) {
|
|
|
|
testUtils.initData().then(function () {
|
2016-06-10 08:12:46 +03:00
|
|
|
return testUtils.fixtures.insertPostsAndTags();
|
2015-04-16 22:40:32 +03:00
|
|
|
}).then(function () {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-12-31 21:09:49 +04:00
|
|
|
before(function (done) {
|
2014-09-19 20:17:58 +04:00
|
|
|
ghost().then(function (ghostServer) {
|
2014-03-25 16:42:52 +04:00
|
|
|
// Setup the request object with the ghost express app
|
2014-09-19 20:17:58 +04:00
|
|
|
request = request(ghostServer.rootApp);
|
2014-08-23 23:20:22 +04:00
|
|
|
|
|
|
|
done();
|
2014-05-06 00:58:58 +04:00
|
|
|
}).catch(function (e) {
|
2014-03-25 16:42:52 +04:00
|
|
|
console.log('Ghost Error: ', e);
|
|
|
|
console.log(e.stack);
|
2016-03-14 18:02:31 +03:00
|
|
|
done(e);
|
2014-03-25 16:42:52 +04:00
|
|
|
});
|
|
|
|
});
|
2013-12-31 21:09:49 +04:00
|
|
|
|
2016-09-13 21:23:22 +03:00
|
|
|
describe('Date permalinks', function () {
|
|
|
|
before(function (done) {
|
|
|
|
// Only way to swap permalinks setting is to login and visit the URL because
|
|
|
|
// poking the database doesn't work as settings are cached
|
|
|
|
testUtils.togglePermalinks(request, 'date')
|
|
|
|
.then(function () {
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function (done) {
|
|
|
|
testUtils.togglePermalinks(request)
|
|
|
|
.then(function () {
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
.catch(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should load a post with date permalink', function (done) {
|
|
|
|
var date = moment().format('YYYY/MM/DD');
|
|
|
|
|
|
|
|
request.get('/' + date + '/welcome-to-ghost/')
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /html/)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('expect redirect because of wrong/old permalink prefix', function (done) {
|
|
|
|
var date = moment().format('YYYY/MM/DD');
|
|
|
|
|
|
|
|
request.get('/2016/04/01/welcome-to-ghost/')
|
|
|
|
.expect('Content-Type', /html/)
|
|
|
|
.end(function (err, res) {
|
|
|
|
res.status.should.eql(301);
|
|
|
|
request.get('/' + date + '/welcome-to-ghost/')
|
|
|
|
.expect(200)
|
|
|
|
.expect('Content-Type', /html/)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should serve RSS with date permalink', function (done) {
|
|
|
|
request.get('/rss/')
|
|
|
|
.expect('Content-Type', 'text/xml; charset=utf-8')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.public)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
should.not.exist(res.headers['X-CSRF-Token']);
|
|
|
|
should.not.exist(res.headers['set-cookie']);
|
|
|
|
should.exist(res.headers.date);
|
|
|
|
|
|
|
|
var content = res.text,
|
|
|
|
todayMoment = moment(),
|
|
|
|
dd = todayMoment.format('DD'),
|
|
|
|
mm = todayMoment.format('MM'),
|
|
|
|
yyyy = todayMoment.format('YYYY'),
|
|
|
|
postLink = '/' + yyyy + '/' + mm + '/' + dd + '/welcome-to-ghost/';
|
|
|
|
|
|
|
|
content.indexOf(postLink).should.be.above(0);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2014-10-19 23:10:13 +04:00
|
|
|
|
|
|
|
describe('Test with Initial Fixtures', function () {
|
|
|
|
after(testUtils.teardown);
|
|
|
|
|
|
|
|
describe('Error', function () {
|
|
|
|
it('should 404 for unknown post', function (done) {
|
|
|
|
request.get('/spectacular/')
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect(404)
|
2015-06-08 13:13:42 +03:00
|
|
|
.expect(/Page not found/)
|
2014-10-19 23:10:13 +04:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2015-09-22 19:38:30 +03:00
|
|
|
it('should 404 for unknown post with invalid characters', function (done) {
|
|
|
|
request.get('/$pec+acular~/')
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
2015-09-22 19:38:30 +03:00
|
|
|
.expect(404)
|
|
|
|
.expect(/Page not found/)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2014-10-19 23:10:13 +04:00
|
|
|
it('should 404 for unknown frontend route', function (done) {
|
|
|
|
request.get('/spectacular/marvellous/')
|
2016-10-04 18:33:43 +03:00
|
|
|
.set('Accept', 'application/json')
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect(404)
|
2015-06-08 13:13:42 +03:00
|
|
|
.expect(/Page not found/)
|
2014-10-19 23:10:13 +04:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2015-09-24 16:40:48 +03:00
|
|
|
it('should 404 for encoded char not 301 from uncapitalise', function (done) {
|
|
|
|
request.get('/|/')
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
2015-09-24 16:40:48 +03:00
|
|
|
.expect(404)
|
|
|
|
.expect(/Page not found/)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
2015-09-27 22:14:09 +03:00
|
|
|
|
|
|
|
it('should 404 for unknown file', function (done) {
|
|
|
|
request.get('/content/images/some/file/that/doesnt-exist.jpg')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules['private'])
|
|
|
|
.expect(404)
|
|
|
|
.expect(/Page not found/)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
2014-10-19 23:10:13 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('Single post', function () {
|
|
|
|
it('should redirect without slash', function (done) {
|
|
|
|
request.get('/welcome-to-ghost')
|
|
|
|
.expect('Location', '/welcome-to-ghost/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
.expect(301)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should redirect uppercase', function (done) {
|
|
|
|
request.get('/Welcome-To-Ghost/')
|
|
|
|
.expect('Location', '/welcome-to-ghost/')
|
2015-09-24 16:40:48 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect(301)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2016-08-23 14:47:59 +03:00
|
|
|
it('should sanitize double slashes when redirecting uppercase', function (done) {
|
|
|
|
request.get('///Google.com/')
|
|
|
|
.expect('Location', '/google.com/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
.expect(301)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2014-10-19 23:10:13 +04:00
|
|
|
it('should respond with html for valid url', function (done) {
|
|
|
|
request.get('/welcome-to-ghost/')
|
|
|
|
.expect('Content-Type', /html/)
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.public)
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
var $ = cheerio.load(res.text);
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
should.not.exist(res.headers['X-CSRF-Token']);
|
|
|
|
should.not.exist(res.headers['set-cookie']);
|
|
|
|
should.exist(res.headers.date);
|
|
|
|
|
|
|
|
$('title').text().should.equal('Welcome to Ghost');
|
|
|
|
$('.content .post').length.should.equal(1);
|
|
|
|
$('.poweredby').text().should.equal('Proudly published with Ghost');
|
|
|
|
$('body.post-template').length.should.equal(1);
|
|
|
|
$('body.tag-getting-started').length.should.equal(1);
|
|
|
|
$('article.post').length.should.equal(1);
|
|
|
|
$('article.tag-getting-started').length.should.equal(1);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not work with date permalinks', function (done) {
|
|
|
|
// get today's date
|
2016-09-13 21:23:22 +03:00
|
|
|
var date = moment().format('YYYY/MM/DD');
|
2014-10-19 23:10:13 +04:00
|
|
|
|
|
|
|
request.get('/' + date + '/welcome-to-ghost/')
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect(404)
|
2015-06-08 13:13:42 +03:00
|
|
|
.expect(/Page not found/)
|
2014-10-19 23:10:13 +04:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Post edit', function () {
|
|
|
|
it('should redirect without slash', function (done) {
|
|
|
|
request.get('/welcome-to-ghost/edit')
|
|
|
|
.expect('Location', '/welcome-to-ghost/edit/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
.expect(301)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should redirect to editor', function (done) {
|
|
|
|
request.get('/welcome-to-ghost/edit/')
|
|
|
|
.expect('Location', '/ghost/editor/1/')
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.public)
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect(302)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should 404 for non-edit parameter', function (done) {
|
|
|
|
request.get('/welcome-to-ghost/notedit/')
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect(404)
|
2015-06-08 13:13:42 +03:00
|
|
|
.expect(/Page not found/)
|
2014-10-19 23:10:13 +04:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
✨ [FEATURE] AMP⚡ (#7229)
closes #6588, #7095
* `ImageObject` with image dimensions (#7152, #7151, #7153)
- Returns meta data as promise
- returns a new Promise from meta data
- uses `Promise.props()` to resolve `getClient()` and `getMetaData()`
- Adds 'image-size' util
The util returns an object like this
```
{
height: 50,
url: 'http://myblog.com/images/cat.jpg',
width: 50
};
```
if the dimensions can be fetched and rejects with error, if not.
In case we get a locally stored image or a not complete url (like `//www.gravatar.com/andsoon`), we add the protocol to the incomplete one and use `urlFor()` to get the absolute URL. If the request fails or `image-size` is not able to read the file, we reject with error.
- adds 'image-size' module to dependencies
- adds `getImageSizeFromUrl` function that returns image dimensions
- In preparation of AMP support and to improve our schema.org JSON-LD and structured data, I made the following changes:
- Changes the following properties to be `Objects`, which have a `url` property by default and a `dimensions` property, if `width` and `height` are available:
- `metaData.coverImage`
- `metaData.authorImage`
- `metaData.blog.logo`
- Checks cache by calling `getCachedImageSizeFromUrl`. If image dimensions were fetched already, returns them from cache instead of fetching them again.
- If we have image dimensions on hand, the output in our JSON-LD changes from normal urls to be full `ImageObjects`. Applies to all images and logos.
- Special case for `publisher.logo` as it has size restrictions: if the image doesn't fulfil the restrictions (<=600 width and <=60 height), we simply output the url instead, so like before.
- Adds new property for schema.org JSON-LD: `mainEntityOfPage` as an Object.
- Adds additional Open Graph data (if we have the image size): `og:image:width` and `og:image:height`
- Adds/updates tests
* AMP router and controller (#7171, #7157)
Implements AMP in `/apps/`:
- renders `amp.hbs` if route is `/:slug/amp/`
- updates `setResponseContext` to set context to `['amp', 'post']` for a amp post and `['amp', 'page']` for a page, but will not render amp template for a page
- updates `context_spec`
- registers 'amp' as new internal app
- adds the `amp.hbs` template to `core/server/apps/amp` which will be the default template for AMP posts.
- adds `isAmpURL` to `post-lookup`
* 🎨 Use `context` in meta as array (#7205)
Instead of reading the first value of the context array, we're checking if it includes certain context values.
This is a preparation change for AMP, where the context will be delivered as `['amp', 'post']`.
* ✨ AMP helpers (#7174, #7216, #7215, #7223)
- Adds AMP helpers `{{amp_content}}`, `{{amp_component}}` and `{{amp_ghost_head}}` to support AMP:
- `{{amp_content}}`:
- Adds `Amperize` as dependency
- AMP app uses new helper `{{amp_content}}` to render AMP HTML
- `Amperize` transforms regular HTML into AMP HTML
- Adds test for `{{amp_content}}` helper
- Adds 'Sanitize-HTML` as dependendy
- After the HTML get 'amperized' we still might have some HTML tags, which are prohibited in AMP HTML, so we use `sanitize-html` to remove those. With every update, `Amperize` gets and it is able to transform more HTML tags, they valid AMP HTML tags (e. g. `video` and `amp-video`) and will therefore not be removed.
- `{{amp_ghost_head}}`:
- registers `{{amp_ghost_head}}` helper, but uses `{{ghost_head}}` code
- uses `{{amp_ghost_head}}` in `amp.hbs` instead of `{{ghost_head}}`
- `{{ghost_head}}`:
- Render `amphtml` link in metadata for post, which links to the amp post (`getAmpUrl`)
- Updates all test in metadata to support `amp` context
- Changes context conditionals to work with full array instead of first array value
- Adds conditionals, so no additional javascript gets rendered in `{{ghost_head}}`
- Removes trailing `/amp/` in URLs, so only `amphtml` link on regular post renders it
- Adds a conditional, so no code injection will be included, for an `amp` context.
- `{{amp_components}}`:
- AMP app uses new helper `{{amp_components}}` to render necessary script tags for AMP extended components as `amp-iframe`, `amp-anime` and `amp-form`
- Adds test for `{{amp_components}}`
2016-08-22 19:49:27 +03:00
|
|
|
describe('AMP post', function () {
|
|
|
|
it('should redirect without slash', function (done) {
|
|
|
|
request.get('/welcome-to-ghost/amp')
|
|
|
|
.expect('Location', '/welcome-to-ghost/amp/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
.expect(301)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should redirect uppercase', function (done) {
|
|
|
|
request.get('/Welcome-To-Ghost/AMP/')
|
|
|
|
.expect('Location', '/welcome-to-ghost/amp/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
.expect(301)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should respond with html for valid url', function (done) {
|
|
|
|
request.get('/welcome-to-ghost/amp/')
|
|
|
|
.expect('Content-Type', /html/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.public)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
var $ = cheerio.load(res.text);
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
should.not.exist(res.headers['X-CSRF-Token']);
|
|
|
|
should.not.exist(res.headers['set-cookie']);
|
|
|
|
should.exist(res.headers.date);
|
|
|
|
|
|
|
|
$('title').text().should.equal('Welcome to Ghost');
|
|
|
|
$('.content .post').length.should.equal(1);
|
|
|
|
$('.poweredby').text().should.equal('Proudly published with Ghost');
|
|
|
|
$('body.amp-template').length.should.equal(1);
|
|
|
|
$('article.post').length.should.equal(1);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not work with date permalinks', function (done) {
|
|
|
|
// get today's date
|
2016-09-13 21:23:22 +03:00
|
|
|
var date = moment().format('YYYY/MM/DD');
|
✨ [FEATURE] AMP⚡ (#7229)
closes #6588, #7095
* `ImageObject` with image dimensions (#7152, #7151, #7153)
- Returns meta data as promise
- returns a new Promise from meta data
- uses `Promise.props()` to resolve `getClient()` and `getMetaData()`
- Adds 'image-size' util
The util returns an object like this
```
{
height: 50,
url: 'http://myblog.com/images/cat.jpg',
width: 50
};
```
if the dimensions can be fetched and rejects with error, if not.
In case we get a locally stored image or a not complete url (like `//www.gravatar.com/andsoon`), we add the protocol to the incomplete one and use `urlFor()` to get the absolute URL. If the request fails or `image-size` is not able to read the file, we reject with error.
- adds 'image-size' module to dependencies
- adds `getImageSizeFromUrl` function that returns image dimensions
- In preparation of AMP support and to improve our schema.org JSON-LD and structured data, I made the following changes:
- Changes the following properties to be `Objects`, which have a `url` property by default and a `dimensions` property, if `width` and `height` are available:
- `metaData.coverImage`
- `metaData.authorImage`
- `metaData.blog.logo`
- Checks cache by calling `getCachedImageSizeFromUrl`. If image dimensions were fetched already, returns them from cache instead of fetching them again.
- If we have image dimensions on hand, the output in our JSON-LD changes from normal urls to be full `ImageObjects`. Applies to all images and logos.
- Special case for `publisher.logo` as it has size restrictions: if the image doesn't fulfil the restrictions (<=600 width and <=60 height), we simply output the url instead, so like before.
- Adds new property for schema.org JSON-LD: `mainEntityOfPage` as an Object.
- Adds additional Open Graph data (if we have the image size): `og:image:width` and `og:image:height`
- Adds/updates tests
* AMP router and controller (#7171, #7157)
Implements AMP in `/apps/`:
- renders `amp.hbs` if route is `/:slug/amp/`
- updates `setResponseContext` to set context to `['amp', 'post']` for a amp post and `['amp', 'page']` for a page, but will not render amp template for a page
- updates `context_spec`
- registers 'amp' as new internal app
- adds the `amp.hbs` template to `core/server/apps/amp` which will be the default template for AMP posts.
- adds `isAmpURL` to `post-lookup`
* 🎨 Use `context` in meta as array (#7205)
Instead of reading the first value of the context array, we're checking if it includes certain context values.
This is a preparation change for AMP, where the context will be delivered as `['amp', 'post']`.
* ✨ AMP helpers (#7174, #7216, #7215, #7223)
- Adds AMP helpers `{{amp_content}}`, `{{amp_component}}` and `{{amp_ghost_head}}` to support AMP:
- `{{amp_content}}`:
- Adds `Amperize` as dependency
- AMP app uses new helper `{{amp_content}}` to render AMP HTML
- `Amperize` transforms regular HTML into AMP HTML
- Adds test for `{{amp_content}}` helper
- Adds 'Sanitize-HTML` as dependendy
- After the HTML get 'amperized' we still might have some HTML tags, which are prohibited in AMP HTML, so we use `sanitize-html` to remove those. With every update, `Amperize` gets and it is able to transform more HTML tags, they valid AMP HTML tags (e. g. `video` and `amp-video`) and will therefore not be removed.
- `{{amp_ghost_head}}`:
- registers `{{amp_ghost_head}}` helper, but uses `{{ghost_head}}` code
- uses `{{amp_ghost_head}}` in `amp.hbs` instead of `{{ghost_head}}`
- `{{ghost_head}}`:
- Render `amphtml` link in metadata for post, which links to the amp post (`getAmpUrl`)
- Updates all test in metadata to support `amp` context
- Changes context conditionals to work with full array instead of first array value
- Adds conditionals, so no additional javascript gets rendered in `{{ghost_head}}`
- Removes trailing `/amp/` in URLs, so only `amphtml` link on regular post renders it
- Adds a conditional, so no code injection will be included, for an `amp` context.
- `{{amp_components}}`:
- AMP app uses new helper `{{amp_components}}` to render necessary script tags for AMP extended components as `amp-iframe`, `amp-anime` and `amp-form`
- Adds test for `{{amp_components}}`
2016-08-22 19:49:27 +03:00
|
|
|
|
|
|
|
request.get('/' + date + '/welcome-to-ghost/amp/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(404)
|
|
|
|
.expect(/Page not found/)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-19 23:10:13 +04:00
|
|
|
describe('Static assets', function () {
|
|
|
|
it('should retrieve theme assets', function (done) {
|
|
|
|
request.get('/assets/css/screen.css')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should retrieve built assets', function (done) {
|
2016-10-08 01:05:36 +03:00
|
|
|
request.get('/ghost/assets/vendor.js')
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should retrieve default robots.txt', function (done) {
|
|
|
|
request.get('/robots.txt')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.hour)
|
|
|
|
.expect('ETag', /[0-9a-f]{32}/i)
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should retrieve default favicon.ico', function (done) {
|
|
|
|
request.get('/favicon.ico')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.day)
|
|
|
|
.expect('ETag', /[0-9a-f]{32}/i)
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
// at the moment there is no image fixture to test
|
|
|
|
// it('should retrieve image assets', function (done) {
|
|
|
|
// request.get('/content/images/some.jpg')
|
|
|
|
// .expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
// .end(doEnd(done));
|
|
|
|
// });
|
|
|
|
});
|
2013-12-31 21:09:49 +04:00
|
|
|
});
|
|
|
|
|
2014-10-19 23:10:13 +04:00
|
|
|
describe('Static page', function () {
|
2015-04-16 22:40:32 +03:00
|
|
|
before(addPosts);
|
2014-10-19 23:10:13 +04:00
|
|
|
after(testUtils.teardown);
|
2013-12-31 21:09:49 +04:00
|
|
|
|
|
|
|
it('should redirect without slash', function (done) {
|
2014-10-19 23:10:13 +04:00
|
|
|
request.get('/static-page-test')
|
|
|
|
.expect('Location', '/static-page-test/')
|
2014-09-25 13:35:28 +04:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
2013-12-31 21:09:49 +04:00
|
|
|
.expect(301)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2014-10-19 23:10:13 +04:00
|
|
|
it('should respond with xml', function (done) {
|
|
|
|
request.get('/static-page-test/')
|
2013-12-31 21:09:49 +04:00
|
|
|
.expect('Content-Type', /html/)
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.public)
|
2013-12-31 21:09:49 +04:00
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
2016-08-08 10:42:04 +03:00
|
|
|
|
|
|
|
describe('edit', function () {
|
|
|
|
it('should redirect without slash', function (done) {
|
|
|
|
request.get('/static-page-test/edit')
|
|
|
|
.expect('Location', '/static-page-test/edit/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
.expect(301)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should redirect to editor', function (done) {
|
|
|
|
request.get('/static-page-test/edit/')
|
|
|
|
.expect('Location', /^\/ghost\/editor\/[0-9]\/$/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.public)
|
|
|
|
.expect(302)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should 404 for non-edit parameter', function (done) {
|
|
|
|
request.get('/static-page-test/notedit/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(404)
|
|
|
|
.expect(/Page not found/)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
});
|
✨ [FEATURE] AMP⚡ (#7229)
closes #6588, #7095
* `ImageObject` with image dimensions (#7152, #7151, #7153)
- Returns meta data as promise
- returns a new Promise from meta data
- uses `Promise.props()` to resolve `getClient()` and `getMetaData()`
- Adds 'image-size' util
The util returns an object like this
```
{
height: 50,
url: 'http://myblog.com/images/cat.jpg',
width: 50
};
```
if the dimensions can be fetched and rejects with error, if not.
In case we get a locally stored image or a not complete url (like `//www.gravatar.com/andsoon`), we add the protocol to the incomplete one and use `urlFor()` to get the absolute URL. If the request fails or `image-size` is not able to read the file, we reject with error.
- adds 'image-size' module to dependencies
- adds `getImageSizeFromUrl` function that returns image dimensions
- In preparation of AMP support and to improve our schema.org JSON-LD and structured data, I made the following changes:
- Changes the following properties to be `Objects`, which have a `url` property by default and a `dimensions` property, if `width` and `height` are available:
- `metaData.coverImage`
- `metaData.authorImage`
- `metaData.blog.logo`
- Checks cache by calling `getCachedImageSizeFromUrl`. If image dimensions were fetched already, returns them from cache instead of fetching them again.
- If we have image dimensions on hand, the output in our JSON-LD changes from normal urls to be full `ImageObjects`. Applies to all images and logos.
- Special case for `publisher.logo` as it has size restrictions: if the image doesn't fulfil the restrictions (<=600 width and <=60 height), we simply output the url instead, so like before.
- Adds new property for schema.org JSON-LD: `mainEntityOfPage` as an Object.
- Adds additional Open Graph data (if we have the image size): `og:image:width` and `og:image:height`
- Adds/updates tests
* AMP router and controller (#7171, #7157)
Implements AMP in `/apps/`:
- renders `amp.hbs` if route is `/:slug/amp/`
- updates `setResponseContext` to set context to `['amp', 'post']` for a amp post and `['amp', 'page']` for a page, but will not render amp template for a page
- updates `context_spec`
- registers 'amp' as new internal app
- adds the `amp.hbs` template to `core/server/apps/amp` which will be the default template for AMP posts.
- adds `isAmpURL` to `post-lookup`
* 🎨 Use `context` in meta as array (#7205)
Instead of reading the first value of the context array, we're checking if it includes certain context values.
This is a preparation change for AMP, where the context will be delivered as `['amp', 'post']`.
* ✨ AMP helpers (#7174, #7216, #7215, #7223)
- Adds AMP helpers `{{amp_content}}`, `{{amp_component}}` and `{{amp_ghost_head}}` to support AMP:
- `{{amp_content}}`:
- Adds `Amperize` as dependency
- AMP app uses new helper `{{amp_content}}` to render AMP HTML
- `Amperize` transforms regular HTML into AMP HTML
- Adds test for `{{amp_content}}` helper
- Adds 'Sanitize-HTML` as dependendy
- After the HTML get 'amperized' we still might have some HTML tags, which are prohibited in AMP HTML, so we use `sanitize-html` to remove those. With every update, `Amperize` gets and it is able to transform more HTML tags, they valid AMP HTML tags (e. g. `video` and `amp-video`) and will therefore not be removed.
- `{{amp_ghost_head}}`:
- registers `{{amp_ghost_head}}` helper, but uses `{{ghost_head}}` code
- uses `{{amp_ghost_head}}` in `amp.hbs` instead of `{{ghost_head}}`
- `{{ghost_head}}`:
- Render `amphtml` link in metadata for post, which links to the amp post (`getAmpUrl`)
- Updates all test in metadata to support `amp` context
- Changes context conditionals to work with full array instead of first array value
- Adds conditionals, so no additional javascript gets rendered in `{{ghost_head}}`
- Removes trailing `/amp/` in URLs, so only `amphtml` link on regular post renders it
- Adds a conditional, so no code injection will be included, for an `amp` context.
- `{{amp_components}}`:
- AMP app uses new helper `{{amp_components}}` to render necessary script tags for AMP extended components as `amp-iframe`, `amp-anime` and `amp-form`
- Adds test for `{{amp_components}}`
2016-08-22 19:49:27 +03:00
|
|
|
|
|
|
|
describe('amp', function () {
|
|
|
|
it('should 404 for amp parameter', function (done) {
|
|
|
|
request.get('/static-page-test/amp/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(404)
|
|
|
|
.expect(/Page not found/)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
});
|
2013-12-31 21:09:49 +04:00
|
|
|
});
|
2014-07-01 03:26:08 +04:00
|
|
|
|
2015-04-16 22:40:32 +03:00
|
|
|
describe('Post preview', function () {
|
|
|
|
before(addPosts);
|
|
|
|
after(testUtils.teardown);
|
|
|
|
|
|
|
|
it('should display draft posts accessed via uuid', function (done) {
|
|
|
|
request.get('/p/d52c42ae-2755-455c-80ec-70b2ec55c903/')
|
|
|
|
.expect('Content-Type', /html/)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
var $ = cheerio.load(res.text);
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
should.not.exist(res.headers['X-CSRF-Token']);
|
|
|
|
should.not.exist(res.headers['set-cookie']);
|
|
|
|
should.exist(res.headers.date);
|
|
|
|
|
|
|
|
$('title').text().should.equal('Not finished yet');
|
|
|
|
$('.content .post').length.should.equal(1);
|
|
|
|
$('.poweredby').text().should.equal('Proudly published with Ghost');
|
|
|
|
$('body.post-template').length.should.equal(1);
|
|
|
|
$('article.post').length.should.equal(1);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should redirect published posts to their live url', function (done) {
|
|
|
|
request.get('/p/2ac6b4f6-e1f3-406c-9247-c94a0496d39d/')
|
|
|
|
.expect(301)
|
|
|
|
.expect('Location', '/short-and-sweet/')
|
2015-09-24 16:40:48 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.public)
|
2015-04-16 22:40:32 +03:00
|
|
|
.end(doEnd(done));
|
2014-02-22 05:25:31 +04:00
|
|
|
});
|
2013-12-31 21:09:49 +04:00
|
|
|
|
2015-04-16 22:40:32 +03:00
|
|
|
it('404s unknown uuids', function (done) {
|
|
|
|
request.get('/p/aac6b4f6-e1f3-406c-9247-c94a0496d39f/')
|
|
|
|
.expect(404)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Post with Ghost in the url', function () {
|
|
|
|
before(addPosts);
|
2014-10-19 23:10:13 +04:00
|
|
|
after(testUtils.teardown);
|
2013-12-31 21:09:49 +04:00
|
|
|
|
2014-10-19 23:10:13 +04:00
|
|
|
// All of Ghost's admin depends on the /ghost/ in the url to work properly
|
|
|
|
// Badly formed regexs can cause breakage if a post slug starts with the 5 letters ghost
|
|
|
|
it('should retrieve a blog post with ghost at the start of the url', function (done) {
|
|
|
|
request.get('/ghostly-kitchen-sink/')
|
2015-10-12 19:54:15 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.public)
|
2013-12-31 21:09:49 +04:00
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-11-23 20:49:47 +03:00
|
|
|
describe('Subdirectory (no slash)', function () {
|
|
|
|
var forkedGhost, request;
|
|
|
|
|
2016-09-13 21:23:22 +03:00
|
|
|
before(function (done) {
|
|
|
|
testUtils.fork.ghost({
|
|
|
|
url: 'http://localhost/blog'
|
|
|
|
}, 'testsubdir')
|
2014-11-23 20:49:47 +03:00
|
|
|
.then(function (child) {
|
|
|
|
forkedGhost = child;
|
|
|
|
request = require('supertest');
|
|
|
|
request = request('http://localhost:' + child.port);
|
|
|
|
}).then(done).catch(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function (done) {
|
|
|
|
if (forkedGhost) {
|
|
|
|
forkedGhost.kill(done);
|
|
|
|
} else {
|
|
|
|
done(new Error('No forked ghost process exists, test setup must have failed.'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it('http://localhost should 404', function (done) {
|
|
|
|
request.get('/')
|
|
|
|
.expect(404)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('http://localhost/ should 404', function (done) {
|
|
|
|
request.get('/')
|
|
|
|
.expect(404)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2016-07-19 23:03:24 +03:00
|
|
|
it('http://localhost/blog should 301 to http://localhost/blog/', function (done) {
|
2014-11-23 20:49:47 +03:00
|
|
|
request.get('/blog')
|
2016-07-19 23:03:24 +03:00
|
|
|
.expect(301)
|
2014-11-23 20:49:47 +03:00
|
|
|
.expect('Location', '/blog/')
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('http://localhost/blog/ should 200', function (done) {
|
|
|
|
request.get('/blog/')
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('http://localhost/blog/welcome-to-ghost should 301 to http://localhost/blog/welcome-to-ghost/', function (done) {
|
|
|
|
request.get('/blog/welcome-to-ghost')
|
|
|
|
.expect(301)
|
|
|
|
.expect('Location', '/blog/welcome-to-ghost/')
|
2015-09-24 16:40:48 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
2014-11-23 20:49:47 +03:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('http://localhost/blog/welcome-to-ghost/ should 200', function (done) {
|
|
|
|
request.get('/blog/welcome-to-ghost/')
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('/blog/tag/getting-started should 301 to /blog/tag/getting-started/', function (done) {
|
|
|
|
request.get('/blog/tag/getting-started')
|
|
|
|
.expect(301)
|
|
|
|
.expect('Location', '/blog/tag/getting-started/')
|
2015-09-24 16:40:48 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
2014-11-23 20:49:47 +03:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('/blog/tag/getting-started/ should 200', function (done) {
|
|
|
|
request.get('/blog/tag/getting-started/')
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Subdirectory (with slash)', function () {
|
|
|
|
var forkedGhost, request;
|
2016-07-15 19:22:41 +03:00
|
|
|
|
2014-11-23 20:49:47 +03:00
|
|
|
before(function (done) {
|
2016-09-13 21:23:22 +03:00
|
|
|
testUtils.fork.ghost({
|
|
|
|
url: 'http://localhost/blog/'
|
|
|
|
}, 'testsubdir')
|
2014-11-23 20:49:47 +03:00
|
|
|
.then(function (child) {
|
|
|
|
forkedGhost = child;
|
|
|
|
request = require('supertest');
|
|
|
|
request = request('http://localhost:' + child.port);
|
|
|
|
}).then(done).catch(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function (done) {
|
|
|
|
if (forkedGhost) {
|
|
|
|
forkedGhost.kill(done);
|
|
|
|
} else {
|
|
|
|
done(new Error('No forked ghost process exists, test setup must have failed.'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it('http://localhost should 404', function (done) {
|
|
|
|
request.get('/')
|
|
|
|
.expect(404)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('http://localhost/ should 404', function (done) {
|
|
|
|
request.get('/')
|
|
|
|
.expect(404)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2016-07-19 23:03:24 +03:00
|
|
|
it('/blog should 301 to /blog/', function (done) {
|
2014-11-23 20:49:47 +03:00
|
|
|
request.get('/blog')
|
2016-07-19 23:03:24 +03:00
|
|
|
.expect(301)
|
2014-11-23 20:49:47 +03:00
|
|
|
.expect('Location', '/blog/')
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('/blog/ should 200', function (done) {
|
|
|
|
request.get('/blog/')
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('/blog/welcome-to-ghost should 301 to /blog/welcome-to-ghost/', function (done) {
|
|
|
|
request.get('/blog/welcome-to-ghost')
|
|
|
|
.expect(301)
|
|
|
|
.expect('Location', '/blog/welcome-to-ghost/')
|
2015-09-24 16:40:48 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
2014-11-23 20:49:47 +03:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('/blog/welcome-to-ghost/ should 200', function (done) {
|
|
|
|
request.get('/blog/welcome-to-ghost/')
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('/blog/tag/getting-started should 301 to /blog/tag/getting-started/', function (done) {
|
|
|
|
request.get('/blog/tag/getting-started')
|
|
|
|
.expect(301)
|
|
|
|
.expect('Location', '/blog/tag/getting-started/')
|
2015-09-24 16:40:48 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
2014-11-23 20:49:47 +03:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('/blog/tag/getting-started/ should 200', function (done) {
|
|
|
|
request.get('/blog/tag/getting-started/')
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
2015-09-24 16:40:48 +03:00
|
|
|
|
2016-09-14 14:47:25 +03:00
|
|
|
it('/blog/welcome-to-ghost/amp/ should 200', function (done) {
|
|
|
|
request.get('/blog/welcome-to-ghost/amp/')
|
|
|
|
.expect(200)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2015-09-24 16:40:48 +03:00
|
|
|
it('should uncapitalise correctly with 301 to subdir', function (done) {
|
|
|
|
request.get('/blog/AAA/')
|
|
|
|
.expect('Location', '/blog/aaa/')
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.year)
|
|
|
|
.expect(301)
|
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
2014-11-23 20:49:47 +03:00
|
|
|
});
|
|
|
|
|
2014-10-19 23:10:13 +04:00
|
|
|
// we'll use X-Forwarded-Proto: https to simulate an 'https://' request behind a proxy
|
|
|
|
describe('HTTPS', function () {
|
|
|
|
var forkedGhost, request;
|
2016-07-15 19:22:41 +03:00
|
|
|
|
2014-07-31 05:41:25 +04:00
|
|
|
before(function (done) {
|
2016-09-13 21:23:22 +03:00
|
|
|
testUtils.fork.ghost({
|
|
|
|
forceAdminSSL: {redirect: false},
|
|
|
|
urlSSL: 'https://localhost/',
|
|
|
|
server: {
|
|
|
|
port: 2370
|
|
|
|
}
|
|
|
|
}, 'testhttps')
|
2014-10-19 23:10:13 +04:00
|
|
|
.then(function (child) {
|
|
|
|
forkedGhost = child;
|
|
|
|
request = require('supertest');
|
2016-09-13 21:23:22 +03:00
|
|
|
request = request('http://127.0.0.1:2370');
|
2014-10-19 23:10:13 +04:00
|
|
|
}).then(done).catch(done);
|
2014-07-31 05:41:25 +04:00
|
|
|
});
|
|
|
|
|
2014-10-19 23:10:13 +04:00
|
|
|
after(function (done) {
|
|
|
|
if (forkedGhost) {
|
|
|
|
forkedGhost.kill(done);
|
2014-10-31 00:43:47 +03:00
|
|
|
} else {
|
|
|
|
done(new Error('No forked ghost process exists, test setup must have failed.'));
|
2014-10-19 23:10:13 +04:00
|
|
|
}
|
2014-07-31 05:41:25 +04:00
|
|
|
});
|
|
|
|
|
2014-10-19 23:10:13 +04:00
|
|
|
it('should set links to url over non-HTTPS', function (done) {
|
|
|
|
request.get('/')
|
2014-07-31 05:41:25 +04:00
|
|
|
.expect(200)
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect(/<link rel="canonical" href="http:\/\/127.0.0.1:2370\/" \/\>/)
|
|
|
|
.expect(/<a href="http:\/\/127.0.0.1:2370">Ghost<\/a\>/)
|
2014-07-31 05:41:25 +04:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
|
|
|
|
2016-01-05 21:04:39 +03:00
|
|
|
it('should set links to urlSSL over HTTPS besides canonical', function (done) {
|
2014-10-19 23:10:13 +04:00
|
|
|
request.get('/')
|
|
|
|
.set('X-Forwarded-Proto', 'https')
|
|
|
|
.expect(200)
|
2016-01-05 21:04:39 +03:00
|
|
|
.expect(/<link rel="canonical" href="http:\/\/127.0.0.1:2370\/" \/\>/)
|
2014-10-19 23:10:13 +04:00
|
|
|
.expect(/<a href="https:\/\/localhost">Ghost<\/a\>/)
|
2014-07-31 05:41:25 +04:00
|
|
|
.end(doEnd(done));
|
|
|
|
});
|
2014-10-19 23:10:13 +04:00
|
|
|
});
|
2014-07-31 05:41:25 +04:00
|
|
|
|
2014-10-28 03:41:18 +03:00
|
|
|
describe('Site Map', function () {
|
2016-07-15 19:22:41 +03:00
|
|
|
before(testUtils.teardown);
|
|
|
|
|
2014-10-28 03:41:18 +03:00
|
|
|
before(function (done) {
|
|
|
|
testUtils.initData().then(function () {
|
2016-06-10 08:12:46 +03:00
|
|
|
return testUtils.fixtures.insertPostsAndTags();
|
2014-10-28 03:41:18 +03:00
|
|
|
}).then(function () {
|
|
|
|
done();
|
|
|
|
}).catch(done);
|
|
|
|
});
|
|
|
|
|
2014-12-07 14:42:26 +03:00
|
|
|
it('should serve sitemap.xml', function (done) {
|
2014-10-28 03:41:18 +03:00
|
|
|
request.get('/sitemap.xml')
|
|
|
|
.expect(200)
|
2016-01-25 20:56:05 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.hour)
|
2014-10-28 03:41:18 +03:00
|
|
|
.expect('Content-Type', 'text/xml; charset=utf-8')
|
2016-09-14 11:44:08 +03:00
|
|
|
.end(function (err, res) {
|
|
|
|
res.text.should.match(/sitemapindex/);
|
|
|
|
doEnd(done)(err, res);
|
|
|
|
});
|
2014-10-28 03:41:18 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should serve sitemap-posts.xml', function (done) {
|
|
|
|
request.get('/sitemap-posts.xml')
|
|
|
|
.expect(200)
|
2016-01-25 20:56:05 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.hour)
|
2014-10-28 03:41:18 +03:00
|
|
|
.expect('Content-Type', 'text/xml; charset=utf-8')
|
2016-09-14 11:44:08 +03:00
|
|
|
.end(function (err, res) {
|
|
|
|
res.text.should.match(/urlset/);
|
|
|
|
doEnd(done)(err, res);
|
|
|
|
});
|
2014-10-28 03:41:18 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should serve sitemap-pages.xml', function (done) {
|
|
|
|
request.get('/sitemap-posts.xml')
|
|
|
|
.expect(200)
|
2016-01-25 20:56:05 +03:00
|
|
|
.expect('Cache-Control', testUtils.cacheRules.hour)
|
2014-10-28 03:41:18 +03:00
|
|
|
.expect('Content-Type', 'text/xml; charset=utf-8')
|
2016-09-14 11:44:08 +03:00
|
|
|
.end(function (err, res) {
|
|
|
|
res.text.should.match(/urlset/);
|
|
|
|
doEnd(done)(err, res);
|
|
|
|
});
|
2014-10-28 03:41:18 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: Other pages and verify content
|
|
|
|
});
|
2013-12-31 21:09:49 +04:00
|
|
|
});
|