From 3b87aa2895ebe52fb5a5b2fbe1d67ad716d1894a Mon Sep 17 00:00:00 2001 From: Paul Adam Davis Date: Fri, 5 Dec 2014 14:39:19 +0000 Subject: [PATCH] About Page Tests Closes #4508 Tests for: - Version number is a number - Database type is an allowed 1 of 3 - There are 20 contributors - First contributor has an image tag and image src exists, alt tag, title tag, href to github --- core/client/templates/settings/about.hbs | 2 +- core/test/functional/base.js | 4 ++ .../functional/client/settings_about_test.js | 40 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 core/test/functional/client/settings_about_test.js diff --git a/core/client/templates/settings/about.hbs b/core/client/templates/settings/about.hbs index e6d947e7b1..c6e79858bc 100644 --- a/core/client/templates/settings/about.hbs +++ b/core/client/templates/settings/about.hbs @@ -23,7 +23,7 @@
Environment:
{{environment}}
Database:
-
{{database}}
+
{{database}}
Mail:
{{#if mail}}{{mail}}{{else}}Native{{/if}}
diff --git a/core/test/functional/base.js b/core/test/functional/base.js index 660fe2d68c..148dbd8ad9 100644 --- a/core/test/functional/base.js +++ b/core/test/functional/base.js @@ -84,6 +84,10 @@ screens = { url: 'ghost/settings/general', selector: '.settings-nav-general.active' }, + 'settings.about': { + url: 'ghost/settings/about', + selector: '.settings-nav-about.active' + }, 'settings.users': { url: 'ghost/settings/users', linkSelector: '.settings-nav-users a', diff --git a/core/test/functional/client/settings_about_test.js b/core/test/functional/client/settings_about_test.js new file mode 100644 index 0000000000..83d601b883 --- /dev/null +++ b/core/test/functional/client/settings_about_test.js @@ -0,0 +1,40 @@ +// # About Test +// Test the various parts of the About page + +/*globals CasperTest, casper */ + +CasperTest.begin('About screen is correct', 10, function suite(test) { + casper.thenOpenAndWaitForPageLoad('settings.about', function testTitleAndUrl() { + test.assertTitle('Settings - About - Test Blog', 'Ghost admin has incorrect title'); + test.assertUrlMatch(/ghost\/settings\/about\/$/, 'Landed on the correct URL'); + }); + + casper.then(function testVersionNumber() { + var versionNumber = casper.getHTML('.about-ghost-intro .version'); + test.assertMatch(versionNumber, /\d+\.\d+\.\d+/, 'Version is a number'); // Tests for a pattern like 0.0.0 to v11111.3334534.2342453-beta + }); + + casper.then(function testDatabaseType() { + var databaseTypeText = casper.getHTML('.about-environment-database'); + test.assertMatch(databaseTypeText, /sqlite3|mysql|pg/gi, 'Database is an allowed type'); + }); + + casper.then(function testContributors() { + var firstContribImageSrc = casper.getElementAttribute('.top-contributors li:nth-child(1) a img', 'src'); + + test.assertElementCount('.top-contributors li', 20, '20 contributors are shown'); + + // Check first contributor image tag is on the page + test.assertExist('.top-contributors li:nth-child(1) img', 'First contributor image is in place'); + + // Check first contributor image resource exists & alt tag isnt empty + test.assertResourceExists(firstContribImageSrc, 'First contributor image file exists'); + test.assertDoesntExist('.top-contributors li:nth-child(1) a img[alt=""]', 'First contributor image alt is not empty'); + + // Check first contributor links to GitHub + test.assertExists('.top-contributors li:nth-child(1) a[href*="github.com"]', 'First contributor link to GitHub'); + + // Check first contributor links to GitHub + test.assertDoesntExist('.top-contributors li:nth-child(1) a[title=""]', 'First contributor title is not empty'); + }); +});