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 #399 from aldryn/feature/integration-tests
Browse files Browse the repository at this point in the history
added apphook creation test
  • Loading branch information
vxsx committed May 24, 2016
2 parents 5829875 + 8ff9d73 commit 676690e
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 53 deletions.
94 changes: 94 additions & 0 deletions aldryn_newsblog/tests/frontend/integration/crud.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
'use strict';

var helpers = require('djangocms-casper-helpers');
var globals = helpers.settings;
var casperjs = require('casper');
var cms = helpers(casperjs);
var xPath = casperjs.selectXPath;

casper.test.setUp(function (done) {
casper.start()
.then(cms.login())
.run(done);
});

casper.test.tearDown(function (done) {
casper.start()
.then(cms.logout())
.run(done);
});

/**
* Returns xpath expression to find the "Add" link corresponding
* to the specific row in the admin.
*
* @function generateXPathForAddLink
* @param {Object} options
* @param {String} options.section module name, e.g. Django CMS
* @param {String} options.row module row, e.g Pages, Users
*/
var generateXPathForAddLink = function (options) {
var section = options.section;
var row = options.row;
var xpath = '//div[.//caption/a[contains(text(), "' + section + '")]]';

xpath += '//th[./a[contains(text(), "' + row + '")]]';
xpath += '/following-sibling::td/a[contains(text(), "Add")]';

return xpath;
};

casper.test.begin('Creation / deletion of the apphook', function (test) {
casper
.start(globals.adminUrl)
.waitUntilVisible('#content', function () {
test.assertVisible('#content', 'Admin loaded');
this.click(
xPath(generateXPathForAddLink({
section: 'Aldryn News & Blog',
row: 'Application configurations'
}))
);
})
.waitForUrl(/add/)
.waitUntilVisible('#newsblogconfig_form')
.then(function () {
test.assertVisible('#newsblogconfig_form', 'Apphook creation form loaded');

this.fill('#newsblogconfig_form', {
namespace: 'Test namespace',
app_title: 'Test Blog'
}, true);
})
.waitUntilVisible('.success', function () {
test.assertSelectorHasText(
'.success',
'The application configuration "NewsBlog / Test namespace" was added successfully.',
'Apphook config was created'
);

test.assertElementCount(
'#result_list tbody tr',
2,
'There are 2 apphooks now'
);

this.clickLabel('NewsBlog / Test namespace', 'a');
})
.waitUntilVisible('.deletelink', function () {
this.click('.deletelink');
})
.waitForUrl(/delete/, function () {
this.click('input[value="Yes, I\'m sure"]');
})
.waitUntilVisible('.success', function () {
test.assertSelectorHasText(
'.success',
'The application configuration "NewsBlog / Test namespace" was deleted successfully.',
'Apphook config was deleted'
);
})
.run(function () {
test.done();
});
});
52 changes: 0 additions & 52 deletions aldryn_newsblog/tests/frontend/integration/loginAdmin.js

This file was deleted.

2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var PROJECT_PATTERNS = {

var INTEGRATION_TESTS = [
[
'loginAdmin'
'crud'
]
];

Expand Down

0 comments on commit 676690e

Please sign in to comment.