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-06-30 16:58:10 +04:00
|
|
|
CasperTest.begin('Admin navigation bar is correct', 27, 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() {
|
|
|
|
var logoHref = this.getElementAttribute('a.ghost-logo', 'href'),
|
|
|
|
contentHref = this.getElementAttribute('#main-menu li.content a', 'href'),
|
|
|
|
editorHref = this.getElementAttribute('#main-menu li.editor a', 'href'),
|
|
|
|
settingsHref = this.getElementAttribute('#main-menu li.settings a', 'href');
|
|
|
|
|
|
|
|
// Logo
|
|
|
|
test.assertExists('a.ghost-logo', 'Ghost logo home page link exists');
|
|
|
|
test.assertEquals(logoHref, '/', 'Ghost logo href is correct');
|
|
|
|
|
|
|
|
// Content
|
|
|
|
test.assertExists('#main-menu li.content a', 'Content nav item exists');
|
|
|
|
test.assertSelectorHasText('#main-menu li.content a', 'Content', 'Content nav item has correct text');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertEquals(contentHref, '/ghost/', 'Content href is correct');
|
2014-06-17 01:44:09 +04:00
|
|
|
test.assertExists('#main-menu li.content.active', 'Content nav item is not marked active');
|
|
|
|
|
|
|
|
// Editor
|
|
|
|
test.assertExists('#main-menu li.editor a', 'Editor nav item exists');
|
|
|
|
test.assertSelectorHasText('#main-menu li.editor a', '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-06-17 01:44:09 +04:00
|
|
|
test.assertDoesntExist('#main-menu li.editor.active', 'Editor nav item is not marked active');
|
|
|
|
|
|
|
|
// Settings
|
|
|
|
test.assertExists('#main-menu li.settings a', 'Settings nav item exists');
|
|
|
|
test.assertSelectorHasText('#main-menu li.settings a', '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-06-17 01:44:09 +04:00
|
|
|
test.assertDoesntExist('#main-menu li.settings.active', 'Settings nav item is marked active');
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function testUserMenuNotVisible() {
|
|
|
|
test.assertExists('#usermenu', 'User menu nav item exists');
|
2014-07-01 03:26:08 +04:00
|
|
|
test.assertNotExists('#usermenu ul.overlay.open', 'User menu should not be visible');
|
2014-06-17 01:44:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.thenClick('#usermenu a');
|
2014-07-01 03:26:08 +04:00
|
|
|
casper.waitForSelector('#usermenu ul.overlay.open', function then() {
|
2014-06-17 01:44:09 +04:00
|
|
|
var profileHref = this.getElementAttribute('#usermenu li.usermenu-profile a', 'href'),
|
|
|
|
helpHref = this.getElementAttribute('#usermenu li.usermenu-help a', 'href'),
|
2014-07-24 01:12:45 +04:00
|
|
|
signoutHref = this.getElementAttribute('#usermenu li.usermenu-signout button', 'href');
|
2014-06-17 01:44:09 +04:00
|
|
|
|
|
|
|
test.assertVisible('#usermenu ul.overlay', 'User menu should be visible');
|
|
|
|
|
|
|
|
test.assertExists('#usermenu li.usermenu-profile a', 'Profile menu item exists');
|
|
|
|
test.assertSelectorHasText('#usermenu li.usermenu-profile a', 'Your Profile',
|
|
|
|
'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
|
|
|
|
|
|
|
test.assertExists('#usermenu li.usermenu-help a', 'Help menu item exists');
|
|
|
|
test.assertSelectorHasText('#usermenu li.usermenu-help a', 'Help / Support', 'Help menu item has correct text');
|
|
|
|
test.assertEquals(helpHref, 'http://support.ghost.org/', 'Help href is correct');
|
|
|
|
|
2014-07-24 01:12:45 +04:00
|
|
|
test.assertExists('#usermenu li.usermenu-signout button', 'Sign Out menu item exists');
|
|
|
|
test.assertSelectorHasText('#usermenu li.usermenu-signout button', 'Sign Out', 'Signout menu item has correct text');
|
2014-07-01 03:26:08 +04:00
|
|
|
// test.assertEquals(signoutHref, '/ghost/signout/', 'Sign Out href is correct');
|
2014-06-17 01:44:09 +04:00
|
|
|
}, casper.failOnTimeout(test, 'WaitForSelector #usermenu ul.overlay failed'));
|
|
|
|
});
|
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
|
|
|
});
|
|
|
|
});
|