Commit 4a4016ff authored by Pascal Hartig's avatar Pascal Hartig

Update browser-tests JS style

parent d7be11ee
module.exports = function (grunt) { module.exports = function (grunt) {
'use strict';
grunt.loadNpmTasks('grunt-simple-mocha'); grunt.loadNpmTasks('grunt-simple-mocha');
var gruntConfig = { grunt.initConfig({
simplemocha: { simplemocha: {
options: { options: {
reporter: 'mocha-known-issues-reporter' reporter: 'mocha-known-issues-reporter'
}, },
files: { files: {
src: 'allTests.js' src: 'allTests.js'
} }
} }
}; });
grunt.initConfig(gruntConfig);
// build tasks // build tasks
grunt.registerTask('test', ['simplemocha']); grunt.registerTask('test', ['simplemocha']);
}; };
var testSuite = require('./test.js'), 'use strict';
fs = require('fs'),
argv = require('optimist').default('laxMode', false).argv,
rootUrl = "http://localhost:8000/",
frameworkNamePattern = /^[a-z-_]+$/;
// collect together the framework names from each of the subfolders var testSuite = require('./test.js');
var list = fs.readdirSync("../architecture-examples/") var fs = require('fs');
.map(function(folderName) { return { name : folderName, path : "architecture-examples/" + folderName} }); var argv = require('optimist').default('laxMode', false).argv;
var rootUrl = 'http://localhost:8000/';
list = list.concat(fs.readdirSync("../labs/architecture-examples/") var frameworkNamePattern = /^[a-z-_]+$/;
.map(function(folderName) { return { name : folderName, path: "labs/architecture-examples/" + folderName} }));
list = list.concat(fs.readdirSync("../labs/dependency-examples/")
.map(function(folderName) { return { name : folderName, path: "labs/dependency-examples/" + folderName} }));
list = list.concat(fs.readdirSync("../dependency-examples/") // collect together the framework names from each of the subfolders
.map(function(folderName) { return { name : folderName, path: "dependency-examples/" + folderName} })); var list = fs.readdirSync('../architecture-examples/')
.map(function (folderName) {
return { name: folderName, path: 'architecture-examples/' + folderName };
})
.concat(fs.readdirSync('../labs/architecture-examples/')
.map(function (folderName) {
return { name: folderName, path: 'labs/architecture-examples/' + folderName };
})
)
.concat(fs.readdirSync('../labs/dependency-examples/')
.map(function (folderName) {
return { name: folderName, path: 'labs/dependency-examples/' + folderName };
})
)
.concat(fs.readdirSync('../dependency-examples/')
.map(function (folderName) {
return { name: folderName, path: 'dependency-examples/' + folderName };
})
);
// apps that are not hosted at the root of their folder need to be handled explicitly // apps that are not hosted at the root of their folder need to be handled explicitly
var exceptions = [ var exceptions = [
{ name : "chaplin-brunch", path : "labs/dependency-examples/chaplin-brunch/public" } { name: 'chaplin-brunch', path: 'labs/dependency-examples/chaplin-brunch/public' }
]; ];
list = list.map(function(framework) {
var exception = exceptions.filter(function(exFramework) { return exFramework.name === framework.name}); list = list.map(function (framework) {
return exception.length > 0 ? exception[0] : framework; var exception = exceptions.filter(function (exFramework) {
return exFramework.name === framework.name;
});
return exception.length > 0 ? exception[0] : framework;
}); });
// filter out any folders that are not frameworks (.e.g hidden files) // filter out any folders that are not frameworks (.e.g hidden files)
list = list.filter(function(framework) { return frameworkNamePattern.test(framework.name); }); list = list.filter(function (framework) {
return frameworkNamePattern.test(framework.name);
});
// if a specific framework has been named, just run this one // if a specific framework has been named, just run this one
if (argv.framework) { if (argv.framework) {
list = list.filter(function(framework) { return framework.name === argv.framework}); list = list.filter(function (framework) {
return framework.name === argv.framework;
});
} }
// run the tests for each framework // run the tests for each framework
var testIndex = 1; list.forEach(function (framework) {
list.forEach(function(framework) { testSuite.todoMVCTest(
testSuite.todoMVCTest(framework.name, framework.name,
rootUrl + framework.path + "/index.html", argv.speedMode, argv.laxMode); rootUrl + framework.path + '/index.html', argv.speedMode,
argv.laxMode
);
}); });
This diff is collapsed.
This diff is collapsed.
var webdriver = require('selenium-webdriver'), 'use strict';
Page = require("./page");
function PageLaxMode(browser) { var webdriver = require('selenium-webdriver');
Page.apply(this, [browser]); var Page = require('./page');
this.tryGetToggleForItemAtIndex = function(index) { module.exports = function PageLaxMode(browser) {
// the specification dictates that the checkbox should have the 'toggle' CSS class. Some implementations deviate from Page.apply(this, [browser]);
// this, hence in lax mode we simply look for any checkboxes within the specified 'li'.
var xpath = this.xPathForItemAtIndex(index) + "//input[@type='checkbox']";
return browser.findElements(webdriver.By.xpath(xpath));
}
this.getEditInputForItemAtIndex = function(index) { this.tryGetToggleForItemAtIndex = function (index) {
// the specification dictates that the input element that allows the user to edit a todo item should have a CSS // the specification dictates that the checkbox should have the 'toggle' CSS class. Some implementations deviate from
// class of 'edit'. In lax mode, we also look for an input of type 'text'. // this, hence in lax mode we simply look for any checkboxes within the specified 'li'.
var xpath = this.xPathForItemAtIndex(index) + '//input[@type="checkbox"]';
return browser.findElements(webdriver.By.xpath(xpath));
};
var xpath = "(" + this.xPathForItemAtIndex(index) + "//input[@type='text']" + "|" + this.getEditInputForItemAtIndex = function (index) {
this.xPathForItemAtIndex(index) + "//input[contains(@class,'edit')]" + ")"; // the specification dictates that the input element that allows the user to edit a todo item should have a CSS
return browser.findElement(webdriver.By.xpath(xpath)); // class of 'edit'. In lax mode, we also look for an input of type 'text'.
}
}
module.exports = PageLaxMode; var xpath = '(' + this.xPathForItemAtIndex(index) + '//input[@type="text"]' + '|' +
\ No newline at end of file this.xPathForItemAtIndex(index) + '//input[contains(@class,"edit")]' + ')';
return browser.findElement(webdriver.By.xpath(xpath));
};
};
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment