0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/test/functional/frontend/post_test.js
Harry Wolff 91ca4a43e5 Fix routing of posts and static pages
closes #1757 and #1773

- switches routes.frontend for posts and pages
to use a regex with two capturing groups.  This removes
the need to dynamically remove an express route at a
later point, leaving the decision making to frontend
controller.

- added unit tests for all routing conditions that 
can arise for posts and pages.

- updated functional tests to also test for same thing
in unit tests

- removes old code from server/api/index that used
to fix this issue, but is no longer needed

- removed some un-needed require statements in routes/admin
2013-12-30 02:04:46 -05:00

37 lines
No EOL
1.7 KiB
JavaScript

/**
* Tests the default post page
*/
/*globals CasperTest, casper, __utils__, url, testPost, falseUser, email */
// Tests when permalinks is set to date (changed in feed_test)
CasperTest.begin('Post page does not load as slug', 2, function suite(test) {
casper.start(url + 'welcome-to-ghost', function then(response) {
test.assertTitle('404 — Page Not Found', 'The post should return 404 page');
test.assertElementCount('.content .post', 0, 'There is no post on this page');
});
}, true);
CasperTest.begin('Toggle permalinks', 0, function suite(test) {
CasperTest.Routines.togglePermalinks.run(test);
});
CasperTest.begin('Post page loads', 3, function suite(test) {
CasperTest.Routines.togglePermalinks.run(test);
casper.start(url + 'welcome-to-ghost', function then(response) {
test.assertTitle('Welcome to Ghost', 'The post should have a title and it should be "Welcome to Ghost"');
test.assertElementCount('.content .post', 1, 'There is exactly one post on this page');
test.assertSelectorHasText('.poweredby', 'Proudly published with Ghost');
});
}, true);
CasperTest.begin('Test helpers on homepage', 4, function suite(test) {
casper.start(url + 'welcome-to-ghost', function then(response) {
// body class
test.assertExists('body.post-template', 'body_class outputs correct post-template class');
test.assertExists('body.tag-getting-started', 'body_class outputs correct tag 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');
});
});