Skip to content

Commit d800c07

Browse files
Merge branch 'reports' of https://github.com/testsigmahq/testsigma into reports
2 parents 77eb3ab + a5215cf commit d800c07

File tree

11 files changed

+214
-11
lines changed

11 files changed

+214
-11
lines changed

server/src/main/java/com/testsigma/controller/ReportsController.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
import com.fasterxml.jackson.core.type.TypeReference;
1313
import com.fasterxml.jackson.databind.ObjectMapper;
14-
import com.testsigma.dto.ElementDTO;
15-
import com.testsigma.dto.TestCaseDTO;
14+
import com.testsigma.dto.*;
1615
import com.testsigma.exception.ResourceNotFoundException;
1716
import com.testsigma.exception.TestsigmaDatabaseException;
1817
import com.testsigma.exception.TestsigmaException;
@@ -59,11 +58,25 @@ public ResponseEntity<Object> show(@PathVariable("id") Long id) throws Testsigma
5958
List<Map<String,Object>> entities = new ArrayList<Map<String,Object>>();
6059
for (int i=0;i<responseObject.length();i++) {
6160
Map<String, Object> result = new ObjectMapper().readValue(responseObject.getJSONObject(i).toString(), new TypeReference<Map<String, Object>>(){});
62-
// JSONObject entity = responseObject.getJSONObject(i);
6361
entities.add(result);
6462
}
6563

6664
return new ResponseEntity<>(entities, HttpStatus.OK);
6765
}
6866

67+
@GetMapping(value = {"/flaky_tests"})
68+
public List<FlakyTestsDTO> getFlakyTests(@RequestParam("versionId") Long versionId) {
69+
return this.reportsService.getFlakyTests(versionId);
70+
}
71+
72+
@GetMapping(value = {"/run_duration_trend"})
73+
public List<RunDurationTrendDTO> getRunDurationTrend(@RequestParam("versionId") Long versionId) {
74+
return this.reportsService.getRunDurationTrend(versionId);
75+
}
76+
77+
@GetMapping(value = {"/top_failures"})
78+
public List<TopFailuresDTO> getTopFailures(@RequestParam("versionId") Long versionId) {
79+
return this.reportsService.getTopFailures(versionId);
80+
}
81+
6982
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.testsigma.dto;
2+
3+
import com.testsigma.model.ResultConstant;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
7+
@Data
8+
@AllArgsConstructor
9+
public class FlakyTestsDTO {
10+
private Long id;
11+
private Long testCaseId;
12+
private Long testPlanResultId;
13+
private ResultConstant result;
14+
private String message;
15+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.testsigma.dto;
2+
3+
import com.testsigma.model.ResultConstant;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
7+
import java.sql.Timestamp;
8+
9+
@Data
10+
@AllArgsConstructor
11+
public class RunDurationTrendDTO {
12+
private Long testPlanId;
13+
private ResultConstant result;
14+
private Long duration;
15+
private String buildNo;
16+
private Timestamp createdDate;
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.testsigma.dto;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Data;
5+
6+
@Data
7+
@AllArgsConstructor
8+
public class TopFailuresDTO {
9+
Long count;
10+
String message;
11+
}

server/src/main/java/com/testsigma/repository/TestCaseRepository.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
package com.testsigma.repository;
1111

12-
import com.testsigma.dto.TestCaseStatusBreakUpDTO;
13-
import com.testsigma.dto.TestCaseTypeBreakUpDTO;
12+
import com.testsigma.dto.*;
1413
import com.testsigma.model.TestCase;
1514
import com.testsigma.model.TestCaseStatus;
1615
import org.springframework.data.domain.Page;
@@ -100,4 +99,13 @@ public interface TestCaseRepository extends PagingAndSortingRepository<TestCase,
10099
countQuery = "SELECT count(testCase.id) FROM TestCase AS testCase " +
101100
"JOIN TestStep AS testStep on testStep.stepGroupId = testCase.id " , nativeQuery= true )
102101
List<TestCase> findAllByStepGroupId(@Param("stepGroupId") Long stepGroupId);
102+
103+
@Query(value="SELECT new com.testsigma.dto.FlakyTestsDTO(id,testCaseId,testPlanResultId,result,message) from TestCaseResult where testPlanResultId in (select id from TestPlanResult where reRunParentId IS NOT NULL and testPlanId IN (select id from TestPlan where workspaceVersionId =:versionId and entityType = 'TEST_PLAN') ) or testPlanResultId in (select reRunParentId from TestPlanResult where reRunParentId IS NOT NULL and testPlanId IN (select id from TestPlan where workspaceVersionId =:versionId and entityType = 'TEST_PLAN'))")
104+
List<FlakyTestsDTO> getFlakyTests(@Param("versionId") Long versionId);
105+
106+
@Query(value="select new com.testsigma.dto.RunDurationTrendDTO(testPlanId, result, duration, buildNo, createdDate) from TestPlanResult order by createdDate")
107+
List<RunDurationTrendDTO> getRunDurationTrend(@Param("versionId") Long versionId);
108+
109+
@Query(value="select new com.testsigma.dto.TopFailuresDTO(count(id), message) from TestCaseResult where testPlanResultId in (select id from TestPlanResult where testPlanId in (select id from TestPlan where workspaceVersionId =:versionId and entityType = 'TEST_PLAN')) and result = 'FAILURE' group by message order by count(id) desc")
110+
List<TopFailuresDTO> getTopFailures(@Param("versionId") Long versionId);
103111
}

server/src/main/java/com/testsigma/service/ReportsService.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class ReportsService {
4747
private final ReportsRepository reportsRepository;
4848

4949
private final TestCaseService testCaseService;
50+
51+
private final TestCaseRepository testCaseRepository;
5052
public JSONArray getReport(Long reportId){
5153
JSONArray reportObject = new JSONArray();
5254
Optional<Report> report = reportsRepository.findById(reportId);
@@ -94,4 +96,16 @@ public String getResponseDataFromService(ReportModule reportModule, BaseSpecific
9496
}
9597
return "";
9698
}
99+
100+
public List<FlakyTestsDTO> getFlakyTests(Long versionId){
101+
return testCaseRepository.getFlakyTests(versionId);
102+
}
103+
104+
public List<RunDurationTrendDTO> getRunDurationTrend(Long versionId){
105+
return testCaseRepository.getRunDurationTrend(versionId);
106+
}
107+
108+
public List<TopFailuresDTO> getTopFailures(Long versionId){
109+
return testCaseRepository.getTopFailures(versionId);
110+
}
97111
}

ui/src/app/app-routing.module.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {DetailsComponent as TestPlanDetailsComponent} from "./components/plans/d
3535
import {DetailsHeaderComponent as TestPlanDetailsHeaderComponent} from "./components/plans/details-header.component";
3636
import {SuitesComponent as TestPlanSuitesListComponent} from './components/plans/suites.component';
3737
import {DevicesComponent as TestPlanDevicesListComponent} from './components/plans/devices.component';
38-
import {PlugsComponent as TestPlanPlugsComponent} from './components/plans/plugs.component';
38+
import {PlugsComponent, PlugsComponent as TestPlanPlugsComponent} from './components/plans/plugs.component';
3939
import {SchedulesComponent as TestPlanSchedulesListComponent} from './components/plans/schedules.component';
4040
import {FormComponent as TestPlanFormComponent} from './components/plans/form.component';
4141
import {ListComponent as ActionTemplatesListComponent} from "./components/actions/list.component";
@@ -50,6 +50,7 @@ import {TestPlansComponent as EnvironmentTestPlansComponent} from './components/
5050
import {LoginFormComponent} from "./components/login-form.component";
5151
import {UnAuthenticationGuardGuard} from "./guards/un-authentication-guard.guard";
5252
import {AddonAppComponent} from "./components/addon-app.component";
53+
import {ReportsComponent} from "./components/reports.component";
5354
import {ConsentGuard} from "./guards/consent.guard";
5455
import {ConsentComponent} from "./components/webcomponents/consent.component";
5556
import {OnboardingFormComponent} from "./components/onboarding-form.component";
@@ -370,6 +371,17 @@ const routes: Routes = [
370371
data: {legacyURL: '#/addons', title: 'page_title.add_ons'},
371372
component: AddonAppComponent
372373
},
374+
{
375+
path: 'reports',
376+
data: {legacyURL: '#/reports', title: 'Reports'},
377+
component: ReportsComponent,
378+
children: [
379+
{path: '', pathMatch: 'full', redirectTo: 'reports'},
380+
{path: 'analytics', component: ReportsComponent},
381+
{path: 'custom_reports', component: ReportsComponent},
382+
{path: 'query_engine', component: ReportsComponent}
383+
]
384+
},
373385
{
374386
path: 'settings',
375387
data: {legacyURL: '#/settings'},

ui/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ import {HelpActionsComponent} from './components/webcomponents/help-actions.comp
226226
import {TestCaseDataDrivenResultListComponent} from './src/app/components/webcomponents/test-case-data-driven-result-list.component';
227227
import {ElementBulkUpdateComponent} from './components/webcomponents/element-bulk-update.component';
228228
import {AddonAppComponent} from './components/addon-app.component';
229+
import {ReportsComponent} from './components/reports.component';
229230
import {RouteLoadingComponent} from './components/webcomponents/route-loading.component';
230231
import {MatCarouselModule} from '@ngmodule/material-carousel';
231232
import {TestDataFilterComponent} from "./components/data/webcomponents/test-data-filter.component";
@@ -496,6 +497,7 @@ export function HttpLoaderFactory(httpClient: HttpClient) {
496497
TestCaseDataDrivenResultListComponent,
497498
ElementBulkUpdateComponent,
498499
AddonAppComponent,
500+
ReportsComponent,
499501
RouteLoadingComponent,
500502
TestDataFilterComponent,
501503
TestDevIconComponent,

ui/src/app/components/reports.component.html

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,71 @@
44
<a
55
class="normal-text"
66
[routerLinkActive]="'active'"
7-
[routerLinkActiveOptions]="{ exact: true }"
8-
[routerLink]="['../plugs']">
7+
[routerLink]="['./analytics']">
98
<span [translate]="'Dashboard'" ></span>
109
</a>
1110
</li>
1211
<li class="nav-items" role="presentation">
1312
<a
1413
[routerLinkActive]="'active'"
15-
[routerLink]="['./bug_report']"
14+
[routerLink]="['./custom_reports']"
1615
class="normal-text">
1716
<span [translate]="'Reports'"></span>
1817
</a>
1918
</li>
2019
<li class="nav-items" role="presentation">
2120
<a
2221
[routerLinkActive]="'active'"
23-
[routerLink]="['./test_lab']"
22+
[routerLink]="['./query_engine']"
2423
class="normal-text">
2524
<span [translate]="'Query Reporting Engine'"></span>
2625
</a>
2726
</li>
2827
</ul>
28+
<div class="page-content page-virtual-scroll pt-40 d-flex-wrap">
29+
<div class="x-sm-h ts-col-18 theme-border border-rds-5 p-40 d-flex mr-10">
30+
<div class="highChart">
31+
<highcharts-chart
32+
[Highcharts] = "Highcharts"
33+
[options] = "chartOptions">
34+
</highcharts-chart>
35+
</div>
36+
</div>
37+
38+
<div class="x-sm-h ts-col-18 theme-border border-rds-5 p-40 d-flex mr-10">
39+
<div class="highChart">
40+
<highcharts-chart
41+
[Highcharts] = "Highcharts"
42+
[options] = "chartOptions">
43+
</highcharts-chart>
44+
</div>
45+
</div>
46+
47+
<div class="x-sm-h ts-col-18 theme-border border-rds-5 p-40 d-flex mr-10">
48+
<div class="highChart">
49+
<highcharts-chart
50+
[Highcharts] = "Highcharts"
51+
[options] = "chartOptions">
52+
</highcharts-chart>
53+
</div>
54+
</div>
55+
56+
<div class="x-sm-h ts-col-18 theme-border border-rds-5 p-40 d-flex mr-10">
57+
<div class="highChart">
58+
<highcharts-chart
59+
[Highcharts] = "Highcharts"
60+
[options] = "chartOptions">
61+
</highcharts-chart>
62+
</div>
63+
</div>
64+
65+
<div class="x-sm-h ts-col-18 theme-border border-rds-5 p-40 d-flex mr-10">
66+
<div class="highChart">
67+
<highcharts-chart
68+
[Highcharts] = "Highcharts"
69+
[options] = "chartOptions">
70+
</highcharts-chart>
71+
</div>
72+
</div>
73+
</div>
2974
</div>

ui/src/app/components/reports.component.ts

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import {ActivatedRoute} from "@angular/router";
3+
import * as Highcharts from 'highcharts';
34
import {AddonActionService} from "../services/addon-action.service";
45
import {AuthenticationGuard} from "../shared/guards/authentication.guard";
56

@@ -16,9 +17,65 @@ export class ReportsComponent implements OnInit {
1617
public authGuard: AuthenticationGuard
1718
) {
1819
}
20+
public Highcharts: typeof Highcharts = Highcharts;
21+
public chartOptions: Highcharts.Options;
1922

2023
ngOnInit(): void {
21-
24+
this.populateChartOptions();
2225
}
2326

27+
populateChartOptions() {
28+
this.chartOptions = {
29+
chart: {
30+
backgroundColor: 'transparent',
31+
margin: 0,
32+
width: 200,
33+
height: 200,
34+
type: 'pie'
35+
},
36+
title: {
37+
text: ''
38+
},
39+
credits: {
40+
enabled: false
41+
},
42+
tooltip: {
43+
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
44+
},
45+
accessibility: {
46+
point: {
47+
valueSuffix: '%'
48+
}
49+
},
50+
plotOptions: {
51+
pie: {
52+
size: '100%',
53+
innerSize: '60%',
54+
slicedOffset: 0,
55+
allowPointSelect: true,
56+
dataLabels: {
57+
enabled: true,
58+
padding: 0,
59+
style: {
60+
fontSize: '8px'
61+
}
62+
}
63+
}
64+
},
65+
series: [{
66+
name: 'Brands',
67+
colorByPoint: true,
68+
type:'pie',
69+
data: [{
70+
name: 'Chrome',
71+
y: 70,
72+
color:'#1FB47E'
73+
},{
74+
name: 'Internet Explorer',
75+
y: 30,
76+
color:'#1FA87E'
77+
}]
78+
}]
79+
};
80+
}
2481
}

ui/src/app/components/webcomponents/left-nav.component.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@
5656
</span>
5757
</a>
5858
</li>
59+
<li
60+
[routerLink]="['/reports']" [routerLinkActive]="'active'">
61+
<a [routerLink]="['/reports']" [routerLinkActive]="'active'" [matTooltip]="'left_nav.settings' | translate"
62+
placement="right">
63+
<span>
64+
<i class="fa-reports"></i>
65+
</span>
66+
</a>
67+
</li>
5968
<li
6069
[routerLink]="['/settings']" [routerLinkActive]="'active'">
6170
<a [routerLink]="['/settings']" [routerLinkActive]="'active'" [matTooltip]="'left_nav.settings' | translate"

0 commit comments

Comments
 (0)