This repository has been archived by the owner on Oct 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #399 from aldryn/feature/integration-tests
added apphook creation test
- Loading branch information
Showing
3 changed files
with
95 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ var PROJECT_PATTERNS = { | |
|
||
var INTEGRATION_TESTS = [ | ||
[ | ||
'loginAdmin' | ||
'crud' | ||
] | ||
]; | ||
|
||
|