Compare commits

...

11 Commits

Author SHA1 Message Date
f198f0f178 [Tests] Test OK/Cancel part of Create flow 2016-03-02 15:28:43 -08:00
d54ad1a726 [Tests] Move to single Create spec 2016-03-02 12:19:05 -08:00
1614412b17 [Tests] Check for dialog 2016-03-02 12:17:44 -08:00
22ce35b98b [Tests] Add template for Create specs 2016-03-02 11:59:28 -08:00
47fc3af5f2 [Tests] Fix Create choose-and-click 2016-03-01 16:28:47 -08:00
57f462b98a [Tests] Begin updating specs 2016-03-01 16:21:44 -08:00
d45f52bdb9 [Tests] Remove obsolete protractor scripts
...as responsibility for running protractor has been moved
to gulp tasks.
2016-03-01 15:50:19 -08:00
4eaedcba2f [Tests] Run web server for tests 2016-03-01 15:48:54 -08:00
fd45e4e895 [Tests] Add task for protractor 2016-03-01 15:32:14 -08:00
c0e758ac76 [Tests] Use 1.0.0 of gulp-protractor
...to avoid forcing upgrade to node 4
2016-03-01 15:13:14 -08:00
282058f4c2 [Tests] Add gulp-protractor dependency
...to begin integrating functional test suite into the
build, #348.
2016-03-01 15:03:40 -08:00
14 changed files with 159 additions and 350 deletions

View File

@ -31,6 +31,9 @@ var gulp = require('gulp'),
jscs = require('gulp-jscs'),
replace = require('gulp-replace-task'),
karma = require('karma'),
protractor = require('gulp-protractor').protractor,
webdriver_update = require('gulp-protractor').webdriver_update,
connect = require('gulp-connect'),
path = require('path'),
fs = require('fs'),
git = require('git-rev-sync'),
@ -47,7 +50,8 @@ var gulp = require('gulp'),
'platform/**/*',
'example/**/*',
'bower_components/**/*'
]
],
protractor: './protractor/**/*Spec.js'
},
options = {
requirejsOptimize: {
@ -69,6 +73,13 @@ var gulp = require('gulp'),
revision: fs.existsSync('.git') ? git.long() : 'Unknown',
branch: fs.existsSync('.git') ? git.branch() : 'Unknown'
}
},
protractor: {
configFile: 'protractor/conf.js',
args: [ '--baseUrl', 'localhost:8080' ]
},
connect: {
root: paths.dist
}
};
@ -85,6 +96,20 @@ gulp.task('test', function (done) {
new karma.Server(options.karma, done).start();
});
gulp.task('webdriver_update', webdriver_update);
gulp.task('protractor', ['webdriver_update', 'install'], function () {
connect.server(options.connect);
return gulp.src(paths.protractor)
.pipe(protractor(options.protractor))
.on('end', connect.serverClose.bind(connect))
.on('error', function (err) {
connect.serverClose();
throw err;
});
});
gulp.task('stylesheets', function () {
return gulp.src(paths.scss, {base: '.'})
.pipe(sourcemaps.init())

View File

@ -12,8 +12,10 @@
"git-rev-sync": "^1.4.0",
"glob": ">= 3.0.0",
"gulp": "^3.9.0",
"gulp-connect": "^3.1.0",
"gulp-jscs": "^3.0.2",
"gulp-jshint": "^2.0.0",
"gulp-protractor": "^1.0.0",
"gulp-rename": "^1.2.2",
"gulp-replace-task": "^0.11.0",
"gulp-requirejs-optimize": "^0.3.1",

View File

@ -1,15 +0,0 @@
#! /usr/bin/env node
var shell = require("shelljs/global");
var startdir = process.cwd();
var command = "npm unlink";
console.log("Cleaning Directory")
exec(command, function(code, output) {
if(code != 0){
console.log('Exit code:', code);
console.log('Program output:', output);
}
});
console.log("rm -rf node_modules")
rm('-rf', __dirname + "/../node_modules")

View File

@ -1,90 +0,0 @@
#! /bin/bash
ARGUMENT=$1;
if [ $# != 1 ]; then
echo "Expected 1 Aurgument. Received " $# 1>&2;
exit 1
fi
#Start webdrive and http-server
if [ $ARGUMENT == start ]; then
echo "Creating Log Directory ..."
mkdir logs;
cd ..
node app.js -p 1984 -x platform/persistence/elastic -i example/persistence > protractor/logs/nodeApp.log 2>&1 &
sleep 3;
if grep -iq "Error" protractor/logs/nodeApp.log; then
if grep -iq "minimist" protractor/logs/nodeApp.log; then
echo " Node Failed Because Minimist is not installed"
echo " Installng Minimist ..."
npm install minimist express > protractor/logs/minimist.log 2>&1 &
wait $!
if [ $? != 0 ]; then
echo " Error: minimist"
echo " Check Log file"
echo
else
echo " Started: Minimist"
echo
node app.js -p 1984 -x platform/persistence/elastic -i example/persistence > protractor/logs/nodeApp.log 2>&1 &
if grep -iq "Error" protractor/logs/nodeApp.log; then
echo " Error: node app failed"
echo " Check Log file"
echo
else
echo " Started: node app.js"
echo
fi
fi
else
echo " Error: node app failed"
echo " Check Log file"
echo
fi
else
echo " Started: node app.js"
echo
fi
echo "Starting webdriver ..."
cd protractor;
webdriver-manager start > logs/webdriver.log 2>&1 &
sleep 3;
if grep -iq "Exception" logs/webdriver.log; then
echo " Error: webdriver-manager"
echo " Check Log file"
echo
else
echo " Started: webdriver-manager"
fi
echo "Starting Elastic Search..."
elasticsearch > logs/elasticSearch.log 2>&1 &
sleep 3;
if grep -iq "Exception" logs/elasticSearch.log; then
echo " Error: ElasticSearch"
echo " Check Log file"
echo
else
echo " Started: ElasticSearch"
fi
#Runs Protractor tests
elif [ $ARGUMENT == run ]; then
protractor ./conf.js
#Kill Process
elif [ $ARGUMENT == stop ]; then
echo "Removing logs"
rm -rf logs
echo "Stopping Node"
kill $(ps aux | grep "[n]ode app.js"| awk '{print $2}');
echo "Stopping webdriver ..."
kill $(ps aux | grep "[p]rotractor" | awk '{print $2}');
kill $(ps aux | grep "[w]ebdriver-manager" | awk '{print $2}');
sleep 1;
echo "Stopping Elastic..."
kill $(ps aux | grep "[e]lastic" | awk '{print $2}');
sleep 1;
else
echo "Unkown: Command" $1;
fi

View File

@ -1,12 +0,0 @@
#! /usr/bin/env node
var shell = require("shelljs/global");
var sleep = require('sleep');
var command = __dirname + "/../node_modules/protractor/bin/protractor " +__dirname + "/../conf.js";
console.log("Executing Protractor Test")
exec(command, function(code, output) {
if(code != 0){
console.log('Exit code:', code);
console.log('Program output:', output);
}
});

View File

@ -1,40 +0,0 @@
#! /usr/bin/env node
var shell,sleep;
try {
shell = require("shelljs/global");
sleep = require('sleep');
}catch (e){
console.log("Dependencies Error");
console.log("Run npm install");
throw (e);
}
///Users/jsanderf/git/elastic/wtd/protractor/bin
var startdir = process.cwd();
var command;
mkdir(__dirname + '/../logs');
command = __dirname + "/../node_modules/protractor/bin/webdriver-manager update";
console.log("Installing Webdriver");
exec(command,{async:false});
sleep.sleep(1);
console.log();
cd(__dirname + '/../../');
console.log('Installing Dependencies');
exec("npm install minimist express", {async:false});
console.log('Starting Node');
sleep.sleep(1);
exec("node app.js -p 1984 -x example/persistence -x platform/persistence/elastic -i example/localstorage > protractor/logs/nodeApp.log 2>&1 &", {async:false});
console.log(' Started Node');
console.log();
console.log('Starting Webdriver');
sleep.sleep(1);
exec("protractor/node_modules/protractor/bin/webdriver-manager start --standalone> protractor/logs/webdriver.log 2>&1 &",{async:false});
if(error() == null){
console.log(" Webdriver Started");
}else{
console.log(" Error : ", error());
}
sleep.sleep(1);
cd(startdir);

View File

@ -1,44 +0,0 @@
#! /usr/bin/env node
var shell = require("shelljs/global");
var ps = require('psnode');
var S = require('string');
var sleep = require('sleep');
// A simple pid lookup
ps.list(function(err, results) {
results.forEach(function( process ){
//Killing Node
if(S(process.command).contains("node app.js")) {
console.log();
console.log( 'Killing Node: %s', process.command);
ps.kill(process.pid, function(err, stdout) {
if (err) {
throw new Error(err);
}
console.log(stdout);
});
}else if(S(process.command).contains("webdriver")) {
console.log();
console.log( 'Killing WebDriver: %s', process.command);
ps.kill(process.pid, function(err, stdout) {
if (err){
throw new Error(err);
}
console.log(stdout);
});
}else if(S(process.command).contains("protractor")) {
console.log();
console.log( 'Killing Chrome Drive: %s', process.command);
ps.kill(process.pid, function(err, stdout) {
if (err){
throw new Error(err);
}
console.log(stdout);
});
}
});
});

View File

@ -24,6 +24,6 @@
module.exports = function launch() {
'use strict';
browser.ignoreSynchronization = true;
browser.get('http://localhost:1984');
browser.get('http://localhost:8080/index.html');
browser.sleep(2000); // 2 seconds
};

View File

@ -0,0 +1,23 @@
/*global module,element,by,browser*/
module.exports = function create(name) {
var createButton = element.all(
by.css('[ng-click="createController.toggle()"]')
);
createButton.click();
return browser.wait(function () {
return element(by.css('[ng-click="createAction.perform()"]'))
.isPresent();
}, 1000)
.then(function () {
return element.all(by.css('[ng-click="createAction.perform()"]'))
.filter(function (el) {
return el.getText().then(function (text) {
return text.indexOf(name) > -1;
});
})
.click();
});
};

View File

@ -25,38 +25,11 @@
exports.config = {
allScriptsTimeout: 500000,
jasmineNodeOpts: {defaultTimeoutInterval: 360000},
seleniumAddress: 'http://localhost:4444/wd/hub',
//specs: ['StressTestCarrot.js'],
specs: [
// 'create/CreateActivity.js',
// 'delete/DeleteActivity.js',
// 'create/CreateActivityMode.js',
// 'delete/DeleteActivityMode.js',
// 'create/CreateClock.js',
// 'delete/DeleteClock.js',
'create/CreateDisplay.js',
'delete/DeleteDisplay.js',
'create/CreateFolder.js',
'delete/DeleteFolder.js',
// 'create/CreateTelemetry.js',
// 'delete/DeleteTelemetry.js',
// 'create/CreateTimeline.js',
// 'delete/DeleteTimeline.js',
// 'create/CreateTimer.js',
// 'delete/DeleteTimer.js',
'create/CreateWebPage.js',
'delete/DeleteWebPage.js',
'UI/Fullscreen.js',
'create/CreateButton.js',
//"UI/DragDrop.js",
"UI/NewWindow.js"
//'UI/InfoBubble.js',
//'UI/RightClick.js'
],
capabilities: {
'browserName': 'chrome', // or 'safari'
'chromeOptions': {}
}
},
seleniumServerJar: "../node_modules/gulp-protractor/node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar"
};
// Allow specifying binary location as an environment variable,

View File

@ -1,58 +0,0 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
var itemCreate = require("../common/CreateItem");
var itemEdit = require("../common/EditItem");
describe('Create Display', function() {
var createClass = new itemCreate();
var editItemClass = new itemEdit();
var ITEM_NAME = "Display";
var ITEM_TYPE = "display";
var ITEM_MENU_GLYPH = 'L\nDisplay Layout';
var ITEM_GRID_SELECT = 'P\nL\nDisplay\n0 Items';
beforeEach(require('../common/Launch'));
it('should Create new Display', function(){
//button.click()
browser.wait(function() {
createClass.createButton().click();
return true;
}).then(function (){
var folder = createClass.selectNewItem(ITEM_TYPE)
expect(folder.getText()).toEqual([ ITEM_MENU_GLYPH ]);
browser.sleep(1000);
folder.click()
}).then(function() {
browser.wait(function () {
return element.all(by.model('ngModel[field]')).isDisplayed();
})
createClass.fillFolderForum(ITEM_NAME,ITEM_TYPE).click();
browser.sleep(1000);
}).then(function (){
var item = editItemClass.SelectItem(ITEM_GRID_SELECT);
expect(item.count()).toBe(1);
browser.sleep(1000);
});
});
});

View File

@ -0,0 +1,26 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
var CreateTemplate = require('./CreateTemplate');
new CreateTemplate("Display Layout", true).describe();
new CreateTemplate("Web Page", false).describe();

View File

@ -0,0 +1,79 @@
var launch = require('../common/Launch'),
create = require('../common/create');
function CreateTemplate(name, expectEditMode) {
this.name = name;
this.expectEditMode = !!expectEditMode;
}
CreateTemplate.prototype.describe = function (nested) {
describe("Create " + this.name, function () {
beforeEach(launch);
beforeEach(create.bind(this, this.name));
it(this.expectEditMode ? "initiates Edit mode" : "does not initiate Edit mode", function () {
expect(element(by.css('.s-status-editing')).isPresent())
.toBe(this.expectEditMode);
}.bind(this));
it(!this.expectEditMode ? "shows a dialog" : "does not show a dialog", function () {
expect(element(by.css('.overlay')).isPresent())
.toBe(!this.expectEditMode);
}.bind(this));
if (this.expectEditMode) {
describe("when saved", function () {
var overlay;
beforeEach(function () {
element(by.css('.t-save')).click();
overlay = element(by.css('.overlay'));
});
it("shows a dialog", function () {
expect(overlay.isPresent()).toBe(true);
});
describe("and confirmed", function () {
beforeEach(function () {
overlay.all(by.css('.bottom-bar .s-btn'))
.filter(function (element) {
return element.getText().then(function (text) {
return text === 'OK';
});
})
.click();
});
it("dismisses the dialog", function () {
expect(element(by.css('.overlay')).isPresent())
.toBe(false);
});
});
describe("and cancelled", function () {
beforeEach(function () {
overlay.all(by.css('.bottom-bar .s-btn'))
.filter(function (element) {
return element.getText().then(function (text) {
return text === 'Cancel';
});
})
.click();
});
it("dismisses the dialog", function () {
expect(element(by.css('.overlay')).isPresent())
.toBe(false);
});
});
});
}
if (nested) {
nested();
}
}.bind(this));
};
module.exports = CreateTemplate;

View File

@ -1,60 +0,0 @@
#! /bin/bash
ARGUMENT=$1;
DIRECTORY=/Users/jsanderf/Applications;
if [ $# != 1 ]; then
echo "Expected 1 Aurgument. Received " $# 1>&2;
exit 1
fi
#Start webdrive and http-server
if [ $ARGUMENT == start ]; then
echo
echo "Starting MMAP ..."
$DIRECTORY/MAMP/ctlscript.sh start > logs/MAMP.log 2>&1 &
wait $!
if [ $? != 0 ]; then
echo " Error: MMAP"
echo " Check Log file"
echo
else
echo " Started: MMAP"
echo
fi
echo "Starting webdriver ..."
webdriver-manager start > logs/webdriver.log 2>&1 &
sleep 3;
if grep -iq "Exception" logs/webdriver.log; then
echo " Error: webdriver-manager"
echo " Check Log file"
echo
else
echo " Started: webdriver-manager"
fi
echo "Starting Elastic Search..."
elasticsearch > logs/elasticSearch.log 2>&1 &
sleep 3;
if grep -iq "Exception" logs/elasticSearch.log; then
echo " Error: ElasticSearch"
echo " Check Log file"
echo
else
echo " Started: ElasticSearch"
fi
#Runs Protractor tests
elif [ $ARGUMENT == run ]; then
protractor ./conf.js
#Kill Process
elif [ $ARGUMENT == stop ]; then
echo "Stopping MAMP"
$DIRECTORY/MAMP/ctlscript.sh stop >> logs/MAMP.log 2>&1 &
sleep 1;
echo "Stopping webdriver ..."
kill $(ps aux | grep "[p]rotractor" | awk '{print $2}');
kill $(ps aux | grep "[w]ebdriver-manager" | awk '{print $2}');
sleep 1;
echo "Stopping Elastic..."
kill $(ps aux | grep "[e]lastic" | awk '{print $2}');
sleep 1;
else
echo "Unkown: Command" $1;
fi