From f007dd3ffb0e848b740ad4051c4e5b716741931f Mon Sep 17 00:00:00 2001 From: raul-marquez-csa Date: Tue, 7 Nov 2023 12:45:38 -0800 Subject: [PATCH 1/8] Updates create and repeat test run execution to match backend changes --- .../test-details/test-details.component.ts | 10 ++-- .../test-execution-history.component.ts | 35 +++++++------ src/app/components/test/test.sandbox.ts | 45 ++++++++-------- src/app/shared/core_apis/test-run.ts | 51 ++++++++++--------- src/app/shared/test-run-utils.ts | 51 ++++++++++--------- 5 files changed, 101 insertions(+), 91 deletions(-) diff --git a/src/app/components/test/test-details/test-details.component.ts b/src/app/components/test/test-details/test-details.component.ts index ec89fc7..6284453 100644 --- a/src/app/components/test/test-details/test-details.component.ts +++ b/src/app/components/test/test-details/test-details.component.ts @@ -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 + ); } } } diff --git a/src/app/components/test/test-execution-history/test-execution-history.component.ts b/src/app/components/test/test-execution-history/test-execution-history.component.ts index 23e14ad..289b960 100644 --- a/src/app/components/test/test-execution-history/test-execution-history.component.ts +++ b/src/app/components/test/test-execution-history/test-execution-history.component.ts @@ -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'; @@ -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) { diff --git a/src/app/components/test/test.sandbox.ts b/src/app/components/test/test.sandbox.ts index 7851353..77f5c04 100644 --- a/src/app/components/test/test.sandbox.ts +++ b/src/app/components/test/test.sandbox.ts @@ -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'; @@ -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) { diff --git a/src/app/shared/core_apis/test-run.ts b/src/app/shared/core_apis/test-run.ts index a3a0c01..35caa07 100644 --- a/src/app/shared/core_apis/test-run.ts +++ b/src/app/shared/core_apis/test-run.ts @@ -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'; @@ -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; diff --git a/src/app/shared/test-run-utils.ts b/src/app/shared/test-run-utils.ts index c05aa22..cd2cf2b 100644 --- a/src/app/shared/test-run-utils.ts +++ b/src/app/shared/test-run-utils.ts @@ -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'; @@ -37,23 +37,26 @@ export class TestRunService { getDefaultTestCases(): Observable { 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 { /* 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 { + return this.http.post(getBaseUrl() + `test_run_executions/${testExecutionId}/repeat`, {}); + } startTestRunExecution(id: number): Observable { return this.http.post(getBaseUrl() + 'test_run_executions/' + id + '/start', {}); } From 709164dfb4fc3b77a8b2b35f54c62376e6a54f10 Mon Sep 17 00:00:00 2001 From: Raul Marquez <130402456+raul-marquez-csa@users.noreply.github.com> Date: Fri, 10 Nov 2023 09:32:26 -0800 Subject: [PATCH 2/8] Updates create and repeat test run execution to match backend changes (#13) --- .../test-details/test-details.component.ts | 10 ++-- .../test-execution-history.component.ts | 35 +++++++------ src/app/components/test/test.sandbox.ts | 45 ++++++++-------- src/app/shared/core_apis/test-run.ts | 51 ++++++++++--------- src/app/shared/test-run-utils.ts | 51 ++++++++++--------- 5 files changed, 101 insertions(+), 91 deletions(-) diff --git a/src/app/components/test/test-details/test-details.component.ts b/src/app/components/test/test-details/test-details.component.ts index ec89fc7..6284453 100644 --- a/src/app/components/test/test-details/test-details.component.ts +++ b/src/app/components/test/test-details/test-details.component.ts @@ -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 + ); } } } diff --git a/src/app/components/test/test-execution-history/test-execution-history.component.ts b/src/app/components/test/test-execution-history/test-execution-history.component.ts index 23e14ad..289b960 100644 --- a/src/app/components/test/test-execution-history/test-execution-history.component.ts +++ b/src/app/components/test/test-execution-history/test-execution-history.component.ts @@ -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'; @@ -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) { diff --git a/src/app/components/test/test.sandbox.ts b/src/app/components/test/test.sandbox.ts index 7851353..77f5c04 100644 --- a/src/app/components/test/test.sandbox.ts +++ b/src/app/components/test/test.sandbox.ts @@ -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'; @@ -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) { diff --git a/src/app/shared/core_apis/test-run.ts b/src/app/shared/core_apis/test-run.ts index a3a0c01..35caa07 100644 --- a/src/app/shared/core_apis/test-run.ts +++ b/src/app/shared/core_apis/test-run.ts @@ -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'; @@ -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; diff --git a/src/app/shared/test-run-utils.ts b/src/app/shared/test-run-utils.ts index c05aa22..cd2cf2b 100644 --- a/src/app/shared/test-run-utils.ts +++ b/src/app/shared/test-run-utils.ts @@ -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'; @@ -37,23 +37,26 @@ export class TestRunService { getDefaultTestCases(): Observable { 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 { /* 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 { + return this.http.post(getBaseUrl() + `test_run_executions/${testExecutionId}/repeat`, {}); + } startTestRunExecution(id: number): Observable { return this.http.post(getBaseUrl() + 'test_run_executions/' + id + '/start', {}); } From a3c99891662a9a9ad3125c386e1dbb10cd693a36 Mon Sep 17 00:00:00 2001 From: Raul Marquez <130402456+raul-marquez-csa@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:08:49 -0800 Subject: [PATCH 3/8] Missing submit button (#14) * Updates create and repeat test run execution to match backend changes * Updates showExecutionPrompt() to handle options and message types --- .../test-execution/test-execution.sandbox.ts | 69 ++++++++++--------- src/app/shared/core_apis/websocket.ts | 5 +- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/src/app/components/test/test-execution/test-execution.sandbox.ts b/src/app/components/test/test-execution/test-execution.sandbox.ts index 15f81a8..237eed2 100644 --- a/src/app/components/test/test-execution/test-execution.sandbox.ts +++ b/src/app/components/test/test-execution/test-execution.sandbox.ts @@ -28,6 +28,7 @@ export class TestExecutionSandbox { showExecutionPrompt(promptData: any) { // Converting the prompt BE json to component required JSON format. + const promptType = promptData.type; const popupObject = { popupId: '', subHeader: promptData.payload.prompt, @@ -36,45 +37,49 @@ export class TestExecutionSandbox { inputItems: [] as any, messageId: promptData.payload.message_id }; - if (promptData.payload.options) { - const isOptionsEmpty = Object.keys(promptData.payload.options).length === 0; - if (isOptionsEmpty) { - // If no options available, only display message - popupObject.popupId = 'TEXTBOX_' + promptData.payload.message_id; - } else { - // Displaying the Radio button popup - const options = Object.entries(promptData.payload.options).map(([key, value]) => ({ key: value, value: key })); - const inputItems = [ - { - id: 1, - type: 'radioButton', - value: '', - groupName: 'group_1', - options: options - } - ]; - const buttons = [ - { - id: 1, - label: 'Submit', - class: 'buttonYes', - callback: this.onYesClick.bind(this) - } - ]; - popupObject.popupId = 'RADIO_' + promptData.payload.message_id; - popupObject.buttons = buttons; - popupObject.inputItems = inputItems; + const buttons = [ + { + id: 1, + label: 'Submit', + class: 'buttonYes', + callback: this.onYesClick.bind(this) } - } else if (promptData.payload.placeholder_text) { // Displaying the Textbox popup + ]; + + if (promptType === 'message_request') { // Displaying the message popup + popupObject.popupId = 'TEXTBOX_' + promptData.payload.message_id; + } else if (promptType === 'options_request') { // Displaying the radio buttons popup + const options = Object.entries(promptData.payload.options).map(([key, value]) => ({ key: value, value: key })); + const inputItems = [ + { + id: 1, + type: 'radioButton', + value: '', + groupName: 'group_1', + options: options + } + ]; + popupObject.popupId = 'RADIO_' + promptData.payload.message_id; + popupObject.inputItems = inputItems; + popupObject.buttons = buttons; + } else if (promptData.payload.placeholder_text) { // Displaying the text field popup popupObject.popupId = 'TEXTBOX_' + promptData.payload.message_id; const inputItems = [ - { id: 1, type: 'inputbox', value: promptData.payload.default_value, placeHolder: promptData.payload.placeholder_text } + { id: 1, + type: 'inputbox', + value: promptData.payload.default_value, + placeHolder: promptData.payload.placeholder_text + } ]; popupObject.inputItems = inputItems; - } else if (promptData.payload.path) { // Displaying the File-upload popup + popupObject.buttons = buttons; + } else if (promptData.payload.path) { // Displaying the file upload popup popupObject.popupId = 'FILE_UPLOAD_' + promptData.payload.message_id; const inputItems = [ - { id: 1, type: 'file_upload', value: '' } + { id: 1, + type: 'file_upload', + value: '' + } ]; popupObject.inputItems = inputItems; } diff --git a/src/app/shared/core_apis/websocket.ts b/src/app/shared/core_apis/websocket.ts index 28efa64..8ca21de 100644 --- a/src/app/shared/core_apis/websocket.ts +++ b/src/app/shared/core_apis/websocket.ts @@ -43,7 +43,10 @@ export class WebSocketAPI { const updated = this.testExecutionSandbox.updateJSONBasedOnWebSocketData(runningTestcase, dataObject); this.testRunAPI.setRunningTestCases(updated); this.checkExecutionEnded(dataObject); - } else if (dataObject.type === 'prompt_request' || dataObject.type === 'custom_upload') { + } else if (dataObject.type === 'prompt_request' || + dataObject.type === 'options_request' || + dataObject.type === 'message_request' || + dataObject.type === 'custom_upload') { this.testExecutionSandbox.showExecutionPrompt(dataObject); } else if (dataObject.type === 'time_out_notification') { this.sharedService.setToastAndNotification({ status: 'error', summary: 'Error!', message: 'Failed to give input' }); From 9e804d06a87ceadc4f399e756cc3c2b7d1677632 Mon Sep 17 00:00:00 2001 From: Raul Marquez <130402456+raul-marquez-csa@users.noreply.github.com> Date: Wed, 22 Nov 2023 13:46:28 -0800 Subject: [PATCH 4/8] Missing submit button (#15) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added script to build/publish docker image (#12) * Added docker build script * Update docker build script * Updates create and repeat test run execution to match backend changes * Updates create and repeat test run execution to match backend changes (#13) * Updates showExecutionPrompt() to handle options and message types * Missing submit button (#14) * Updates create and repeat test run execution to match backend changes * Updates showExecutionPrompt() to handle options and message types * Handles file_upload_request prompt, adds submit button to file upload prompt --------- Co-authored-by: Mikael Møller --- scripts/build-docker-image.sh | 123 ++++++++++++++++++ .../test-execution/test-execution.sandbox.ts | 5 +- src/app/shared/core_apis/websocket.ts | 1 + 3 files changed, 127 insertions(+), 2 deletions(-) create mode 100755 scripts/build-docker-image.sh diff --git a/scripts/build-docker-image.sh b/scripts/build-docker-image.sh new file mode 100755 index 0000000..31fd1f1 --- /dev/null +++ b/scripts/build-docker-image.sh @@ -0,0 +1,123 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2020 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. +# + +ME=$(basename "$0") +ROOT_DIR=$(realpath $(dirname "$0")/..) +cd $ROOT_DIR + +DEFAULT_IMAGE=csa-certification-tool-frontend + + +GHCR_ORG="ghcr.io" +ORG=${DOCKER_BUILD_ORG:-project-chip} + +# Latest commit hash +GIT_SHA=$(git rev-parse --short HEAD) + +# If working copy has changes, append `-local` to hash +GIT_DIFF=$(git diff -s --exit-code || echo "-local") +if [[ $GIT_DIFF ]]; then + echo " 🔴 Git repo has changes. Please commit all changes before publishing." +fi +GIT_REV=$GIT_SHA$GIT_DIFF +echo "$GIT_REV" + + +IMAGE=${DOCKER_BUILD_IMAGE:-$DEFAULT_IMAGE} + +# version +VERSION=${DOCKER_BUILD_VERSION:-$GIT_REV} + +# verify that repo is clean +DIRTY=`git status --porcelain --untracked-files=no` + + +# help +[[ ${*/--help//} != "${*}" ]] && { + set +x + echo "Usage: $me + + Build and (optionally tag as latest, push) a docker image from Dockerfile in CWD + + Options: + --no-cache passed as a docker build argument + --latest update latest to the current built version (\"$VERSION\") + --push push image(s) to $GHCR_ORG (requires docker login for \"$ORG\") + --skip-build skip the build/prune step + --help get this message + --squash squash docker layers before push them to $GHCR_ORG (requires docker-squash python module) + --clear remove images after after publishing them + +" + exit 0 +} + +die() { + echo "$me: *** ERROR: $*" + exit 1 +} + +set -ex + +[[ -n $VERSION ]] || die "version cannot be empty" + +BUILD_ARGS=() +if [[ ${*/--no-cache//} != "${*}" ]]; then + BUILD_ARGS+=(--no-cache) +fi + +# Don't run `docker build` and `docker image prune` when `--skip-build` in arguments +[[ ${*/--skip-build//} != "${*}" ]] || { + docker build "${BUILD_ARGS[@]}" --build-arg TARGETPLATFORM="$TARGET_PLATFORM_TYPE" --build-arg GIT_SHA="$GIT_REV" --build-arg VERSION="$VERSION" -t "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" . + docker image prune --force +} + +[[ ${*/--squash//} != "${*}" ]] && { + command -v docker-squash >/dev/null && + docker-squash "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" -t "$GHCR_ORG"/"$ORG"/"$IMAGE":squashed +} + +[[ ${*/--latest//} != "${*}" ]] && { + if [[ ${*/--squash//} != "${*}" ]]; then + docker tag "$GHCR_ORG"/"$ORG"/"$IMAGE":squashed "$GHCR_ORG"/"$ORG"/"$IMAGE":latest + else + docker tag "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" "$GHCR_ORG"/"$ORG"/"$IMAGE":latest + fi +} + +[[ ${*/--push//} != "${*}" ]] && { + if [[ $GIT_DIFF ]]; then + die "Don't push image with local changes" + fi + docker push "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" + [[ ${*/--latest//} != "${*}" ]] && { + docker push "$GHCR_ORG"/"$ORG"/"$IMAGE":latest + } +} + +[[ ${*/--clear//} != "${*}" ]] && { + docker rmi -f "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" + [[ ${*/--latest//} != "${*}" ]] && { + docker rmi -f "$GHCR_ORG"/"$ORG"/"$IMAGE":latest + } + [[ ${*/--squash//} != "${*}" ]] && { + docker rmi -f "$GHCR_ORG"/"$ORG"/"$IMAGE":squashed + } +} + +docker images --filter=reference="$GHCR_ORG/$ORG/*" \ No newline at end of file diff --git a/src/app/components/test/test-execution/test-execution.sandbox.ts b/src/app/components/test/test-execution/test-execution.sandbox.ts index 237eed2..1c4d66d 100644 --- a/src/app/components/test/test-execution/test-execution.sandbox.ts +++ b/src/app/components/test/test-execution/test-execution.sandbox.ts @@ -73,7 +73,7 @@ export class TestExecutionSandbox { ]; popupObject.inputItems = inputItems; popupObject.buttons = buttons; - } else if (promptData.payload.path) { // Displaying the file upload popup + } else if (promptType === 'file_upload_request') { // Displaying the file upload popup popupObject.popupId = 'FILE_UPLOAD_' + promptData.payload.message_id; const inputItems = [ { id: 1, @@ -82,6 +82,7 @@ export class TestExecutionSandbox { } ]; popupObject.inputItems = inputItems; + popupObject.buttons = buttons; } this.sharedAPI.setCustomPopupData(popupObject); this.sharedAPI.setShowCustomPopup(popupObject.popupId); @@ -133,4 +134,4 @@ export class TestExecutionSandbox { } return testData; } -} \ No newline at end of file +} diff --git a/src/app/shared/core_apis/websocket.ts b/src/app/shared/core_apis/websocket.ts index 8ca21de..a29fcbc 100644 --- a/src/app/shared/core_apis/websocket.ts +++ b/src/app/shared/core_apis/websocket.ts @@ -46,6 +46,7 @@ export class WebSocketAPI { } else if (dataObject.type === 'prompt_request' || dataObject.type === 'options_request' || dataObject.type === 'message_request' || + dataObject.type === 'file_upload_request' || dataObject.type === 'custom_upload') { this.testExecutionSandbox.showExecutionPrompt(dataObject); } else if (dataObject.type === 'time_out_notification') { From d48c2d69f10e9c56f8ecc85f41974e2d9309e912 Mon Sep 17 00:00:00 2001 From: raul-marquez-csa Date: Thu, 23 Nov 2023 15:35:39 -0800 Subject: [PATCH 5/8] Updates .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8225baa..2e3d1ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /node_modules /dist +Usersrmarq.git-credentials From e508e20df263b8028c61ae43a5f53dc0d1aec03f Mon Sep 17 00:00:00 2001 From: raul-marquez-csa Date: Tue, 28 Nov 2023 00:40:05 -0800 Subject: [PATCH 6/8] Updates test_run_executions test selection JSON payload to Pydantic's BaseModel format --- .../test-details/test-details.component.ts | 69 +++++++++++++------ src/app/shared/interfaces/test.ts | 15 ++++ 2 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 src/app/shared/interfaces/test.ts diff --git a/src/app/components/test/test-details/test-details.component.ts b/src/app/components/test/test-details/test-details.component.ts index 6284453..0ab65e5 100644 --- a/src/app/components/test/test-details/test-details.component.ts +++ b/src/app/components/test/test-details/test-details.component.ts @@ -24,6 +24,7 @@ import { TestSandbox } from '../test.sandbox'; import { environment } from 'src/environments/environment'; import { SharedService } from 'src/app/shared/core_apis/shared-utils'; import { TestRunStore } from 'src/app/store/test-run-store'; +import { Collection, TestSuite, TestCase } from 'src/app/shared/interfaces/test'; import * as _ from 'lodash'; @Component({ @@ -32,7 +33,6 @@ import * as _ from 'lodash'; styleUrls: ['./test-details.component.scss'] }) export class TestDetailsComponent { - selectedDataFinal: any = {}; testName = 'UI_Test_Run'; description = ''; allowedCharacter = /[^A-Za-z0-9 _-]/; @@ -89,32 +89,61 @@ export class TestDetailsComponent { this.testRunAPI.setRunningTestCases([]); this.testRunAPI.setTestLogs([]); this.testSandbox.setTestScreen(1); + /* eslint-disable @typescript-eslint/naming-convention */ - this.selectedDataFinal = { - 'name': 'test', - 'dut_name': 'test_dut', - 'selected_tests': {} + const selectedCollections = this.testSandbox.getSelectedData(); + const testSuiteCategories = this.testSandbox.getTestSuiteCategory(); + const collections: Collection[] = []; + const selectedDataFinal = { + name: 'test', + dut_name: 'test_dut', + selected_tests: { + collections + } }; - /* eslint-enable @typescript-eslint/naming-convention */ - for (let mainIndex = 0; mainIndex < this.testSandbox.getSelectedData().length; mainIndex++) { - if (this.testSandbox.getSelectedData()[mainIndex].length > 0) { - this.selectedDataFinal.selected_tests[this.testSandbox.getTestSuiteCategory()[mainIndex]] = {}; - for (let parentIndex = 0; parentIndex < this.testSandbox.getSelectedData()[mainIndex].length; parentIndex++) { - if (this.testSandbox.getSelectedData()[mainIndex][parentIndex]) { - this.selectedDataFinal.selected_tests[this.testSandbox.getTestSuiteCategory() - [mainIndex]][this.testSandbox.getSelectedData()[mainIndex][parentIndex].public_id] = {}; - this.testSandbox.getSelectedData()[mainIndex][parentIndex].children.forEach((selectedChildren: any) => { - this.selectedDataFinal.selected_tests[this.testSandbox.getTestSuiteCategory()[mainIndex]] - [this.testSandbox.getSelectedData()[mainIndex][parentIndex].public_id][selectedChildren.public_id] = - selectedChildren.count; - }); - } + + for (let collectionIndex = 0; collectionIndex < selectedCollections.length; collectionIndex++) { + // Add collections + const collectionData = selectedCollections[collectionIndex]; + const collectionId = testSuiteCategories[collectionIndex]; + const test_suites: TestSuite[] = []; + const collection: Collection = { + public_id: collectionId, + test_suites + }; + selectedDataFinal.selected_tests.collections.push(collection); + + for (let testSuiteIndex = 0; testSuiteIndex < collectionData.length; testSuiteIndex++) { + const testSuiteTest = collectionData[testSuiteIndex]; + if (testSuiteTest) { + // Add test suites + const testSuiteId = testSuiteTest.public_id; + const test_cases: TestCase[] = []; + const testSuite: TestSuite = { + public_id: testSuiteId, + test_cases + }; + selectedDataFinal.selected_tests.collections[collectionIndex] + .test_suites.push(testSuite); + + testSuiteTest.children.forEach((testCaseData: any) => { + // Add test cases + const testCaseId = testCaseData.public_id; + const testCaseIterations = testCaseData.count; + const testCase: TestCase = { + public_id: testCaseId, + iterations: testCaseIterations + }; + selectedDataFinal.selected_tests.collections[collectionIndex] + .test_suites[testSuiteIndex].test_cases.push(testCase); + }); } } } + this.testSandbox.createTestRunExecution( this.callbackForStartTestExecution.bind(this), - this.selectedDataFinal, + selectedDataFinal, this.testName, this.testRunAPI.getSelectedOperator().id, this.description diff --git a/src/app/shared/interfaces/test.ts b/src/app/shared/interfaces/test.ts new file mode 100644 index 0000000..963671a --- /dev/null +++ b/src/app/shared/interfaces/test.ts @@ -0,0 +1,15 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +export interface TestCase { + public_id: string; + iterations: number; +} + +export interface TestSuite { + public_id: string; + test_cases: TestCase[]; +} + +export interface Collection { + public_id: string; + test_suites: TestSuite[]; +} From b1ee5d49e67d16af19fa54f768452b88d81ee902 Mon Sep 17 00:00:00 2001 From: raul-marquez-csa Date: Tue, 28 Nov 2023 01:31:06 -0800 Subject: [PATCH 7/8] Refactors test run execution selection gathering logic, fixes array index issues --- .../test-details/test-details.component.ts | 108 ++++++++++-------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/src/app/components/test/test-details/test-details.component.ts b/src/app/components/test/test-details/test-details.component.ts index 0ab65e5..f6bcd1d 100644 --- a/src/app/components/test/test-details/test-details.component.ts +++ b/src/app/components/test/test-details/test-details.component.ts @@ -90,66 +90,78 @@ export class TestDetailsComponent { this.testRunAPI.setTestLogs([]); this.testSandbox.setTestScreen(1); - /* eslint-disable @typescript-eslint/naming-convention */ - const selectedCollections = this.testSandbox.getSelectedData(); - const testSuiteCategories = this.testSandbox.getTestSuiteCategory(); - const collections: Collection[] = []; - const selectedDataFinal = { - name: 'test', - dut_name: 'test_dut', - selected_tests: { - collections - } - }; + this.testSandbox.createTestRunExecution( + this.callbackForStartTestExecution.bind(this), + this.getTestRunData(), + this.testName, + this.testRunAPI.getSelectedOperator().id, + this.description + ); + } + } + } - for (let collectionIndex = 0; collectionIndex < selectedCollections.length; collectionIndex++) { - // Add collections - const collectionData = selectedCollections[collectionIndex]; - const collectionId = testSuiteCategories[collectionIndex]; - const test_suites: TestSuite[] = []; - const collection: Collection = { - public_id: collectionId, - test_suites - }; - selectedDataFinal.selected_tests.collections.push(collection); + getTestRunData() { + /* eslint-disable @typescript-eslint/naming-convention */ + const selectedCollections = this.testSandbox.getSelectedData(); + const testSuiteCategories = this.testSandbox.getTestSuiteCategory(); + const collections: Collection[] = []; + const selectedDataFinal = { + name: 'test', + dut_name: 'test_dut', + selected_tests: { + collections + } + }; - for (let testSuiteIndex = 0; testSuiteIndex < collectionData.length; testSuiteIndex++) { - const testSuiteTest = collectionData[testSuiteIndex]; - if (testSuiteTest) { - // Add test suites - const testSuiteId = testSuiteTest.public_id; - const test_cases: TestCase[] = []; - const testSuite: TestSuite = { - public_id: testSuiteId, - test_cases - }; - selectedDataFinal.selected_tests.collections[collectionIndex] - .test_suites.push(testSuite); + // Build test run data object + for (let collectionIndex = 0; collectionIndex < selectedCollections.length; collectionIndex++) { + const collectionData = selectedCollections[collectionIndex]; + if (collectionData.length > 0) { + // Add collection + const collectionId = testSuiteCategories[collectionIndex]; + const test_suites: TestSuite[] = []; + const collection: Collection = { + public_id: collectionId, + test_suites + }; + const collectionsLength = selectedDataFinal.selected_tests.collections.push(collection); + const collectionInsertIndex = collectionsLength - 1; + + for (let testSuiteIndex = 0; testSuiteIndex < collectionData.length; testSuiteIndex++) { + const testSuiteData = collectionData[testSuiteIndex]; + if (testSuiteData) { + // Add test suite + const testSuiteId = testSuiteData.public_id; + const test_cases: TestCase[] = []; + const testSuite: TestSuite = { + public_id: testSuiteId, + test_cases + }; + const testSuitesLength = selectedDataFinal.selected_tests.collections[collectionInsertIndex] + .test_suites.push(testSuite); + const testSuiteInsertIndex = testSuitesLength - 1; - testSuiteTest.children.forEach((testCaseData: any) => { - // Add test cases + for (let testCaseIndex = 0; testCaseIndex < testSuiteData.children.length; testCaseIndex++) { + const testCaseData = testSuiteData.children[testCaseIndex]; + if (testCaseData) { + // Add test case const testCaseId = testCaseData.public_id; const testCaseIterations = testCaseData.count; const testCase: TestCase = { - public_id: testCaseId, - iterations: testCaseIterations + public_id: testCaseId, + iterations: testCaseIterations }; - selectedDataFinal.selected_tests.collections[collectionIndex] - .test_suites[testSuiteIndex].test_cases.push(testCase); - }); + selectedDataFinal.selected_tests.collections[collectionInsertIndex] + .test_suites[testSuiteInsertIndex].test_cases.push(testCase); + } } } } - - this.testSandbox.createTestRunExecution( - this.callbackForStartTestExecution.bind(this), - selectedDataFinal, - this.testName, - this.testRunAPI.getSelectedOperator().id, - this.description - ); } } + + return selectedDataFinal; } // call back for test execution From a45471159ded9ade0e816ade18b2ef7eba295357 Mon Sep 17 00:00:00 2001 From: raul-marquez-csa Date: Tue, 28 Nov 2023 02:03:49 -0800 Subject: [PATCH 8/8] More refactor, removes unused properties --- .../test-details/test-details.component.ts | 29 +++++++------------ src/app/shared/interfaces/test.ts | 4 +++ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/app/components/test/test-details/test-details.component.ts b/src/app/components/test/test-details/test-details.component.ts index f6bcd1d..32807bb 100644 --- a/src/app/components/test/test-details/test-details.component.ts +++ b/src/app/components/test/test-details/test-details.component.ts @@ -24,7 +24,7 @@ import { TestSandbox } from '../test.sandbox'; import { environment } from 'src/environments/environment'; import { SharedService } from 'src/app/shared/core_apis/shared-utils'; import { TestRunStore } from 'src/app/store/test-run-store'; -import { Collection, TestSuite, TestCase } from 'src/app/shared/interfaces/test'; +import { Collection, TestSuite, TestCase, SelectedTests } from 'src/app/shared/interfaces/test'; import * as _ from 'lodash'; @Component({ @@ -92,7 +92,7 @@ export class TestDetailsComponent { this.testSandbox.createTestRunExecution( this.callbackForStartTestExecution.bind(this), - this.getTestRunData(), + this.getTestRunExecutionSelection(), this.testName, this.testRunAPI.getSelectedOperator().id, this.description @@ -101,17 +101,12 @@ export class TestDetailsComponent { } } - getTestRunData() { + getTestRunExecutionSelection() { /* eslint-disable @typescript-eslint/naming-convention */ const selectedCollections = this.testSandbox.getSelectedData(); const testSuiteCategories = this.testSandbox.getTestSuiteCategory(); - const collections: Collection[] = []; - const selectedDataFinal = { - name: 'test', - dut_name: 'test_dut', - selected_tests: { - collections - } + const selected_tests: SelectedTests = { + collections: [] }; // Build test run data object @@ -120,12 +115,11 @@ export class TestDetailsComponent { if (collectionData.length > 0) { // Add collection const collectionId = testSuiteCategories[collectionIndex]; - const test_suites: TestSuite[] = []; const collection: Collection = { public_id: collectionId, - test_suites + test_suites: [] }; - const collectionsLength = selectedDataFinal.selected_tests.collections.push(collection); + const collectionsLength = selected_tests.collections.push(collection); const collectionInsertIndex = collectionsLength - 1; for (let testSuiteIndex = 0; testSuiteIndex < collectionData.length; testSuiteIndex++) { @@ -133,12 +127,11 @@ export class TestDetailsComponent { if (testSuiteData) { // Add test suite const testSuiteId = testSuiteData.public_id; - const test_cases: TestCase[] = []; const testSuite: TestSuite = { public_id: testSuiteId, - test_cases + test_cases: [] }; - const testSuitesLength = selectedDataFinal.selected_tests.collections[collectionInsertIndex] + const testSuitesLength = selected_tests.collections[collectionInsertIndex] .test_suites.push(testSuite); const testSuiteInsertIndex = testSuitesLength - 1; @@ -152,7 +145,7 @@ export class TestDetailsComponent { public_id: testCaseId, iterations: testCaseIterations }; - selectedDataFinal.selected_tests.collections[collectionInsertIndex] + selected_tests.collections[collectionInsertIndex] .test_suites[testSuiteInsertIndex].test_cases.push(testCase); } } @@ -161,7 +154,7 @@ export class TestDetailsComponent { } } - return selectedDataFinal; + return { selected_tests }; } // call back for test execution diff --git a/src/app/shared/interfaces/test.ts b/src/app/shared/interfaces/test.ts index 963671a..0201b96 100644 --- a/src/app/shared/interfaces/test.ts +++ b/src/app/shared/interfaces/test.ts @@ -13,3 +13,7 @@ export interface Collection { public_id: string; test_suites: TestSuite[]; } + +export interface SelectedTests { + collections: Collection[]; +}