Commit e36fff78 authored by ColinEberhardt's avatar ColinEberhardt

Merge pull request #801 from passy/browser-tests-style

Update browser-tests JS style
parents bacfede5 4a4016ff
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-simple-mocha');
'use strict';
grunt.loadNpmTasks('grunt-simple-mocha');
var gruntConfig = {
simplemocha: {
options: {
reporter: 'mocha-known-issues-reporter'
},
files: {
src: 'allTests.js'
}
}
};
grunt.initConfig(gruntConfig);
grunt.initConfig({
simplemocha: {
options: {
reporter: 'mocha-known-issues-reporter'
},
files: {
src: 'allTests.js'
}
}
});
// build tasks
grunt.registerTask('test', ['simplemocha']);
// build tasks
grunt.registerTask('test', ['simplemocha']);
};
var testSuite = require('./test.js'),
fs = require('fs'),
argv = require('optimist').default('laxMode', false).argv,
rootUrl = "http://localhost:8000/",
frameworkNamePattern = /^[a-z-_]+$/;
'use strict';
// collect together the framework names from each of the subfolders
var list = fs.readdirSync("../architecture-examples/")
.map(function(folderName) { return { name : folderName, path : "architecture-examples/" + folderName} });
list = list.concat(fs.readdirSync("../labs/architecture-examples/")
.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} }));
var testSuite = require('./test.js');
var fs = require('fs');
var argv = require('optimist').default('laxMode', false).argv;
var rootUrl = 'http://localhost:8000/';
var frameworkNamePattern = /^[a-z-_]+$/;
list = list.concat(fs.readdirSync("../dependency-examples/")
.map(function(folderName) { return { name : folderName, path: "dependency-examples/" + folderName} }));
// collect together the framework names from each of the subfolders
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
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});
return exception.length > 0 ? exception[0] : framework;
list = list.map(function (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)
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 (argv.framework) {
list = list.filter(function(framework) { return framework.name === argv.framework});
if (argv.framework) {
list = list.filter(function (framework) {
return framework.name === argv.framework;
});
}
// run the tests for each framework
var testIndex = 1;
list.forEach(function(framework) {
testSuite.todoMVCTest(framework.name,
rootUrl + framework.path + "/index.html", argv.speedMode, argv.laxMode);
list.forEach(function (framework) {
testSuite.todoMVCTest(
framework.name,
rootUrl + framework.path + '/index.html', argv.speedMode,
argv.laxMode
);
});
This diff is collapsed.
This diff is collapsed.
var webdriver = require('selenium-webdriver'),
Page = require("./page");
'use strict';
function PageLaxMode(browser) {
Page.apply(this, [browser]);
var webdriver = require('selenium-webdriver');
var Page = require('./page');
this.tryGetToggleForItemAtIndex = function(index) {
// the specification dictates that the checkbox should have the 'toggle' CSS class. Some implementations deviate from
// 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));
}
module.exports = function PageLaxMode(browser) {
Page.apply(this, [browser]);
this.getEditInputForItemAtIndex = function(index) {
// the specification dictates that the input element that allows the user to edit a todo item should have a CSS
// class of 'edit'. In lax mode, we also look for an input of type 'text'.
this.tryGetToggleForItemAtIndex = function (index) {
// the specification dictates that the checkbox should have the 'toggle' CSS class. Some implementations deviate from
// 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.xPathForItemAtIndex(index) + "//input[contains(@class,'edit')]" + ")";
return browser.findElement(webdriver.By.xpath(xpath));
}
}
this.getEditInputForItemAtIndex = function (index) {
// the specification dictates that the input element that allows the user to edit a todo item should have a CSS
// class of 'edit'. In lax mode, we also look for an input of type 'text'.
module.exports = PageLaxMode;
\ No newline at end of file
var xpath = '(' + this.xPathForItemAtIndex(index) + '//input[@type="text"]' + '|' +
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