Skip to content

Commit

Permalink
New Features:
Browse files Browse the repository at this point in the history
1. System Tests get chart, passed tests, execute test
New Pages:
Bugs Corrected:
To Be Corrected:
0. On product delete, delete trace results
1. On product delete, delete flamegraph result
2. Add AI to System Tests
  • Loading branch information
juanfranciscocis committed Sep 3, 2024
1 parent cd09969 commit 2e299bf
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <H2>Choose a type of test.</H2>
<ion-card-title class="flex flex-col justify-center items-center text-green-600">Passed Tests</ion-card-title>
</ion-card-header>
<ion-card-content class="flex flex-col justify-center items-center">
<h1>{{passed}}</h1>
<h1>{{passedSystemTests}}</h1>
</ion-card-content>
</ion-card>
</ion-col>
Expand All @@ -84,7 +84,7 @@ <h1>{{passed}}</h1>
<ion-card-title class="flex flex-col justify-center items-center text-red-800">Failed Tests</ion-card-title>
</ion-card-header>
<ion-card-content class="flex flex-col justify-center items-center">
<h1>{{ failed }}</h1>
<h1>{{ failedSystemTests }}</h1>
</ion-card-content>
</ion-card>
</ion-col>
Expand Down
206 changes: 117 additions & 89 deletions src/app/pages/software-testing-chooser/software-testing-chooser.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,48 @@ import {EChartsOption} from "echarts";
styleUrls: ['./software-testing-chooser.page.scss'],
})
export class SoftwareTestingChooserPage implements OnInit {

productStep: string = '';
systemTests: SystemTest[] = [];
productObjective: string = '';

private user: User = {};
private orgName: string = '';

passed: number = 0;
failed: number = 0;

systemTests: SystemTest[] = [];

passedSystemTests: number = 0;
failedSystemTests: number = 0;

systemTestsChart: EChartsOption = {
tooltip: {
trigger: 'axis'
},
legend: {
data: ['Passed', 'Failed'],
left: 'left'
},
xAxis: {
type: 'category',
boundaryGap: false,
data: [] // This will be populated with execution dates
},
yAxis: {
type: 'value'
},
series: [
{
name: 'Passed',
type: 'line',
data: [] // This will be populated with the number of passed tests
tooltip: {
trigger: 'axis'
},
legend: {
data: ['Passed', 'Failed'],
left: 'left'
},
xAxis: {
type: 'category',
boundaryGap: false,
data: [] // This will be populated with execution dates
},
{
name: 'Failed',
type: 'line',
data: [] // This will be populated with the number of failed tests
}
]
};
yAxis: {
type: 'value'
},
series: [
{
name: 'Passed',
type: 'line',
data: [] // This will be populated with the number of passed tests
},
{
name: 'Failed',
type: 'line',
data: [] // This will be populated with the number of failed tests
},
]
};

constructor(
private activatedRoute: ActivatedRoute,
Expand All @@ -65,8 +69,8 @@ export class SoftwareTestingChooserPage implements OnInit {
async ionViewWillEnter() {
this.getProductFromParams();
await this.getSystemTests();
await this.calculatePassed();
await this.calculateGraphData();
await this.calculatePassedSystemTests();
await this.calculateGraphDataSystemTests();
}

/**
Expand All @@ -82,38 +86,17 @@ export class SoftwareTestingChooserPage implements OnInit {
console.log(this.productStep);
}


/**
* Methods to navigate.
*/
navigateToCreateSystemTest() {
// Navigate to the system test creation page
this.router.navigate(['/create-system-test', {
productObjective: this.productObjective,
step: this.productStep
}]);
}

async getSystemTests() {
await this.showLoading()
// Get User from local storage
const userString = localStorage.getItem('user');
if (!userString) return;

this.user = JSON.parse(userString);
this.orgName = this.user.orgName!;


// Get system tests from the service
this.systemTestService.getSystemTest(this.orgName, this.productObjective, this.productStep).then(r => {
this.systemTests = r;
});

await this.hideLoading();
}


doRefresh($event: any) {
this.getSystemTests();
$event.target.complete();
}

navigateToExecuteTest(testTitle:string) {
this.router.navigate(['/execute-system-test', {
productObjective: this.productObjective,
Expand All @@ -122,18 +105,21 @@ export class SoftwareTestingChooserPage implements OnInit {
}]);
}

async calculatePassed() {
/**
* Methods to calculate the number of passed and failed system tests.
*/
async calculatePassedSystemTests() {
await this.showLoading();

this.passed = 0;
this.failed = 0;
this.passedSystemTests = 0;
this.failedSystemTests = 0;
await this.systemTestService.getSystemTestHistoryByStep(this.orgName, this.productObjective, this.productStep).then(r => {
r.forEach((test: { state: boolean; }) => {
if (test.state) {
this.passed++;
this.passedSystemTests++;
}
else {
this.failed++;
this.failedSystemTests++;
}
});
});
Expand All @@ -142,34 +128,10 @@ export class SoftwareTestingChooserPage implements OnInit {
}

/**
* Show a loading spinner.
* Methods to calculate the data for the graph.
* @returns {Promise<void>}
*/
async showLoading() {
const loading = await this.loadingCtrl.create({
});
await loading.present();
}

/**
* Hide the loading spinner.
*/
async hideLoading() {
await this.loadingCtrl.dismiss();
}


async deleteTest(title: string) {
let systemTest = this.systemTests.find((systemTest: { title: string; }) => systemTest.title === title);
if (!systemTest) return;
await this.systemTestService.deleteSystemTest(this.orgName, this.productObjective, this.productStep,systemTest).then(async () => {
await this.getSystemTests();
});
await this.calculatePassed();
await this.calculateGraphData();
}


async calculateGraphData() {
async calculateGraphDataSystemTests() {
await this.showLoading();
// Get the system test history
await this.systemTestService.getSystemTestHistory(this.orgName, this.productObjective).then(r => {
Expand Down Expand Up @@ -241,4 +203,70 @@ export class SoftwareTestingChooserPage implements OnInit {
await this.hideLoading();
}


/**
* Methods to show tests in each section.
*/
async getSystemTests() {
await this.showLoading()
// Get User from local storage
const userString = localStorage.getItem('user');
if (!userString) return;

this.user = JSON.parse(userString);
this.orgName = this.user.orgName!;


// Get system tests from the service
this.systemTestService.getSystemTest(this.orgName, this.productObjective, this.productStep).then(r => {
this.systemTests = r;
});

await this.hideLoading();
}





async deleteTest(title: string) {
let systemTest = this.systemTests.find((systemTest: { title: string; }) => systemTest.title === title);
if (!systemTest) return;
await this.systemTestService.deleteSystemTest(this.orgName, this.productObjective, this.productStep,systemTest).then(async () => {
await this.getSystemTests();
});
await this.calculatePassedSystemTests();
await this.calculateGraphDataSystemTests();
}

/**
* Show a loading spinner.
*/
async showLoading() {
const loading = await this.loadingCtrl.create({
});
await loading.present();
}

/**
* Hide the loading spinner.
*/
async hideLoading() {
await this.loadingCtrl.dismiss();
}

/**
* Refresh the data.
* @param $event
*/
doRefresh($event: any) {
this.getSystemTests();
$event.target.complete();
}






}
1 change: 0 additions & 1 deletion www/383.77457df574544b3d.js

This file was deleted.

Loading

0 comments on commit 2e299bf

Please sign in to comment.