From cfe272e175829b6092e04582ff9b8820fe67fc1a Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 1 Nov 2013 11:13:43 +0000 Subject: [PATCH] Functional tests for home and post page closes #1373 - Note that the tests fail if you run them pre #1363, thus future proofing us from this happening again. - Added submodule handling to travis - Added a new test for each of the home and post pages --- .travis.yml | 3 +-- core/test/functional/frontend/home_test.js | 22 ++++++++++++++++++++ core/test/functional/frontend/post_test.js | 23 +++++++++++++++++++++ core/test/functional/frontend/route_test.js | 6 +++--- 4 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 core/test/functional/frontend/home_test.js create mode 100644 core/test/functional/frontend/post_test.js diff --git a/.travis.yml b/.travis.yml index 0ed022b4fc..f984026995 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,8 @@ node_js: env: - DB=sqlite3 - DB=mysql -git: - submodules: false before_install: + - git submodule update --init - gem update --system - gem install sass bourbon - npm install -g grunt-cli diff --git a/core/test/functional/frontend/home_test.js b/core/test/functional/frontend/home_test.js new file mode 100644 index 0000000000..5918354523 --- /dev/null +++ b/core/test/functional/frontend/home_test.js @@ -0,0 +1,22 @@ +/** + * 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'); + }); +}); \ No newline at end of file diff --git a/core/test/functional/frontend/post_test.js b/core/test/functional/frontend/post_test.js new file mode 100644 index 0000000000..a0dfdab94b --- /dev/null +++ b/core/test/functional/frontend/post_test.js @@ -0,0 +1,23 @@ +/** + * Tests the default post page + */ + +/*globals CasperTest, casper, __utils__, url, testPost, falseUser, email */ +CasperTest.begin('Post page loads', 3, function suite(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'); + }); +}); \ No newline at end of file diff --git a/core/test/functional/frontend/route_test.js b/core/test/functional/frontend/route_test.js index 67da4867c9..142f61d536 100644 --- a/core/test/functional/frontend/route_test.js +++ b/core/test/functional/frontend/route_test.js @@ -1,10 +1,10 @@ /** - * Tests logging out and attempting to sign up + * Tests archive page routing */ -/*globals casper, __utils__, url, testPost, falseUser, email */ +/*globals CasperTest, casper, __utils__, url, testPost, falseUser, email */ CasperTest.begin('Redirects page 1 request', 1, function suite(test) { - casper.thenOpen(url + 'page/1/', function then(response) { + casper.thenOpen(url + 'page/1/', function then(response) { test.assertEqual(casper.getCurrentUrl().indexOf('page/'), -1, 'Should be redirected to "/".'); }); }, true); \ No newline at end of file