Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates create and repeat test run execution to match backend changes #13

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
*/
/**
raul-marquez-csa marked this conversation as resolved.
Show resolved Hide resolved
*
* 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) {
raul-marquez-csa marked this conversation as resolved.
Show resolved Hide resolved
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.
*/
/**
raul-marquez-csa marked this conversation as resolved.
Show resolved Hide resolved
*
* 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