mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 16:42:17 +03:00
af6137248d
fixes #1765 fixes #1811 issue #1833 New UrlFor functions - moved body of url helper to config.path.urlFor, which can generate a URL for various scenarios - urlFor can take a string (name) or object (relativeUrl: '/') as the first argument - this is the first step towards issue #1833 - also added config.path.urlForPost which is async and handles getting permalink setting - frontend controller, ghost_head helper, cache invalidation all now use urlFor or urlForPost all urls should be correct and consistent URL Consistency Improvements - refactored invalidateCache into cacheInvalidationHeader which returns a promise so that url can be generated properly by urlForPost - moved isPost from models to schema, and refactored schema to have a tables object - deleted posts now return the whole object, not just id and slug, ensuring cache invalidation header can be set on delete - frontend controller rss and archive page redirects work properly with subdirectory - removes {{url}} helper from admin and client, and replaced with adminUrl helper which also uses urlFor - in res.locals ghostRoot becomes relativeUrl, and path is removed
79 lines
3.1 KiB
JavaScript
79 lines
3.1 KiB
JavaScript
/**
|
|
* Tests the homepage
|
|
*/
|
|
|
|
/*globals CasperTest, casper, __utils__, url, testPost, falseUser, email */
|
|
CasperTest.begin('Home page loads', 3, function suite(test) {
|
|
casper.start(url, function then(response) {
|
|
test.assertTitle('Ghost', 'The homepage should have a title and it should be Ghost');
|
|
test.assertExists('.content .post', 'There is at least one post on this page');
|
|
test.assertSelectorHasText('.poweredby', 'Proudly published with Ghost');
|
|
});
|
|
}, true);
|
|
|
|
CasperTest.begin('Test helpers on homepage', 3, function suite(test) {
|
|
casper.start(url, function then(response) {
|
|
// body class
|
|
test.assertExists('body.home-template', 'body_class outputs correct home-template class');
|
|
// post class
|
|
test.assertExists('article.post', 'post_class outputs correct post class');
|
|
test.assertExists('article.tag-getting-started', 'post_class outputs correct tag class');
|
|
});
|
|
}, true);
|
|
|
|
CasperTest.begin('Test navigating to Post', 4, function suite(test) {
|
|
casper.thenOpen(url, function then(response) {
|
|
var lastPost = '.content article:last-of-type',
|
|
lastPostLink = lastPost + ' .post-title a';
|
|
|
|
test.assertExists(lastPost, 'there is a last child on the page');
|
|
test.assertSelectorHasText(lastPostLink, 'Welcome to Ghost', 'Is correct post');
|
|
|
|
casper.then(function testLink() {
|
|
var link = this.evaluate(function (lastPostLink) {
|
|
return document.querySelector(lastPostLink).getAttribute('href');
|
|
}, lastPostLink);
|
|
|
|
test.assert(link === '/welcome-to-ghost/', 'Has correct link');
|
|
});
|
|
|
|
casper.thenClick(lastPostLink);
|
|
|
|
casper.waitForResource(/welcome-to-ghost/).then(function (resource) {
|
|
test.assert(resource.status === 200, 'resource got 200');
|
|
});
|
|
});
|
|
}, true);
|
|
|
|
CasperTest.begin('Test navigating to Post with date permalink', 4, function suite(test) {
|
|
CasperTest.Routines.togglePermalinks.run('on');
|
|
casper.thenOpen(url, function then(response) {
|
|
var lastPost = '.content article:last-of-type',
|
|
lastPostLink = lastPost + ' .post-title a',
|
|
today = new Date(),
|
|
dd = ("0" + today.getDate()).slice(-2),
|
|
mm = ("0" + (today.getMonth() + 1)).slice(-2),
|
|
yyyy = today.getFullYear(),
|
|
postLink = '/' + yyyy + '/' + mm + '/' + dd + '/welcome-to-ghost/';
|
|
|
|
test.assertExists(lastPost, 'there is a last child on the page');
|
|
test.assertSelectorHasText(lastPostLink, 'Welcome to Ghost', 'Is correct post');
|
|
|
|
casper.then(function testLink() {
|
|
var link = this.evaluate(function (lastPostLink) {
|
|
return document.querySelector(lastPostLink).getAttribute('href');
|
|
}, lastPostLink);
|
|
|
|
test.assert(link === postLink, 'Has correct link');
|
|
});
|
|
|
|
casper.thenClick(lastPostLink);
|
|
|
|
casper.waitForResource(postLink).then(function (resource) {
|
|
test.assert(resource.status === 200, 'resource got 200');
|
|
});
|
|
});
|
|
CasperTest.Routines.togglePermalinks.run('off');
|
|
}, false);
|
|
|