From 35217ad7c4f2599e3aabf3daeb909c64f63002b3 Mon Sep 17 00:00:00 2001 From: Nandana-NNR <118901484+Nandana-NNR@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:34:20 +0530 Subject: [PATCH] fix: error schema fix (#199) --- cypress/fixtures/schemas/errorSchema.json | 76 +++++-------------- cypress/support/constants/constants.js | 2 - .../support/validations/schemaValidation.js | 9 +-- 3 files changed, 23 insertions(+), 64 deletions(-) diff --git a/cypress/fixtures/schemas/errorSchema.json b/cypress/fixtures/schemas/errorSchema.json index 0f7e4011f..7f115d7d6 100644 --- a/cypress/fixtures/schemas/errorSchema.json +++ b/cypress/fixtures/schemas/errorSchema.json @@ -1,57 +1,23 @@ { - "errorSchemaSDK": { - "oneOf": [ - { - "type": "object", - "additionalProperties": false, - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "title": "errorObjectCode", - "description": "A Number that indicates the error type that occurred. This MUST be an integer. The error codes from and including -32768 to -32000 are reserved for pre-defined errors. These pre-defined errors SHOULD be assumed to be returned from any JSON-RPC api.", - "type": "integer" - }, - "message": { - "title": "errorObjectMessage", - "description": "A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.", - "type": "string" - }, - "data": { - "title": "errorObjectData", - "description": "A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.)." - } - } - }, - { - "type": "string" - } - ] - }, - "errorSchemaTransport": { - "type": "object", - "additionalProperties": false, - "required": [ - "code", - "message" - ], - "properties": { - "code": { - "title": "errorObjectCode", - "description": "A Number that indicates the error type that occurred. This MUST be an integer. The error codes from and including -32768 to -32000 are reserved for pre-defined errors. These pre-defined errors SHOULD be assumed to be returned from any JSON-RPC api.", - "type": "integer" - }, - "message": { - "title": "errorObjectMessage", - "description": "A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.", - "type": "string" - }, - "data": { - "title": "errorObjectData", - "description": "A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.)." - } - } + "errorSchema": { + "type": "object", + "additionalProperties": false, + "required": ["code", "message"], + "properties": { + "code": { + "title": "errorObjectCode", + "description": "A Number that indicates the error type that occurred. This MUST be an integer. The error codes from and including -32768 to -32000 are reserved for pre-defined errors. These pre-defined errors SHOULD be assumed to be returned from any JSON-RPC api.", + "type": "integer" + }, + "message": { + "title": "errorObjectMessage", + "description": "A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.", + "type": "string" + }, + "data": { + "title": "errorObjectData", + "description": "A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.)." + } } -} \ No newline at end of file + } +} diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index f7fabf99b..a63c76112 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -126,8 +126,6 @@ module.exports = { ERROR_NOT_UNDEFINED_CHECK: 'Error not undefined Check', ERROR_NULL_CHECK: 'Error null Check', ERROR_CONTENT_OBJECTS_PATH: 'cypress/fixtures/objects/errorContentObjects.json', - ERROR_SCHEMA_SDK: 'errorSchemaSDK', - ERROR_SCHEMA_TRANSPORT: 'errorSchemaTransport', EVENT: 'event', EVENT_ERROR_MSG: 'Event listener error validation', EVENT_LISTENER_RESPONSE: 'eventListenerResponse', diff --git a/cypress/support/validations/schemaValidation.js b/cypress/support/validations/schemaValidation.js index 7ffc04109..14a434b2f 100644 --- a/cypress/support/validations/schemaValidation.js +++ b/cypress/support/validations/schemaValidation.js @@ -171,13 +171,8 @@ Cypress.Commands.add('getSchema', (methodOrEvent, params, schemaType) => { let schemaMap = null; if (schemaType == CONSTANTS.ERROR) { - cy.fixture(CONSTANTS.OPENRPC_ERROR_SCHEMA_PATH).then((errorSchema) => { - const communicationMode = UTILS.getCommunicationMode(); - const errorSchemaBasedOnMode = - communicationMode == CONSTANTS.MODE_TRANSPORT - ? errorSchema[CONSTANTS.ERROR_SCHEMA_TRANSPORT] - : errorSchema[CONSTANTS.ERROR_SCHEMA_SDK]; - return errorSchemaBasedOnMode; + cy.fixture(CONSTANTS.OPENRPC_ERROR_SCHEMA_PATH).then((errorSchemaObject) => { + return errorSchemaObject.errorSchema; }); } else { if (