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 test_run_executions test selection JSON payload to Pydantic's BaseModel format #16

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
/dist
Usersrmarq.git-credentials
84 changes: 59 additions & 25 deletions src/app/components/test/test-details/test-details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, SelectedTests } from 'src/app/shared/interfaces/test';
import * as _ from 'lodash';

@Component({
Expand All @@ -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 _-]/;
Expand Down Expand Up @@ -89,32 +89,10 @@ 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': {}
};
/* 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;
});
}
}
}
}

this.testSandbox.createTestRunExecution(
this.callbackForStartTestExecution.bind(this),
this.selectedDataFinal,
this.getTestRunExecutionSelection(),
this.testName,
this.testRunAPI.getSelectedOperator().id,
this.description
Expand All @@ -123,6 +101,62 @@ export class TestDetailsComponent {
}
}

getTestRunExecutionSelection() {
/* eslint-disable @typescript-eslint/naming-convention */
const selectedCollections = this.testSandbox.getSelectedData();
const testSuiteCategories = this.testSandbox.getTestSuiteCategory();
const selected_tests: SelectedTests = {
collections: []
};

// 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 collection: Collection = {
public_id: collectionId,
test_suites: []
};
const collectionsLength = 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 testSuite: TestSuite = {
public_id: testSuiteId,
test_cases: []
};
const testSuitesLength = selected_tests.collections[collectionInsertIndex]
.test_suites.push(testSuite);
const testSuiteInsertIndex = testSuitesLength - 1;

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
};
selected_tests.collections[collectionInsertIndex]
.test_suites[testSuiteInsertIndex].test_cases.push(testCase);
}
}
}
}
}
}

return { selected_tests };
}

// call back for test execution
callbackForStartTestExecution(value: any) {
this.testSandbox.setRunningTestsDataOnStart(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -82,6 +82,7 @@ export class TestExecutionSandbox {
}
];
popupObject.inputItems = inputItems;
popupObject.buttons = buttons;
}
this.sharedAPI.setCustomPopupData(popupObject);
this.sharedAPI.setShowCustomPopup(popupObject.popupId);
Expand Down Expand Up @@ -133,4 +134,4 @@ export class TestExecutionSandbox {
}
return testData;
}
}
}
1 change: 1 addition & 0 deletions src/app/shared/core_apis/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
19 changes: 19 additions & 0 deletions src/app/shared/interfaces/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* 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[];
}

export interface SelectedTests {
collections: Collection[];
}