Skip to content

Commit

Permalink
feat: Sanity report logging (#213)
Browse files Browse the repository at this point in the history
* Added sanity report changes

* Added testcontext changes

* reverted the changes

* Added testrunner changes

* Added schema validation for all cases sanity

* Added new schema format

* Optimised getGenerateApiresult

* Added minor changes

* Addressed the review comments

* Added UI changes

* Added minor changes

* Added minor changes:

* Added unit tests for test runner

* Added minor changes

* Added additional unit test

* Addressed the comments
  • Loading branch information
Abhishk123 authored Sep 6, 2024
1 parent 80b6610 commit 52b1596
Show file tree
Hide file tree
Showing 6 changed files with 753 additions and 591 deletions.
511 changes: 144 additions & 367 deletions src/Test_Runner.js

Large diffs are not rendered by default.

30 changes: 12 additions & 18 deletions src/ValidationView.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class ValidationView extends lng.Component {
},
color: 0xff123456,
},
ContentValidationStateText: {
Message: {
x: 530,
y: 200,
w: 1920 - 700,
Expand Down Expand Up @@ -198,7 +198,7 @@ export default class ValidationView extends lng.Component {
this.tag('UpdateText').text = CONSTANTS.VALIDATION_SCROLLMESSAGE;
this.tag('ApititleText').text = '';
this.tag('SchemaValidationStateText').text = '';
this.tag('ContentValidationStateText').text = '';
this.tag('Message').text = '';
this.tag('ValidationData').text = '';
}
} else {
Expand Down Expand Up @@ -230,45 +230,39 @@ export default class ValidationView extends lng.Component {
const { err, fail, code } = _displayparms;
this.tag('ValidationData').color = 0xff123456;
let schemaValidationStateText = null,
contentValidationStateText = null,
message = null,
validationData = null;
if (code != undefined) {
let codeObject = null,
isCodeTypeObject = true,
messageString = null;
try {
codeObject = JSON.parse(_displayparms.code);
messageString = codeObject.Message;
if (typeof codeObject.Message != 'string') {
messageString = JSON.stringify(codeObject.Message, null, 1);
messageString = codeObject.Response;
if (typeof codeObject.Response != 'string') {
messageString = JSON.stringify(codeObject.Response, null, 1);
}
isCodeTypeObject = true;
} catch (err) {
isCodeTypeObject = false;
}
if (isCodeTypeObject) {
schemaValidationStateText = CONSTANTS.SCHEMA_VALIDATION_STATUSMESSAGE + codeObject.Schema;
contentValidationStateText = CONSTANTS.CONTENT_VALIDATION_STATUSMESSAGE + codeObject.Content;
if (fail) {
validationData = CONSTANTS.ERROR_MESSAGE + messageString;
} else {
validationData = CONSTANTS.API_RESPONSE + messageString;
}
schemaValidationStateText = CONSTANTS.SCHEMA_VALIDATION_STATUSMESSAGE + codeObject['Schema Validation'];
message = 'Message: ' + codeObject.Message;
validationData = CONSTANTS.API_RESPONSE + messageString;
} else {
schemaValidationStateText = CONSTANTS.SCHEMA_VALIDATION_STATUSMESSAGE + CONSTANTS.SCHEMA_CONTENT_SKIPPED;
contentValidationStateText = CONSTANTS.CONTENT_VALIDATION_STATUSMESSAGE + CONSTANTS.SCHEMA_CONTENT_SKIPPED;
validationData = CONSTANTS.ERROR_MESSAGE + 'JSON parse failed (ValidationView)';
validationData = CONSTANTS.API_RESPONSE + 'JSON parse failed (ValidationView)';
}
} else {
// Remove if not needed after testing
schemaValidationStateText = CONSTANTS.SCHEMA_VALIDATION_STATUSMESSAGE + CONSTANTS.SCHEMA_CONTENT_SKIPPED;
contentValidationStateText = CONSTANTS.CONTENT_VALIDATION_STATUSMESSAGE + CONSTANTS.SCHEMA_CONTENT_SKIPPED;
validationData = CONSTANTS.ERROR_MESSAGE + 'Received response as undefined';
validationData = CONSTANTS.API_RESPONSE + 'Received response as undefined';
}
// Updating values in UI
this.tag('ApititleText').text = CONSTANTS.API_TITLE + _displayparms.fullTitle;
this.tag('SchemaValidationStateText').text = schemaValidationStateText;
this.tag('ContentValidationStateText').text = contentValidationStateText;
this.tag('Message').text = message;

/*
Schema data for some APIs are large enough to break the render engine.
Expand Down
4 changes: 3 additions & 1 deletion src/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const CONSTANTS = {
CONTENT_ERROR: 'Content Error',
RDK_SERVICES: 'org.rdk.',
API_TITLE: 'API TITLE: ',
API_RESPONSE: 'API Response: ',
API_RESPONSE: 'Response: ',
INVOKE_TEST_MESSAGE: '**** Click Invoke to run tests ****',
VALIDATION_MESSAGE: '***** Validation Started ******',
VALIDATION_SCROLLMESSAGE: "Scroll down through the menu's to view the result",
Expand Down Expand Up @@ -172,4 +172,6 @@ export const CONSTANTS = {
EXCLUDED_METHODS_FOR_MFOS: [],
...CONFIG_CONSTANTS,
VERSIONS: 'Versions',
NO_RESULT_OR_ERROR_MESSAGE: 'No result or error in response. eg: {jsonrpc: "2.0", id: x }',
SCHEMA_VALIDATION: 'Schema Validation',
};
2 changes: 1 addition & 1 deletion src/pubsub/handlers/RunTestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class RunTestHandler extends BaseHandler {

async getValidationReport(message) {
const sdkMode = message.action;
process.env.COMMUNICATION_MODE = message.context.communicationMode;
process.env.COMMUNICATION_MODE = message.context.communicationMode ? message.context.communicationMode : CONSTANTS.TRANSPORT;

const sdkInvokerInfo = new Test_Runner();
let validatedMenu;
Expand Down
1 change: 0 additions & 1 deletion src/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ async function getschemaValidationDone(name, response, sdkType) {
* @param response - response of the method
*/
function censorData(methodName, response) {
let json;
try {
const json = censorDataJson;
if (methodName in json) {
Expand Down
Loading

0 comments on commit 52b1596

Please sign in to comment.