I write another script to help us to assign test.
There will be a tooltip shows the total sum of estimated time of the selected tests.
Then I can easily have an idea about how much the loading is I am about to assign to someone.
Here are the source:
name: Assign helper
description: Add a 'Show total sum of estimate for checked test'
author: Alston
version: 1.0
includes: ^runs/view/
excludes:
js:
var TestData = [];
function ConvertToSecond (value)
{
var values = value.split(" ")
var time = 0;
var patt = new RegExp(/\d/);
var num = 0;
var measure;
for (var i = 0; i < values.length; i++) {
patt = /\d+/;
num = patt.exec(values[i]);
patt = /\D+/;
measure = patt.exec(values[i]);
switch(measure[0]) {
case "d":
time = time + num * 8 * 60 * 60;
break;
case "h":
time = time + num * 60 * 60;
break;
case "m":
time = time + num * 60;
break;
case "s":
time = time + num * 1;
break;
}
}
return time;
}
function Calculate (boxes, data)
{
var nEstimate = 0;
for (var i = 0; i < data.length; i++)
{
for (var j = 0; j < boxes.length; j++)
{
if (data[i].id == boxes[j].value)
{
boxes.splice(j, 1);
if (data[i].estimate)
{
nEstimate += ConvertToSecond (data[i].estimate);
}
break;
}
}
if (boxes.length == 0)
{
break;
}
}
$("#groupContainer").prop('title', 'Selected estimate: ' + nEstimate + 's');
$("#groupContainer)").tooltip();
}
function GetTests (boxes)
{
$.ajax(
{
url: uiscripts.env.page_base + '/api/v2/get_tests/' +uiscripts.context.run.id,
dataType: 'json',
beforeSend: function(xhr)
{
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("X-Requested-With", "API Client");
},
success: function(data, status)
{
TestData = data;
Calculate (boxes, data);
console.log(data); // Contains the suite
},
error: function(error)
{
alert("GetTests Fail");
console.log(error);
}
});
}
function calculestimate()
{
var boxes = $('input.selectionCheckbox[type=checkbox]:checked');
if (TestData.length > 0)
{
Calculate (boxes, TestData);
}
else
{
GetTests (boxes);
}
}
$(document).ready(
function() {
$(document).on("change", "th.checkbox + input.selectionCheckbox", function () {
alert("test");
});
$(document).on("click", "input.selectionCheckbox" , function() {
setTimeout (calculestimate(), 50);
});
}
);
css:
div.some-class {
}