Skip to content

Commit

Permalink
Added history to actions and test cases
Browse files Browse the repository at this point in the history
Fixed a bug where test cases with same var name was not working as designed
Fixed startup to allow for long db startup
  • Loading branch information
octoocto1 committed Jul 8, 2015
1 parent b09d37f commit dfd07cb
Show file tree
Hide file tree
Showing 14 changed files with 555 additions and 51 deletions.
12 changes: 11 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ var express = require('express')
, emailsettings = require('./routes/emailsettings')
, imageautomation = require('./routes/imageautomation')
, recorder = require('./routes/recorder')
, license = require('./routes/license');
, license = require('./routes/license')
, actionHistory = require('./routes/actionHistory')
, testcaseHistory = require('./routes/testcaseHistory');


//var app = express.createServer();
Expand Down Expand Up @@ -100,6 +102,14 @@ app.post('/recordimage',auth.auth,imageautomation.recordImage);
app.get('/image/:id',auth.auth,imageautomation.getImage);
app.post('/recordedimage',imageautomation.recordedImage);

//test case history
app.get('/testcasehistory/:id',auth.auth,testcaseHistory.historyGet);
app.post('/testcasehistory',auth.auth,testcaseHistory.historyPost);

//action history
app.get('/actionhistory/:id',auth.auth,actionHistory.historyGet);
app.post('/actionhistory',auth.auth,actionHistory.historyPost);

//uploadFiles
app.post('/uploadfiles',auth.auth,uploadFiles.uploadFiles);
app.post('/uploadfromagent',uploadFiles.uploadFromAgent);
Expand Down
2 changes: 1 addition & 1 deletion appWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ common.parseConfig(function(){
var dbStarted = false;
var dbOut = "";

appChild.start();
dbChild.on('stdout', function (data) {
if (dbStarted == false){
dbOut = dbOut + data.toString();
if (dbOut.indexOf("waiting for connections on port") != -1){
dbStarted = true;
appChild.start();
//setTimeout(function(){
// fs.writeFileSync(__dirname+"/app.pid",process.pid+"\r\n"+dbChild.child.pid +"\r\n"+appChild.child.pid);
//},10000);
Expand Down
6 changes: 4 additions & 2 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ exports.parseConfig = function(callback){
});

//find .NET location
setNETLocation(function(){});
setNETLocation(function(){
console.log("Aga");
});
};

exports.setNETLocation = function(callback){setNETLocation(callback)};
Expand Down Expand Up @@ -73,7 +75,7 @@ exports.initDB = function(port,callback){
Server = mongo.Server,
Db = mongo.Db;

var dbRetry = 120;
var dbRetry = 420;
var connect = function(){
var dbServer = new Server('localhost', parseInt(port), {auto_reconnect: true,safe:true});
db = new Db('automationframework', dbServer);
Expand Down
43 changes: 38 additions & 5 deletions public/controller/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ function openAction(id){
}
}

function openActionHistory(actionID,historyID){
var store = Ext.data.StoreManager.lookup('ActionHistoryStore'+actionID);
var tab = Ext.ComponentQuery.query("#mainTabPanel")[0];
tab.setActiveTab(tab.down("#actionsBrowser"));
var controller = Redwood.app.getController("Actions");
var record = store.query("_id",historyID).get(0);
//flag this as a history test case
record.set("history",true);
controller.onEditAction(record);
if(Ext.isChrome){
return false;
}
}

Ext.define("Redwood.controller.Actions", {
extend: 'Ext.app.Controller',

Expand All @@ -29,6 +43,20 @@ Ext.define("Redwood.controller.Actions", {
});
},

onRevert: function(historyID){
Ext.Ajax.request({
url:"/actionhistory",
method:"POST",
jsonData : {id:historyID},
success: function(response) {
var obj = Ext.decode(response.responseText);
if(obj.error){
Ext.Msg.alert('Error', obj.error);
}
}
});
},

onCloneAction:function(){
var actionView = this.tabPanel.getActiveTab();
var me = this;
Expand Down Expand Up @@ -85,11 +113,16 @@ Ext.define("Redwood.controller.Actions", {
});
},
onEditAction: function(record,collapse){
var foundIndex = this.tabPanel.items.findIndex("title",new RegExp("^"+record.get("name")+"$"),0,false,true);
var name = record.get("name");
if(record.get("history") == true){
name = "[HISTORY " + Ext.Date.format(record.get("date"),"m/d h:i:s") + "] "+name;
}

var foundIndex = this.tabPanel.items.findIndex("title",new RegExp("^"+name+"$"),0,false,true);
if (foundIndex == -1){
//foundIndex = this.tabPanel.items.findIndex("title",new RegExp("^"+record.get("name")+"\\*$"),0,false,true);
foundIndex = this.tabPanel.items.findIndexBy(function(item,key){
if(key == record.get("name")){
if(key == name){
return true;
}
else{
Expand All @@ -99,16 +132,16 @@ Ext.define("Redwood.controller.Actions", {
}
if (foundIndex == -1){
var tab = Ext.create('Redwood.view.ActionView',{
title:record.get("name"),
title:name,
closable:true,
dataRecord:record,
itemId:record.get("name")
itemId:name
});

this.tabPanel.add(tab);
//foundIndex = this.tabPanel.items.findIndex("title",new RegExp("^"+record.get("name")+"$"),0,false,true);
foundIndex = this.tabPanel.items.findIndexBy(function(item,key){
if(key == record.get("name")){
if(key == name){
return true;
}
else{
Expand Down
45 changes: 40 additions & 5 deletions public/controller/TestCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ function openTestCase(id){
}
}

function openTestCaseHistory(testcaseID,historyID){
var store = Ext.data.StoreManager.lookup('TCHistoryStore'+testcaseID);
var tab = Ext.ComponentQuery.query("#mainTabPanel")[0];
tab.setActiveTab(tab.down("#testcasesBrowser"));
var controller = Redwood.app.getController("TestCases");
var record = store.query("_id",historyID).get(0);
//flag this as a history test case
record.set("history",true);
controller.onEditTestCase(record);
if(Ext.isChrome){
return false;
}
}


Ext.define("Redwood.controller.TestCases", {
extend: 'Ext.app.Controller',
Expand All @@ -31,6 +45,20 @@ Ext.define("Redwood.controller.TestCases", {
});
},

onRevert: function(historyID){
Ext.Ajax.request({
url:"/testcasehistory",
method:"POST",
jsonData : {id:historyID},
success: function(response) {
var obj = Ext.decode(response.responseText);
if(obj.error){
Ext.Msg.alert('Error', obj.error);
}
}
});
},

onRecordTestCase:function(){
var testcaseView = this.tabPanel.getActiveTab();
var me = this;
Expand Down Expand Up @@ -99,12 +127,16 @@ Ext.define("Redwood.controller.TestCases", {
});
},
onEditTestCase: function(record,collapse){
var foundIndex = this.tabPanel.items.findIndex("title",new RegExp("^"+record.get("name")+"$"),0,false,true);
var name = record.get("name");
if(record.get("history") == true){
name = "[HISTORY " + Ext.Date.format(record.get("date"),"m/d h:i:s") + "] "+name;
}
var foundIndex = this.tabPanel.items.findIndex("title",new RegExp("^"+name+"$"),0,false,true);
//try again with the star
if (foundIndex == -1){
//foundIndex = this.tabPanel.items.findIndex("title",new RegExp("^"+record.get("name")+"\\*$"),0,false,true);
foundIndex = this.tabPanel.items.findIndexBy(function(item,key){
if(key == record.get("name")){
if(key == name){
return true;
}
else{
Expand All @@ -114,17 +146,17 @@ Ext.define("Redwood.controller.TestCases", {
}
if (foundIndex == -1){
var tab = Ext.create('Redwood.view.TestCaseView',{
title:record.get("name"),
title:name,
closable:true,
dataRecord:record,
itemId:record.get("name")
itemId:name
});

this.tabPanel.add(tab);

//foundIndex = this.tabPanel.items.findIndex("title",new RegExp("^"+record.get("name")+"$"),0,false,true);
foundIndex = this.tabPanel.items.findIndexBy(function(item,key){
if(key == record.get("name")){
if(key == name){
return true;
}
else{
Expand All @@ -148,6 +180,9 @@ Ext.define("Redwood.controller.TestCases", {
if (testcaseView.validate(this.getStore('TestCases')) === false){
return;
}
if (testcaseView.dataRecord !== null && testcaseView.dataRecord.get("history") == true){
return;
}
var lastScrollPos = testcaseView.getEl().dom.children[0].scrollTop;
var testcase = testcaseView.getTestCaseData();
if (testcaseView.dataRecord === null){
Expand Down
Binary file added public/images/undo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions public/view/ActionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,23 @@ Ext.define('Redwood.view.ActionView', {
}
]
},
{
xtype: 'fieldset',
title: 'History',
defaultType: 'textfield',
itemId: "actionHistory",
flex: 1,
hidden:false,
collapsible: true,
collapsed:true,
//layout: "column",
defaults: {
flex: 1
},
items: [

]
},
/*
{
Expand Down Expand Up @@ -537,6 +554,93 @@ Ext.define('Redwood.view.ActionView', {

me.down("actioncollection").loadCollection(me.dataRecord.get("collection"));

me.historyStore = Ext.create('Ext.data.Store', {
model: 'Redwood.model.Actions',
autoLoad: true,
storeId: "ActionHistoryStore"+me.dataRecord.get("_id"),
idProperty: '_id',
proxy: {
type: 'rest',
url: '/actionhistory/'+me.dataRecord.get("_id"),
reader: {
type: 'json',
root: 'actions',
successProperty: 'success'
}
},
sorters: [{
property : 'date',
direction: 'DESC'
}]
});

//add history specific fields
me.historyStore.model.prototype.fields.add(new Ext.data.Field({ name: 'user', type: 'string'}));
me.historyStore.model.prototype.fields.add(new Ext.data.Field({ name: 'date', type: 'date'}));
me.historyGrid = Ext.create('Ext.grid.Panel', {
store: me.historyStore,
itemId:"historyGrid",
selType: 'rowmodel',
height:200,
overflowY: 'auto',
viewConfig: {
markDirty: false,
enableTextSelection: true
},
plugins: [
"bufferedrenderer"],
columns:[
{
xtype:"datecolumn",
format:'m/d h:i:s',
header: 'Date',
dataIndex: 'date',
width: 120
},
{
header: 'UserID',
dataIndex: 'user',
width: 180
},
{
header: 'Previous Version',
dataIndex: '_id',
renderer: function(value,meta,record){
//meta.tdCls = 'x-redwood-results-cell';
return "<a style= 'color:font-weight:bold;blue;' href='javascript:openActionHistory(&quot;"+ me.dataRecord.get("_id") +"&quot;,&quot;" + value + "&quot;)'>View Test Case</a>"
}
},
{
xtype: 'actioncolumn',
icon: 'images/undo.png',
width: 40,
tooltip: 'Revert to this version.',
handler: function (grid, rowIndex, colIndex) {
Ext.Msg.show({
title: 'Revert to version.',
msg: 'Are you sure you want to revert action to this version?',
buttons: Ext.Msg.YESNO,
icon: Ext.Msg.QUESTION,
fn: function (id) {
if (id == "yes") {
var controller = Redwood.app.getController("Actions");
controller.onRevert(grid.store.getAt(rowIndex).get("_id"));
me.close();
}
}
});
}
}
]

});
if(me.dataRecord.get("history") == true){
me.down("#actionHistory").hide();
}
else{
me.down("#actionHistory").items.add(me.historyGrid);
}

}
else{
me.down("actioncollection").loadCollection("");
Expand Down
1 change: 1 addition & 0 deletions public/view/ExecutionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,7 @@ Ext.define('Redwood.view.ExecutionView', {
var testcasesStore = this.down("#executionTestcases").store;

execution.testcases = [];
//testcasesStore.query("name",/.*/).each(function(item){
testcasesStore.query("_id",/.*/).each(function(item){
execution.testcases.push(item.data);
});
Expand Down
Loading

0 comments on commit dfd07cb

Please sign in to comment.