Skip to content

Commit

Permalink
Updates create and repeat test run execution to match backend changes (
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-marquez-csa authored Nov 10, 2023
1 parent 584156b commit 66d60a5
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 91 deletions.
10 changes: 7 additions & 3 deletions src/app/components/test/test-details/test-details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ export class TestDetailsComponent {
}
}
}
const testConfig: any = await this.testSandbox.createTestRunConfig(this.selectedDataFinal);
this.testSandbox.createTestRunExecution(this.callbackForStartTestExecution.bind(this),
testConfig.id, this.testName, this.testRunAPI.getSelectedOperator().id, this.description);
this.testSandbox.createTestRunExecution(
this.callbackForStartTestExecution.bind(this),
this.selectedDataFinal,
this.testName,
this.testRunAPI.getSelectedOperator().id,
this.description
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, Injectable } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { DialogService } from 'primeng/dynamicdialog';
Expand Down Expand Up @@ -229,8 +229,7 @@ export class TestExecutionHistoryComponent {
const title: any = executionData.title.slice(0, executionData.title.length - 20);
this.sharedAPI.setAppState(APP_STATE[1]);
this.sharedAPI.setWebSocketLoader(true);
this.testSandbox.createTestRunExecution(this.repeatExecution.bind(this), executionData.test_run_config_id,
title, executionData.operator.id, executionData.description);
this.testSandbox.repeatTestRunExecution(this.repeatExecution.bind(this), executionData.id);
}
}
repeatExecution(execId: any) {
Expand Down
45 changes: 22 additions & 23 deletions src/app/components/test/test.sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { SharedAPI } from 'src/app/shared/core_apis/shared';
import { TestRunAPI } from 'src/app/shared/core_apis/test-run';
Expand Down Expand Up @@ -135,15 +135,14 @@ export class TestSandbox {
setDefaultSelectedData(selectedData: any) {
this.testRunStore.setSelectedTestCase(selectedData);
}
// Trigger core_apis function to create new test-run-config
async createTestRunConfig(requestJson: any) {
const testConfigData = await this.testRunAPI.createTestRunConfig(requestJson);
return testConfigData;
}
// Trigger core_apis function to create new test-run-executions
createTestRunExecution(callback: any, testConfigId: number, testName: string, operatorId: any, description: any) {
createTestRunExecution(callback: any, selectedDataFinal: any, testName: string, operatorId: any, description: any) {
const selectedProjectId = this.sharedAPI.getSelectedProjectType().id;
this.testRunAPI.createTestRunExecution(callback, testConfigId, selectedProjectId, testName, operatorId, description);
this.testRunAPI.createTestRunExecution(callback, selectedDataFinal, selectedProjectId, testName, operatorId, description);
}
// Trigger core_apis function to repeat test-run-executions
repeatTestRunExecution(callback: any, testExecutionId: number) {
this.testRunAPI.repeatTestRunExecution(callback, testExecutionId);
}
// Start test execution and set initial running testcase data
setRunningTestsDataOnStart(execId: any) {
Expand Down
51 changes: 28 additions & 23 deletions src/app/shared/core_apis/test-run.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { TestRunStore } from 'src/app/store/test-run-store';
import { TestRunService } from '../test-run-utils';
Expand Down Expand Up @@ -243,15 +243,20 @@ export class TestRunAPI {
);
}

// Create new test run config
async createTestRunConfig(requestJson: any) {
const testConfigData = await this.testRunService.createTestRunConfig(requestJson);
return testConfigData;
// Create new test run execution
createTestRunExecution(callback: any, selectedDataFinal: any, selectedProjectId: number, testName: string, operatorId: any, description: any) {
return this.testRunService.createTestRunExecution(selectedDataFinal, selectedProjectId, testName, operatorId, description).subscribe(
(data) => {
callback(data.id);
return data;
}, err => {
this.sharedService.showPopUp();
});
}

// Create new test run execution
createTestRunExecution(callback: any, testConfigId: number, selectedProjectId: number, testName: string, operatorId: any, description: any) {
return this.testRunService.createTestRunExecution(testConfigId, selectedProjectId, testName, operatorId, description).subscribe(
// Repeats a test run execution
repeatTestRunExecution(callback: any, testExecutionId: number) {
return this.testRunService.repeatTestRunExecution(testExecutionId).subscribe(
(data) => {
callback(data.id);
return data;
Expand Down
51 changes: 27 additions & 24 deletions src/app/shared/test-run-utils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
Expand All @@ -37,23 +37,26 @@ export class TestRunService {
getDefaultTestCases(): Observable<any> {
return this.http.get(getBaseUrl() + 'test_collections');
}
async createTestRunConfig(requestJson: any) {
const testConfigData = await this.http.post(getBaseUrl() + 'test_run_configs', requestJson).toPromise();
return testConfigData;
}
createTestRunExecution(testConfigId: number, selectedProjectId: number, testName: string, operatorId: any,
createTestRunExecution(selectedDataFinal: any, selectedProjectId: number, testName: string, operatorId: any,
description: any): Observable<any> {
/* eslint-disable @typescript-eslint/naming-convention */
const selected_tests = selectedDataFinal.selected_tests;
const requestJson = {
'test_run_execution_in':
{
'title': testName + '_' + getTimeStamp(), 'test_run_config_id': testConfigId,
'project_id': selectedProjectId, 'description': description, 'operator_id': operatorId
}
'title': testName + '_' + getTimeStamp(),
'project_id': selectedProjectId,
'description': description,
'operator_id': operatorId
},
selected_tests
};
/* eslint-enable @typescript-eslint/naming-convention */
return this.http.post(getBaseUrl() + 'test_run_executions', requestJson);
}
repeatTestRunExecution(testExecutionId: number): Observable<any> {
return this.http.post(getBaseUrl() + `test_run_executions/${testExecutionId}/repeat`, {});
}
startTestRunExecution(id: number): Observable<any> {
return this.http.post(getBaseUrl() + 'test_run_executions/' + id + '/start', {});
}
Expand Down

0 comments on commit 66d60a5

Please sign in to comment.