2014-06-17 01:44:09 +04:00
|
|
|
// # App Test
|
|
|
|
// Tests that the general layout & functionality of global admin components is correct
|
|
|
|
|
2014-06-24 15:17:40 +04:00
|
|
|
/*globals CasperTest, casper */
|
2014-06-17 01:44:09 +04:00
|
|
|
|
2014-08-18 20:43:06 +04:00
|
|
|
CasperTest.begin('Admin navigation bar is correct', 28, function suite(test) {
|
2014-06-17 01:44:09 +04:00
|
|
|
casper.thenOpenAndWaitForPageLoad('root', function testTitleAndUrl() {
|
|
|
|
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function testNavItems() {
|
2014-08-17 23:23:00 +04:00
|
|
|
var logoHref = this.getElementAttribute('.ghost-logo', 'href'),
|
|
|
|
contentHref = this.getElementAttribute('.nav-content', 'href'),
|
|
|
|
editorHref = this.getElementAttribute('.nav-new', 'href'),
|
|
|
|
settingsHref = this.getElementAttribute('.nav-settings', 'href');
|
2014-06-17 01:44:09 +04:00
|
|
|
|
|
|
|
// Logo
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.ghost-logo', 'Ghost logo home page link exists');
|
2014-08-11 13:25:30 +04:00
|
|
|
test.assertEquals(logoHref, '/', 'Ghost logo link href is correct');
|
2014-06-17 01:44:09 +04:00
|
|
|
|
|
|
|
// Content
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.nav-content', 'Content nav item exists');
|
|
|
|
test.assertSelectorHasText('.nav-content', 'Content', 'Content nav item has correct text');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertEquals(contentHref, '/ghost/', 'Content href is correct');
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.nav-content.active', 'Content nav item is not marked active');
|
2014-06-17 01:44:09 +04:00
|
|
|
|
|
|
|
// Editor
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.nav-new', 'Editor nav item exists');
|
|
|
|
test.assertSelectorHasText('.nav-new', 'New Post', 'Editor nav item has correct text');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertEquals(editorHref, '/ghost/editor/', 'Editor href is correct');
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertDoesntExist('.nav-new.active', 'Editor nav item is not marked active');
|
2014-06-17 01:44:09 +04:00
|
|
|
|
|
|
|
// Settings
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.nav-settings', 'Settings nav item exists');
|
|
|
|
test.assertSelectorHasText('.nav-settings', 'Settings', 'Settings nav item has correct text');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertEquals(settingsHref, '/ghost/settings/', 'Settings href is correct');
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertDoesntExist('.nav-settings.active', 'Settings nav item is marked active');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function testUserMenuNotVisible() {
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.user-menu', 'User menu nav item exists');
|
|
|
|
test.assertNotExists('.user-menu .dropdown.open', 'User menu should not be visible');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
2014-08-17 23:23:00 +04:00
|
|
|
casper.thenClick('.user-menu .nav-label');
|
|
|
|
casper.waitForSelector('.user-menu .dropdown.open', function then() {
|
|
|
|
var profileHref = this.getElementAttribute('.user-menu-profile', 'href'),
|
|
|
|
helpHref = this.getElementAttribute('.user-menu-support', 'href'),
|
|
|
|
signoutHref = this.getElementAttribute('.user-menu-signout', 'href');
|
2014-06-17 01:44:09 +04:00
|
|
|
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertVisible('.user-menu .dropdown-menu', 'User menu should be visible');
|
2014-06-17 01:44:09 +04:00
|
|
|
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.user-menu-profile', 'Profile menu item exists');
|
|
|
|
test.assertSelectorHasText('.user-menu-profile', 'Your Profile',
|
2014-06-17 01:44:09 +04:00
|
|
|
'Profile menu item has correct text');
|
2014-07-02 07:44:39 +04:00
|
|
|
test.assertEquals(profileHref, '/ghost/settings/users/' + newUser.slug + '/', 'Profile href is correct');
|
2014-06-17 01:44:09 +04:00
|
|
|
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.user-menu-support', 'Help menu item exists');
|
|
|
|
test.assertSelectorHasText('.user-menu-support', 'Help / Support', 'Help menu item has correct text');
|
2014-06-17 01:44:09 +04:00
|
|
|
test.assertEquals(helpHref, 'http://support.ghost.org/', 'Help href is correct');
|
|
|
|
|
2014-08-17 23:23:00 +04:00
|
|
|
test.assertExists('.user-menu-signout', 'Sign Out menu item exists');
|
|
|
|
test.assertSelectorHasText('.user-menu-signout', 'Sign Out', 'Signout menu item has correct text');
|
2014-07-30 00:49:26 +04:00
|
|
|
test.assertEquals(signoutHref, '/ghost/signout/', 'Sign Out href is correct');
|
2014-08-17 23:23:00 +04:00
|
|
|
}, casper.failOnTimeout(test, 'WaitForSelector .user-menu .dropdown failed'));
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
2014-06-28 07:50:31 +04:00
|
|
|
|
|
|
|
CasperTest.begin('Can transition to the editor and back', 6, function suite(test) {
|
|
|
|
casper.thenOpenAndWaitForPageLoad('root', function testTitleAndUrl() {
|
|
|
|
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-06-28 07:50:31 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.thenTransitionAndWaitForScreenLoad('editor', function testTransitionToEditor() {
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/editor\/$/, 'Landed on the correct URL');
|
2014-06-28 07:50:31 +04:00
|
|
|
test.assertExists('.entry-markdown', 'Ghost editor is present');
|
|
|
|
test.assertExists('.entry-preview', 'Ghost preview is present');
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.thenTransitionAndWaitForScreenLoad('content', function testTransitionToContent() {
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
2014-06-28 07:50:31 +04:00
|
|
|
});
|
|
|
|
});
|