work on browserstack info, removed column for law engine
parent
dbbb36132c
commit
5ae870f267
|
@ -95,8 +95,106 @@
|
|||
});
|
||||
}
|
||||
|
||||
function getBrowserStackData() {
|
||||
var queryParams1 = [
|
||||
'type=builds'
|
||||
];
|
||||
|
||||
var queryParams2 = [
|
||||
'type=buildSessions'
|
||||
];
|
||||
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: 'http://localhost:3001/browserstack_php.php' + '?' + queryParams1.join('&')
|
||||
}).then(function (data) {
|
||||
queryParams2.push('buildId=' + data.data.results[0].automation_build.hashed_id);
|
||||
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: 'http://localhost:3001/browserstack_php.php' + '?' + queryParams2.join('&')
|
||||
}).then(function (response) {
|
||||
$scope.behatResults = {
|
||||
failed: 0,
|
||||
passed: 0,
|
||||
windows: {
|
||||
chrome: {
|
||||
name: 'Chrome',
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
percentage: 0
|
||||
},
|
||||
firefox: {
|
||||
name: 'Firefox',
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
percentage: 0
|
||||
},
|
||||
ie: {
|
||||
name: 'Internet Explorer',
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
percentage: 0
|
||||
},
|
||||
edge: {
|
||||
name: 'Microsoft Edge',
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
percentage: 0
|
||||
}
|
||||
},
|
||||
mac: {
|
||||
chrome: {
|
||||
name: 'Chrome',
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
percentage: 0
|
||||
},
|
||||
firefox: {
|
||||
name: 'Firefox',
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
percentage: 0
|
||||
},
|
||||
safari: {
|
||||
name: 'Safari',
|
||||
passed: 0,
|
||||
failed: 0,
|
||||
percentage: 0
|
||||
}
|
||||
}
|
||||
};
|
||||
function calcPercentage(browser) {
|
||||
$scope.behatResults.windows[browser].percentage = (($scope.behatResults.windows[browser].passed / ($scope.behatResults.windows[browser].passed + $scope.behatResults.windows[browser].failed)) * 100).toFixed(2);
|
||||
}
|
||||
|
||||
function browserTestLog(test, status) {
|
||||
if (test.os === 'Windows') {
|
||||
$scope.behatResults.windows[test.browser][status] += 1;
|
||||
|
||||
calcPercentage(test.browser);
|
||||
}
|
||||
}
|
||||
|
||||
response.data.results.forEach(function (test) {
|
||||
var session = test.automation_session;
|
||||
|
||||
if ((session.status === 'done' && session.reason === 'UI_STOPPED') || session.status === 'passed') {
|
||||
$scope.behatResults.passed += 1;
|
||||
browserTestLog(session, 'passed')
|
||||
} else if (session.status !== 'running') {
|
||||
$scope.behatResults.failed += 1;
|
||||
browserTestLog(session, 'failed')
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$interval(getPivotalStories, 120000);
|
||||
$interval(getBrowserStackData, 300000);
|
||||
getPivotalStories();
|
||||
getBrowserStackData();
|
||||
}
|
||||
|
||||
})();
|
|
@ -47,17 +47,24 @@
|
|||
}).then(function (response) {
|
||||
getPivotalStories().then(function (data) {
|
||||
$scope.workInProgress = [];
|
||||
users = response.data;
|
||||
users = {};
|
||||
stories = data.data;
|
||||
|
||||
users.forEach(function (user) {
|
||||
response.data.forEach(function (user) {
|
||||
var items = $filter('filter')(stories, {owned_by_id: user.person.id});
|
||||
|
||||
items.forEach(function (ignore, index) {
|
||||
items[index].owner = user.person;
|
||||
users[user.person.id] = user.person;
|
||||
});
|
||||
|
||||
|
||||
stories.forEach(function (story, index) {
|
||||
story.owners = [];
|
||||
|
||||
story.owner_ids.forEach(function (ownerId) {
|
||||
story.owners.push(users[ownerId]);
|
||||
});
|
||||
|
||||
$scope.workInProgress = $scope.workInProgress.concat(items);
|
||||
$scope.workInProgress.push(story);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="row">
|
||||
<div class="col-md-6" ng-controller="chartJs1DCtrl">
|
||||
<div class="col-md-8" ng-controller="chartJs1DCtrl">
|
||||
<div ba-panel ba-panel-title="Current Sprint" ba-panel-class="with-scroll ">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
@ -16,23 +16,60 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3" ng-controller="chartJs2DCtrl">
|
||||
<div ba-panel ba-panel-title="Polar" ba-panel-class="with-scroll ">
|
||||
<div class="chartjs-canvas-holder-first-row">
|
||||
<canvas id="polar-area" class="chart chart-polar-area"
|
||||
chart-data="data" chart-options="options" chart-labels="labels"
|
||||
chart-click="changeData">
|
||||
</canvas>
|
||||
<div ba-panel ba-panel-title="Behat results" ba-panel-class="with-scroll">
|
||||
<div class="row">
|
||||
<div class="col-md-1"></div>
|
||||
<div class="col-md-5">
|
||||
<div style="background: red; border-radius: 8px; color: white; padding: 24px 48px; box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.25)">
|
||||
<p style="margin-bottom: 24px;">Failed</p>
|
||||
<h1 style="text-align: right; margin-bottom: 0px;">{{behatResults.failed}}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div style="background: lightgreen; border-radius: 8px; padding: 24px 48px; box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.25)">
|
||||
<p style="margin-bottom: 24px;">Passed</p>
|
||||
<h1 style="text-align: right; margin-bottom: 0px;">{{behatResults.passed}}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1"></div>
|
||||
</div>
|
||||
|
||||
<hr style="margin: 30px 8%;"/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-1"></div>
|
||||
<div class="col-md-5">
|
||||
<h4>Windows</h4>
|
||||
|
||||
<div data-ng-repeat="(browser, results) in behatResults.windows" style="padding: 6px; border-radius: 4px; margin-bottom: 3px;" data-ng-style="results.percentage === 100 ? {background: 'green'} : {background: 'red'}">
|
||||
<ul style="margin-bottom: 0; padding-left: 24px;">
|
||||
<li>
|
||||
<span>{{results.name}}</span><span style="float: right;">{{results.percentage}}%</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<h4>Mac</h4>
|
||||
|
||||
<div data-ng-repeat="(browser, results) in behatResults.mac" style="padding: 6px; border-radius: 4px; margin-bottom: 3px;" data-ng-style="results.percentage === 100 ? {background: 'green'} : {background: 'red'}">
|
||||
<ul style="margin-bottom: 0; padding-left: 24px;">
|
||||
<li>
|
||||
<span>{{results.name}}</span><span style="float: right;">{{results.percentage}}%</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3" ng-controller="chartJs3DCtrl">
|
||||
<div class="col-md-4" ng-controller="chartJs3DCtrl">
|
||||
<div ba-panel ba-panel-title="Work in progress" ba-panel-class="with-scroll ">
|
||||
<div class="item" data-ng-repeat="story in workInProgress track by $index" style="border-bottom: 1px solid #E6EAEE; margin-bottom: 6px;">
|
||||
<div style="font-weight: 600;"><span>{{story.owner.name}}</span> <span style="float: right;">#{{story.id}}</span></div>
|
||||
<div style="font-weight: 600;"><span data-ng-repeat="owner in story.owners" class="list-of-words">{{owner.name}}</span> <span style="float: right;">#{{story.id}}</span></div>
|
||||
<p style="padding-top: 3px;">{{story.name}}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
class HTTP_Request_Helper {
|
||||
|
||||
public static function request($method, $request_url, $data = NULL, $headers = array(), $followRedirected = FALSE)
|
||||
{
|
||||
$returnValue = FALSE;
|
||||
|
||||
if ($cURL = curl_init()) {
|
||||
|
||||
curl_setopt($cURL, CURLOPT_CUSTOMREQUEST, mb_strtoupper($method));
|
||||
curl_setopt($cURL, CURLOPT_HEADER, TRUE);
|
||||
curl_setopt($cURL, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($cURL, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
|
||||
curl_setopt($cURL, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($cURL, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
|
||||
if (in_array(mb_strtoupper($method), array('PATCH', 'POST', 'PUT')) && !empty($data)) {
|
||||
curl_setopt($cURL, CURLOPT_POSTFIELDS, $data);
|
||||
}
|
||||
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
curl_setopt($cURL, CURLOPT_URL, $request_url);
|
||||
if ($followRedirected) {
|
||||
curl_setopt($cURL, CURLOPT_FOLLOWLOCATION, TRUE);
|
||||
} else {
|
||||
curl_setopt($cURL, CURLOPT_FOLLOWLOCATION, FALSE);
|
||||
}
|
||||
|
||||
if (defined('DISABLE_SSL_SECURITY_FOR_TESTING') && DISABLE_SSL_SECURITY_FOR_TESTING) {
|
||||
curl_setopt($cURL, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
}
|
||||
|
||||
if ($response = curl_exec($cURL)) {
|
||||
|
||||
list($responseHeaders, $responseBody) = explode("\r\n\r\n", $response, 2);
|
||||
$returnValue['status'] = curl_getinfo($cURL, CURLINFO_HTTP_CODE);
|
||||
$tmpHeaders = explode("\r\n", $responseHeaders);
|
||||
$returnValue['headers'] = array();
|
||||
foreach ($tmpHeaders AS $str) {
|
||||
if (!preg_match('/^HTTP\\//u', $str)) {
|
||||
list($Key, $value) = explode(': ', $str, 2);
|
||||
$returnValue['headers'][$Key] = $value;
|
||||
}
|
||||
}
|
||||
$returnValue['body'] = $responseBody;
|
||||
}
|
||||
|
||||
curl_close($cURL);
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
class BrowserStackAPI_Helper
|
||||
{
|
||||
protected $apiRoot = 'https://www.browserstack.com/';
|
||||
|
||||
protected $token = NULL;
|
||||
|
||||
public function setAccessToken($token) {
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
public function get($request_uri, $data = NULL, $headers = array(), $parse_body = TRUE)
|
||||
{
|
||||
return self::request('GET', $request_uri, $data, $headers, $parse_body);
|
||||
}
|
||||
|
||||
private function request($method, $request_uri, $data = NULL, $headers = array(), $parse_body = TRUE)
|
||||
{
|
||||
if (NULL !== $this->token) {
|
||||
$headers[] = 'Authorization: Basic ' . $this->token;
|
||||
}
|
||||
|
||||
// Force to JSON for now - ideally this needs to look at the current Output::$outputFormat to ensure returned data is consistent
|
||||
$headers[] = 'Accept: application/json';
|
||||
return self::makeRequest($method, $request_uri, $data, $headers, $parse_body);
|
||||
}
|
||||
|
||||
private function makeRequest($method, $request_uri, $data = NULL, $headers = array(), $parse_body = TRUE)
|
||||
{
|
||||
$returnValue = FALSE;
|
||||
|
||||
$request_url = $this->apiRoot . ltrim($request_uri, '/');
|
||||
|
||||
$response = HTTP_Request_Helper::request($method, $request_url, $data, $headers);
|
||||
|
||||
if (FALSE !== $response) {
|
||||
$returnValue = array();
|
||||
$returnValue['status'] = $response['status'];
|
||||
$returnValue['headers'] = $response['headers'];
|
||||
$returnValue['body'] = json_decode($response['body'], TRUE);
|
||||
} else {
|
||||
$returnValue = array();
|
||||
$returnValue['status'] = 504;
|
||||
$returnValue['headers'] = array();
|
||||
$returnValue['body'] = '';
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
class BrowserStackClient extends BrowserStackAPI_Helper
|
||||
{
|
||||
|
||||
public function __construct($username, $password)
|
||||
{
|
||||
$token = $this->generateToken($username, $password);
|
||||
$this->setAccessToken($token);
|
||||
}
|
||||
|
||||
public function buildSessions($buildId)
|
||||
{
|
||||
return $this->get('automate/builds/' . $buildId . '/sessions.json');
|
||||
}
|
||||
|
||||
public function builds()
|
||||
{
|
||||
return $this->get('automate/builds.json');
|
||||
}
|
||||
|
||||
private function generateToken($user, $password)
|
||||
{
|
||||
return base64_encode($user . ':' . $password);
|
||||
}
|
||||
}
|
||||
|
||||
$user = 'danneh1';
|
||||
$password = '5gXqwjkDjBtTiLVmvsLV';
|
||||
$browserStackClient = new BrowserStackClient($user, $password);
|
||||
|
||||
$buildId = '7ecd9b26fd193d25102ef8e45acad32b02127615';
|
||||
|
||||
if ($_GET['type'] == 'builds') {
|
||||
$response = $browserStackClient->builds();
|
||||
if (isset($response['body']) && is_array($response['body'])) {
|
||||
echo json_encode(['results' => $response['body']]);
|
||||
} else {
|
||||
echo json_encode(['errors' => ['No results found for builds.']]);
|
||||
}
|
||||
} else if (isset($_GET['type']) && $_GET['type'] == 'buildSessions' && isset($_GET['buildId'])) {
|
||||
$buildId = $_GET['buildId'];
|
||||
$response = $browserStackClient->buildSessions($buildId);
|
||||
|
||||
if (isset($response['body']) && is_array($response['body'])) {
|
||||
echo json_encode(['results' => $response['body']]);
|
||||
} else {
|
||||
if (!$buildId) {
|
||||
echo json_encode(['errors' => ['GET parameter of buildId is required for buildSessions query.']]);
|
||||
} else {
|
||||
echo json_encode(['errors' => ['No results found for build sessions.']]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['errors' => ['GET parameter of builds of buildSessions is required.']]);
|
||||
}
|
||||
?>
|
|
@ -20,4 +20,8 @@
|
|||
|
||||
.blurCalendar{
|
||||
height: 475px;
|
||||
}
|
||||
|
||||
.list-of-words:not(:nth-last-child(2)):after {
|
||||
content: ", ";
|
||||
}
|
Loading…
Reference in New Issue