removed nightwatch
This commit is contained in:
parent
4bcd8e64db
commit
179a483661
|
@ -1,26 +0,0 @@
|
|||
// A custom Nightwatch assertion.
|
||||
// the name of the method is the filename.
|
||||
// can be used in tests like this:
|
||||
//
|
||||
// browser.assert.elementCount(selector, count)
|
||||
//
|
||||
// for how to write custom assertions see
|
||||
// http://nightwatchjs.org/guide#writing-custom-assertions
|
||||
exports.assertion = function (selector, count) {
|
||||
this.message = 'Testing if element <' + selector + '> has count: ' + count
|
||||
this.expected = count
|
||||
this.pass = function (val) {
|
||||
return val === this.expected
|
||||
}
|
||||
this.value = function (res) {
|
||||
return res.value
|
||||
}
|
||||
this.command = function (cb) {
|
||||
var self = this
|
||||
return this.api.execute(function (selector) {
|
||||
return document.querySelectorAll(selector).length
|
||||
}, [selector], function (res) {
|
||||
cb.call(self, res)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
module.exports.command = function(page) {
|
||||
return page;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
let fs = require("fs");
|
||||
let path = require("path");
|
||||
|
||||
module.exports.command = function(title) {
|
||||
//console.log(this);
|
||||
let prefix = this.currentTest.module + '/' + this.currentTest.name + (title ? ("-" + title) : "");
|
||||
prefix = prefix.replace(/\s/g, '-').replace(/"|'/g, '');
|
||||
let baseFilePath = path.join(this.screenshotsPath, prefix);
|
||||
|
||||
let idx = 2;
|
||||
let filePath = baseFilePath + ".png";
|
||||
while (fs.existsSync(filePath))
|
||||
filePath = baseFilePath + "_" + (idx++) + ".png";
|
||||
|
||||
this.saveScreenshot(filePath);
|
||||
return this;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
|
||||
"waitForConditionTimeout": 10000
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
let seleniumServer = require('selenium-server');
|
||||
let chromedriver = require('chromedriver');
|
||||
|
||||
let appPort = process.env.APP_PORT || process.env.PORT || 3000;
|
||||
|
||||
// http://nightwatchjs.org/guide#settings-file
|
||||
//
|
||||
module.exports = {
|
||||
"src_folders": ["e2e_tests/specs"],
|
||||
"output_folder": "e2e_tests/reports",
|
||||
"globals_path": "e2e_tests/globals.js",
|
||||
"custom_assertions_path": ["e2e_tests/custom-assertions"],
|
||||
"custom_commands_path": [ "e2e_tests/custom-commands" ],
|
||||
"page_objects_path": "e2e_tests/pages",
|
||||
"test_runner": {
|
||||
"type" : "mocha",
|
||||
"options": {
|
||||
"ui": "bdd",
|
||||
"reporter": "spec"
|
||||
}
|
||||
},
|
||||
|
||||
"selenium": {
|
||||
"start_process": true,
|
||||
"server_path": seleniumServer.path,
|
||||
"host": "127.0.0.1",
|
||||
"port": 4444,
|
||||
"cli_args": {
|
||||
"webdriver.chrome.driver": chromedriver.path
|
||||
}
|
||||
},
|
||||
|
||||
"test_settings": {
|
||||
"default": {
|
||||
"launch_url" : "http://tellform.dev:3001",
|
||||
"appPort": appPort,
|
||||
"selenium_port": 4444,
|
||||
"selenium_host": "localhost",
|
||||
"silent": true,
|
||||
"desiredCapabilities": {
|
||||
"javascriptEnabled": true,
|
||||
"acceptSslCerts": true
|
||||
},
|
||||
"screenshots": {
|
||||
"enabled": true,
|
||||
"on_failure" : true,
|
||||
"on_error" : false,
|
||||
"path": "e2e_tests/reports/screenshots"
|
||||
}
|
||||
},
|
||||
|
||||
"chrome": {
|
||||
"desiredCapabilities": {
|
||||
"browserName": "chrome"
|
||||
}
|
||||
},
|
||||
|
||||
"firefox": {
|
||||
"desiredCapabilities": {
|
||||
"browserName": "firefox"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
let commands = {
|
||||
submit(email) {
|
||||
return this
|
||||
.waitForElementVisible('@emailField', 10000)
|
||||
.assert.containsText("@title", "FORGOT")
|
||||
.assert.elementPresent("@emailField")
|
||||
.setValue("@emailField", email)
|
||||
.makeScreenshot()
|
||||
.click("@submitButton");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
url() {
|
||||
return this.client.api.options.baseURL + "/forgot";
|
||||
},
|
||||
|
||||
commands: [commands],
|
||||
|
||||
elements: {
|
||||
title: "form header",
|
||||
emailField: "form #email",
|
||||
submitButton: "form [type=submit]",
|
||||
|
||||
flashError: ".flash .alert-danger div",
|
||||
flashInfo: ".flash .alert-success div"
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
let commands = {
|
||||
logout() {
|
||||
return this
|
||||
.client.api.url("http://"+ this.client.api.options.baseURL + this.client.options.appPort + "/logout")
|
||||
.waitForElementVisible(".page h1");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
url(subdomain) {
|
||||
console.log('http://'+subdomain + '.helpbase.dev:' + this.client.options.appPort + "/#!/");
|
||||
return 'http://'+subdomain + '.helpbase.dev:' + this.client.options.appPort + "/#!/";
|
||||
},
|
||||
|
||||
commands: [commands],
|
||||
|
||||
elements: {
|
||||
title: "h2.title.align-left"
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
let commands = {
|
||||
login(username, password) {
|
||||
return this
|
||||
.waitForElementVisible('@usernameField', 10000)
|
||||
.assert.elementPresent("@usernameField")
|
||||
.assert.elementPresent("@passwordField")
|
||||
.setValue("@usernameField", username)
|
||||
.setValue("@passwordField", password)
|
||||
.makeScreenshot()
|
||||
.click("@submitButton");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
url() {
|
||||
return this.client.api.options.baseURL + "/login";
|
||||
},
|
||||
|
||||
commands: [commands],
|
||||
|
||||
elements: {
|
||||
formImage: ".row > .col > img.responsive-image",
|
||||
usernameField: "form #username",
|
||||
passwordField: "form #password",
|
||||
submitButton: "form [type=submit]",
|
||||
|
||||
flashError: ".flash .alert-danger div",
|
||||
flashInfo: ".flash .alert-success div"
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
let commands = {
|
||||
submit(password, confirm) {
|
||||
return this
|
||||
.waitForElementVisible('@passwordField', 10000)
|
||||
.assert.containsText("@title", "NEW PASSWORD")
|
||||
.assert.elementPresent("@passwordField")
|
||||
.assert.elementPresent("@confirmField")
|
||||
.setValue("@passwordField", password)
|
||||
.setValue("@confirmField", confirm)
|
||||
.makeScreenshot()
|
||||
.click("@submitButton");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
url() {
|
||||
return this.client.api.options.baseURL + "/reset";
|
||||
},
|
||||
|
||||
commands: [commands],
|
||||
|
||||
elements: {
|
||||
title: "form header",
|
||||
passwordField: "form #password",
|
||||
confirmField: "form #confirm",
|
||||
submitButton: "form [type=submit]",
|
||||
|
||||
flashError: ".flash .alert-danger div",
|
||||
flashInfo: ".flash .alert-success div"
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
let commands = {
|
||||
signup(name, email, password, company_name, company_subdomain) {
|
||||
return this
|
||||
.waitForElementVisible('@emailField', 10000)
|
||||
.assert.elementPresent("@nameField")
|
||||
.assert.elementPresent("@emailField")
|
||||
.assert.elementPresent("@companyNameField")
|
||||
.assert.elementPresent("@companySubdomainField")
|
||||
.assert.elementPresent("@passwordField")
|
||||
.setValue("@nameField", name)
|
||||
.setValue("@emailField", email)
|
||||
.setValue("@passwordField", password)
|
||||
.setValue("@companyNameField", company_name)
|
||||
.setValue("@companySubdomainField", company_subdomain)
|
||||
.makeScreenshot()
|
||||
.click("@submitButton");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
url() {
|
||||
return this.client.api.options.baseURL + "/signup";
|
||||
},
|
||||
|
||||
commands: [commands],
|
||||
|
||||
elements: {
|
||||
title: "form header",
|
||||
nameField: "form #name",
|
||||
companySubdomainField: "form #company_subdomain",
|
||||
companyNameField: "form #company_name",
|
||||
emailField: "form #email",
|
||||
passwordField: "form #password",
|
||||
submitButton: "form [type=submit]",
|
||||
|
||||
flashError: ".flash .alert-danger div",
|
||||
flashInfo: ".flash .alert-success div"
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
var path = require("path");
|
||||
|
||||
// 1. start the server
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
// Pass the port of server via environment
|
||||
var app = require("../server");
|
||||
var config = require('../config/config');
|
||||
process.env.APP_PORT = config.port;
|
||||
|
||||
// 2. run the nightwatch test suite against it
|
||||
// to run in additional browsers:
|
||||
// 1. add an entry in tests/e2e/nightwatch.conf.json under "test_settings"
|
||||
// 2. or add it to the --env flag below
|
||||
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
|
||||
// For more information on Nightwatch's config file, see
|
||||
// http://nightwatchjs.org/guide#settings-file
|
||||
|
||||
var opts = process.argv.slice(2);
|
||||
if (opts.indexOf('--config') === -1) {
|
||||
opts = opts.concat(['--config', 'e2e_tests/nightwatch.conf.js']);
|
||||
}
|
||||
if (opts.indexOf('--env') === -1) {
|
||||
opts = opts.concat(['--env', 'chrome']);
|
||||
}
|
||||
|
||||
// Clear reports folder
|
||||
var del = require("del");
|
||||
del.sync(path.join(__dirname, "reports", "**"));
|
||||
|
||||
var spawn = require('cross-spawn');
|
||||
var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' });
|
||||
|
||||
runner.on('exit', function (code) {
|
||||
app.close();
|
||||
process.exit(code);
|
||||
});
|
||||
|
||||
runner.on('error', function (err) {
|
||||
app.close();
|
||||
throw err;
|
||||
});
|
|
@ -1,73 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
let mailtrap = require("../../util/mailtrap");
|
||||
|
||||
let pauseTime = 100;
|
||||
|
||||
describe.only("Test login page with username and password", () => {
|
||||
|
||||
let loginPage;
|
||||
let homePage;
|
||||
|
||||
let baseURL;
|
||||
|
||||
before((browser, done) => {
|
||||
baseURL = 'http://helpbase.dev:' + browser.globals.test_settings.appPort;
|
||||
browser.options.baseURL = baseURL;
|
||||
loginPage = browser.page.loginPage();
|
||||
homePage = browser.page.homePage();
|
||||
done();
|
||||
});
|
||||
|
||||
after((browser, done) => {
|
||||
browser.end(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should give error, if username/email does not exist", (browser) => {
|
||||
loginPage.navigate()
|
||||
.waitForElementPresent('form.validate-form')
|
||||
.login("johnnn", "johnny")
|
||||
.waitForElementPresent(".flash")
|
||||
.assert.elementPresent("@flashError")
|
||||
.assert.containsText("@flashError", "Unknow username or e-mail")
|
||||
.api.pause(pauseTime)
|
||||
.makeScreenshot();
|
||||
});
|
||||
|
||||
it("should give error, if password is incorrect", (browser) => {
|
||||
loginPage.navigate()
|
||||
.login("test", "1234567")
|
||||
.waitForElementPresent(".flash")
|
||||
.assert.elementPresent("@flashError")
|
||||
.assert.containsText("@flashError", "Unknown user or invalid password")
|
||||
.api.pause(pauseTime)
|
||||
.makeScreenshot();
|
||||
});
|
||||
|
||||
it("should redirect to main, if credentials correct", (browser) => {
|
||||
loginPage.navigate()
|
||||
.login("test", "test1234")
|
||||
.api.pause(pauseTime)
|
||||
.makeScreenshot();
|
||||
|
||||
homePage
|
||||
.waitForElementVisible("@title")
|
||||
.assert.containsText("@title", "Dashboard")
|
||||
.assert.urlEquals('http://polydaic.helpbase.dev:3000/#!/")
|
||||
.makeScreenshot();
|
||||
});
|
||||
|
||||
it("should jump to index, after logout", (browser) => {
|
||||
// Logout
|
||||
browser.url(http://polydaic.helpbase.dev:3000 + "/logout")
|
||||
.waitForElementVisible("h1.center-align")
|
||||
.assert.urlEquals(baseURL + "/")
|
||||
.assert.elementPresent("h1.center-align")
|
||||
.pause(pauseTime)
|
||||
.makeScreenshot();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/*"use strict";
|
||||
|
||||
let mailtrap = require("../../util/mailtrap");
|
||||
|
||||
let pauseTime = 100;
|
||||
|
||||
describe("Test forgot page", () => {
|
||||
|
||||
let forgotPage;
|
||||
let resetPage;
|
||||
let homePage;
|
||||
let loginPage;
|
||||
|
||||
let baseURL;
|
||||
|
||||
before((browser, done) => {
|
||||
baseURL = 'http://localhost:' + browser.globals.test_settings.appPort;
|
||||
browser.options.baseURL = baseURL;
|
||||
|
||||
forgotPage = browser.page.forgotPage();
|
||||
resetPage = browser.page.resetPage();
|
||||
homePage = browser.page.homePage();
|
||||
loginPage = browser.page.loginPage();
|
||||
done();
|
||||
});
|
||||
|
||||
after((browser, done) => {
|
||||
browser.end(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should give error, if email is not found", (browser) => {
|
||||
forgotPage.navigate()
|
||||
.submit("chuck.norris@notfound.me")
|
||||
.waitForElementPresent(".flash")
|
||||
.assert.elementPresent("@flashError")
|
||||
.assert.containsText("@flashError", "The email address chuck.norris@notfound.me is not associated with any account.")
|
||||
.api.pause(pauseTime)
|
||||
.makeScreenshot();
|
||||
});
|
||||
|
||||
it("should send rest email, if email is correct", (browser) => {
|
||||
forgotPage.navigate()
|
||||
.submit("test@boilerplate-app.com")
|
||||
.waitForElementPresent(".flash")
|
||||
.assert.elementPresent("@flashInfo")
|
||||
.assert.containsText("@flashInfo", "An email has been sent to test@boilerplate-app.com with further instructions.")
|
||||
.api.pause(pauseTime)
|
||||
.makeScreenshot();
|
||||
|
||||
browser
|
||||
.pause(1000) // Wait for email received
|
||||
.perform(function(browser, done) {
|
||||
console.log("Check mailbox...");
|
||||
|
||||
let re = /reset\/(\w+)/g;
|
||||
mailtrap.getTokenFromMessage("test@boilerplate-app.com", re, function(err, token, message) {
|
||||
if (err)
|
||||
throw new Error(err);
|
||||
|
||||
// Delete message
|
||||
mailtrap.deleteMessage(null, message.id);
|
||||
|
||||
console.log("Open reset link: " + baseURL + "/reset/" + token);
|
||||
browser.url(baseURL + "/reset/" + token);
|
||||
|
||||
return done();
|
||||
});
|
||||
|
||||
return this;
|
||||
})
|
||||
.pause(pauseTime);
|
||||
|
||||
// Try to reset password
|
||||
resetPage
|
||||
.waitForElementVisible("@passwordField")
|
||||
|
||||
// password is too short
|
||||
.submit("123", "123")
|
||||
.waitForElementPresent(".flash")
|
||||
.assert.elementPresent("@flashError")
|
||||
.assert.containsText("@flashError", "Password must be at least 6 characters long!")
|
||||
.api.pause(pauseTime)
|
||||
.makeScreenshot()
|
||||
|
||||
resetPage
|
||||
// invalid confirm password
|
||||
.submit("newPassword", "otherConfirmPassword")
|
||||
.waitForElementPresent(".flash")
|
||||
.assert.elementPresent("@flashError")
|
||||
.assert.containsText("@flashError", "Passwords must match.")
|
||||
.api.pause(pauseTime)
|
||||
.makeScreenshot()
|
||||
|
||||
resetPage
|
||||
// correct new password
|
||||
.submit("newPassword", "newPassword")
|
||||
.api.pause(pauseTime)
|
||||
|
||||
// Check we logged in automatically
|
||||
homePage
|
||||
.waitForElementVisible("@title")
|
||||
.assert.urlEquals(homePage.url)
|
||||
.assert.containsText("@title", "Home")
|
||||
.makeScreenshot();
|
||||
|
||||
// Logout
|
||||
homePage
|
||||
.logout()
|
||||
|
||||
// Login with the new password
|
||||
loginPage.navigate()
|
||||
.login("test", "newPassword");
|
||||
|
||||
homePage
|
||||
.waitForElementVisible("@title")
|
||||
.assert.urlEquals(homePage.url)
|
||||
.assert.containsText("@title", "Home")
|
||||
.makeScreenshot();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
*/
|
|
@ -1,86 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
let mailtrap = require("../../util/mailtrap");
|
||||
let fakerator = require("fakerator")();
|
||||
|
||||
let pauseTime = 100;
|
||||
|
||||
let user = fakerator.entity.user();
|
||||
let company = fakerator.entity.company();
|
||||
user.name = user.firstName + " " + user.lastName;
|
||||
|
||||
describe("Test signup page with password", () => {
|
||||
|
||||
let loginPage;
|
||||
let signupPage;
|
||||
let homePage;
|
||||
|
||||
let baseURL;
|
||||
|
||||
before((browser, done) => {
|
||||
baseURL = 'http://helpbase.dev:' + browser.globals.test_settings.appPort;
|
||||
browser.options.baseURL = baseURL;
|
||||
signupPage = browser.page.signupPage();
|
||||
loginPage = browser.page.loginPage();
|
||||
homePage = browser.page.homePage();
|
||||
done();
|
||||
});
|
||||
|
||||
after((browser, done) => {
|
||||
browser.end(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should give error, if password is too short", (browser) => {
|
||||
signupPage.navigate()
|
||||
.signup(user.name, user.email, "123", company.name, "abcd")
|
||||
.waitForElementPresent(".flash")
|
||||
.assert.elementPresent("@flashError")
|
||||
.assert.containsText("@flashError", "Password must be at least 6 characters long!")
|
||||
.api.pause(pauseTime)
|
||||
.makeScreenshot();
|
||||
});
|
||||
|
||||
it("should accept signup, if every data is good", (browser) => {
|
||||
signupPage.navigate()
|
||||
.signup(user.name, user.email, user.password, company.name, "abcd")
|
||||
.waitForElementPresent(".flash")
|
||||
.assert.elementPresent("@flashInfo")
|
||||
.assert.containsText("@flashInfo", "Please check your email to verify your account. Thanks for signing up!")
|
||||
.api.pause(pauseTime)
|
||||
.assert.urlEquals(loginPage.url)
|
||||
.makeScreenshot();
|
||||
|
||||
browser
|
||||
.pause(1000) // Wait for email received
|
||||
.perform(function(browser, done) {
|
||||
//console.log("Check mailbox...");
|
||||
|
||||
let re = /verify\/(\w+)/g;
|
||||
mailtrap.getTokenFromMessage(user.email, re, function(err, token, message) {
|
||||
if (err)
|
||||
throw new Error(err);
|
||||
|
||||
// Delete message
|
||||
mailtrap.deleteMessage(null, message.id);
|
||||
|
||||
//console.log("Open verify link: " + baseURL + "/verify/" + token);
|
||||
browser.url(baseURL + "/verify/" + token);
|
||||
|
||||
return done();
|
||||
});
|
||||
|
||||
return this;
|
||||
})
|
||||
.pause(pauseTime);
|
||||
|
||||
// Check the user redirected to main app
|
||||
homePage
|
||||
.waitForElementVisible('@usernameField')
|
||||
.assert.urlEquals(loginPage.url)
|
||||
.makeScreenshot();
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in a new issue