Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #271 from aldryn/feature/gulpfile-update
Browse files Browse the repository at this point in the history
More integration tests
  • Loading branch information
Marketionist committed Jul 16, 2015
2 parents bb65a99 + 2bbaaf6 commit 299dc17
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ var newsBlogPage = {
userMenus: element.all(by.css('.cms_toolbar-item-navigation > li > a')),
testLink: element(by.css('.selected a')),

// adding new page
userMenuDropdown: element(by.css(
'.cms_toolbar-item-navigation-hover')),
administrationOptions: element.all(by.css(
'.cms_toolbar-item-navigation a[href="/en/admin/"]')),
sideMenuIframe: element(by.css('.cms_sideframe-frame iframe')),
pagesLink: element(by.css('.model-page > th > a')),
addPageLink: element(by.css('.sitemap-noentry .addlink')),
titleInput: element(by.id('id_title')),
slugErrorNotification: element(by.css('.errors.slug')),
saveButton: element(by.css('.submit-row [name="_save"]')),
editPageLink: element(by.css('.col1 [href*="preview/"]')),

// adding new apphook config
breadcrumbsLinks: element.all(by.css('.breadcrumbs a')),
newsBlogConfigsLink: element(by.css('.model-newsblogconfig > th > a')),
editConfigsLink: element(by.css('.row1 > th > a')),
addConfigsButton: element(by.css('.object-tools .addlink')),
namespaceInput: element(by.id('id_namespace')),
applicationTitleInput: element(by.id('id_app_title')),
successNotification: element(by.css('.messagelist .success')),

cmsLogin: function (credentials) {
// object can contain username and password, if not set it will
// fallback to 'admin'
Expand Down
138 changes: 135 additions & 3 deletions aldryn_newsblog/tests/frontend/integration/specs/spec.newsblog.crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

'use strict';
/* global describe, it, browser */
/* global describe, it, browser, By, expect */

// #############################################################################
// INTEGRATION TEST
Expand All @@ -26,12 +26,144 @@ describe('Aldryn Newsblog tests: ', function () {
}

// wait for username input to appear
browser.wait(browser.isElementPresent(newsBlogPage.usernameInput),
newsBlogPage.mainElementsWaitTime);
browser.wait(function () {
return browser.isElementPresent(newsBlogPage.usernameInput);
}, newsBlogPage.mainElementsWaitTime);

// login to the site
newsBlogPage.cmsLogin();
});
});

it('creates a new test page', function () {
// click the example.com link in the top menu
newsBlogPage.userMenus.first().click().then(function () {
// wait for top menu dropdown options to appear
browser.wait(function () {
return browser.isElementPresent(newsBlogPage.userMenuDropdown);
}, newsBlogPage.mainElementsWaitTime);

newsBlogPage.administrationOptions.first().click();
}).then(function () {
// wait for modal iframe to appear
browser.wait(function () {
return browser.isElementPresent(newsBlogPage.sideMenuIframe);
}, newsBlogPage.iframeWaitTime);

// switch to sidebar menu iframe
browser.switchTo().frame(browser.findElement(
By.css('.cms_sideframe-frame iframe')));

browser.wait(function () {
return browser.isElementPresent(newsBlogPage.pagesLink);
}, newsBlogPage.mainElementsWaitTime);

newsBlogPage.pagesLink.click();

// check if the page already exists and return the status
return newsBlogPage.addPageLink.isPresent();
}).then(function (present) {
if (present === true) {
// page is absent - create new page
browser.wait(function () {
return browser.isElementPresent(newsBlogPage.addPageLink);
}, newsBlogPage.mainElementsWaitTime);

newsBlogPage.addPageLink.click();

browser.wait(function () {
return browser.isElementPresent(newsBlogPage.titleInput);
}, newsBlogPage.mainElementsWaitTime);

newsBlogPage.titleInput.sendKeys('Test').then(function () {
newsBlogPage.saveButton.click();

newsBlogPage.slugErrorNotification.isPresent()
.then(function (present) {
if (present === false) {
browser.wait(function () {
return browser.isElementPresent(newsBlogPage.editPageLink);
}, newsBlogPage.mainElementsWaitTime);

// wait till the editPageLink will become clickable
browser.sleep(500);

// validate/click edit page link
newsBlogPage.editPageLink.click();

// switch to default page content
browser.switchTo().defaultContent();

browser.wait(function () {
return browser.isElementPresent(newsBlogPage.testLink);
}, newsBlogPage.mainElementsWaitTime);

// validate test link text
newsBlogPage.testLink.getText()
.then(function (title) {
expect(title).toEqual('Test');
});
}
});
});
}
});
});

it('creates a new apphook config', function () {
// check if the focus is on sidebar ifarme
newsBlogPage.editPageLink.isPresent().then(function (present) {
if (present === false) {
// wait for modal iframe to appear
browser.wait(function () {
return browser.isElementPresent(newsBlogPage.sideMenuIframe);
}, newsBlogPage.iframeWaitTime);

// switch to sidebar menu iframe
browser.switchTo().frame(browser.findElement(By.css(
'.cms_sideframe-frame iframe')));
}
}).then(function () {
browser.wait(function () {
return browser.isElementPresent(newsBlogPage.breadcrumbsLinks.first());
}, newsBlogPage.mainElementsWaitTime);

// click the Home link in breadcrumbs
newsBlogPage.breadcrumbsLinks.first().click();

browser.wait(function () {
return browser.isElementPresent(newsBlogPage.newsBlogConfigsLink);
}, newsBlogPage.mainElementsWaitTime);

newsBlogPage.newsBlogConfigsLink.click();

// check if the apphook config already exists and return the status
return newsBlogPage.editConfigsLink.isPresent();
}).then(function (present) {
if (present === false) {
// apphook config is absent - create new apphook config
browser.wait(function () {
return browser.isElementPresent(newsBlogPage.addConfigsButton);
}, newsBlogPage.mainElementsWaitTime);

newsBlogPage.addConfigsButton.click();

browser.wait(function () {
return browser.isElementPresent(newsBlogPage.namespaceInput);
}, newsBlogPage.mainElementsWaitTime);

newsBlogPage.namespaceInput.sendKeys('aldryn_newsblog')
.then(function () {
newsBlogPage.applicationTitleInput.sendKeys('Test title');
}).then(function () {
newsBlogPage.saveButton.click();

browser.wait(function () {
return browser.isElementPresent(newsBlogPage.successNotification);
}, newsBlogPage.mainElementsWaitTime);
});
}
});
});

});
4 changes: 2 additions & 2 deletions aldryn_newsblog/tests/frontend/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ var browsers = baseConf.sauceLabsBrowsers;
var config = {
// Maximum number of total browser sessions to run. Tests are queued in
// sequence if number of browser sessions is limited by this parameter.
// Use a number less than 1 to denote unlimited. Default is unlimited.
// Use a number less than 1 to denote unlimited. Default is unlimited
maxSessions: 1,

// Capabilities to be passed to the webdriver instance.
// Capabilities to be passed to the webdriver instance
capabilities: {
'browserName': 'phantomjs',
'phantomjs.binary.path': require('phantomjs').path
Expand Down
5 changes: 2 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ var PROJECT_PATH = {
var PROJECT_PATTERNS = {
'lint': [
PROJECT_PATH.js + '/addons/*.js',
PROJECT_PATH.tests + '/*.js',
PROJECT_PATH.tests + '/unit/*.js',
PROJECT_PATH.tests + '/integration/*/*.js',
PROJECT_PATH.tests + '/**/*.js',
'!' + PROJECT_PATH.tests + '/coverage/**/*.js',
PROJECT_ROOT + '/gulpfile.js'
]
};
Expand Down

0 comments on commit 299dc17

Please sign in to comment.