From 91083ee8c01361b2a0c01579e9635d0c54271edc Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Tue, 6 Aug 2024 14:33:05 +0530 Subject: [PATCH 01/22] added support in env setup glue for fetching device details dynamically --- cypress/support/constants/constants.js | 2 ++ cypress/support/step_definitions/testSetup.js | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index 32e2d097..5345f9a8 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -84,10 +84,12 @@ module.exports = { DEVICEMODULEFORMAT: 'deviceModelFormat', DEVICE_AUDIO: 'device.audio', DEVICE_CONTENT_VALIDATION: 'deviceContentValidation', + DEVICE_DATA: 'deviceData', DEVICE_ENV: 'Device', DEVICE_FIRMWARE: 'Device Firmware', DEVICE_HDCP: 'device.hdcp', DEVICE_HDR: 'device.hdr', + DEVICE_ID: 'device.id', DEVICE_IP: 'deviceIp', DEVICE_MAC: 'deviceMac', DEVICE_MAC_UNAVAILABLE: 'Device MAC unavailable', diff --git a/cypress/support/step_definitions/testSetup.js b/cypress/support/step_definitions/testSetup.js index c01bd9f4..55cc5fc9 100644 --- a/cypress/support/step_definitions/testSetup.js +++ b/cypress/support/step_definitions/testSetup.js @@ -55,6 +55,31 @@ Given('the environment has been set up for {string} tests', (test) => { if (Cypress.env(CONSTANTS.TEST_TYPE).includes('rpc-Only')) { Cypress.env(CONSTANTS.IS_RPC_ONLY, true); } + // fetch device details dynamically + cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( + (response) => { + if (response) { + const deviceData = Cypress.env(CONSTANTS.DEVICE_DATA); + const extractedData = {}; + if (deviceData) { + for (let i = 0; i < deviceData.length; i++) { + if (deviceData[i].id == response) { + extractedData.deviceId = deviceData[i].id; + extractedData.deviceData = deviceData[i].data.deviceType; + extractedData.accountId = deviceData[i].data.serviceAccountId; + extractedData.distributor = deviceData[i].data.partner; + extractedData.sku = deviceData[i].data.model; + } + } + Cypress.env(CONSTANTS.DEVICE_DATA, extractedData); + } else { + throw new Error('Error getting deviceData from CodeBig '); + } + } else { + throw new Error('Error getting device id '); + } + } + ); } }); From e4e2ae73d714ffd8313b427fab07402a30030bde Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 7 Aug 2024 12:24:48 +0530 Subject: [PATCH 02/22] addressed review comments for error handling msg --- cypress/support/step_definitions/testSetup.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cypress/support/step_definitions/testSetup.js b/cypress/support/step_definitions/testSetup.js index 55cc5fc9..2b5463fc 100644 --- a/cypress/support/step_definitions/testSetup.js +++ b/cypress/support/step_definitions/testSetup.js @@ -58,6 +58,7 @@ Given('the environment has been set up for {string} tests', (test) => { // fetch device details dynamically cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( (response) => { + // if response ( device.id ) is present, call a function in xumoConfig for executing the following logic if (response) { const deviceData = Cypress.env(CONSTANTS.DEVICE_DATA); const extractedData = {}; @@ -73,7 +74,7 @@ Given('the environment has been set up for {string} tests', (test) => { } Cypress.env(CONSTANTS.DEVICE_DATA, extractedData); } else { - throw new Error('Error getting deviceData from CodeBig '); + throw new Error('Error getting deviceData'); } } else { throw new Error('Error getting device id '); From 03660a0d0eba1233b74a3ec01dd0d9f87c76e899 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Fri, 9 Aug 2024 15:39:21 +0530 Subject: [PATCH 03/22] added support in fcs to fetch device details dynamically --- cypress/support/constants/constants.js | 1 - cypress/support/step_definitions/testSetup.js | 35 +++++++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index 5345f9a8..b3ce01a4 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -84,7 +84,6 @@ module.exports = { DEVICEMODULEFORMAT: 'deviceModelFormat', DEVICE_AUDIO: 'device.audio', DEVICE_CONTENT_VALIDATION: 'deviceContentValidation', - DEVICE_DATA: 'deviceData', DEVICE_ENV: 'Device', DEVICE_FIRMWARE: 'Device Firmware', DEVICE_HDCP: 'device.hdcp', diff --git a/cypress/support/step_definitions/testSetup.js b/cypress/support/step_definitions/testSetup.js index 2b5463fc..4191b132 100644 --- a/cypress/support/step_definitions/testSetup.js +++ b/cypress/support/step_definitions/testSetup.js @@ -56,31 +56,20 @@ Given('the environment has been set up for {string} tests', (test) => { Cypress.env(CONSTANTS.IS_RPC_ONLY, true); } // fetch device details dynamically - cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( - (response) => { - // if response ( device.id ) is present, call a function in xumoConfig for executing the following logic - if (response) { - const deviceData = Cypress.env(CONSTANTS.DEVICE_DATA); - const extractedData = {}; - if (deviceData) { - for (let i = 0; i < deviceData.length; i++) { - if (deviceData[i].id == response) { - extractedData.deviceId = deviceData[i].id; - extractedData.deviceData = deviceData[i].data.deviceType; - extractedData.accountId = deviceData[i].data.serviceAccountId; - extractedData.distributor = deviceData[i].data.partner; - extractedData.sku = deviceData[i].data.model; - } - } - Cypress.env(CONSTANTS.DEVICE_DATA, extractedData); - } else { - throw new Error('Error getting deviceData'); + if (Cypress.env(CONSTANTS.TEST_TYPE) == CONSTANTS.DEVICE_ENV) { + cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( + (response) => { + if (response) { + const method = CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCHDEVICEDETAILS; + const requestMap = { + method: method, + params: response, + }; + cy.sendMessagetoPlatforms(requestMap); } - } else { - throw new Error('Error getting device id '); } - } - ); + ); + } } }); From 00a8bd725f5925dbd4d404fd75ecc28d798bb693 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Mon, 12 Aug 2024 13:52:40 +0530 Subject: [PATCH 04/22] addressed review comments --- cypress/support/constants/constants.js | 1 + cypress/support/step_definitions/testSetup.js | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index b3ce01a4..6f8a1179 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -100,6 +100,7 @@ module.exports = { DEVICE_PLATFORM: 'device.platform', DEVICE_VIDEORESOLUTION: 'device.videoResolution', DISCOVERY_LAUNCH: 'discovery.launch', + DYNAMIC_DEVICE_DETAILS_MODULES: ['Device'], EMAIL: 'email', ENV_PLATFORM_SDK_VERSION: 'platformSdkVersion', ENV_PLATFORM: 'platform', diff --git a/cypress/support/step_definitions/testSetup.js b/cypress/support/step_definitions/testSetup.js index 4191b132..22719a6d 100644 --- a/cypress/support/step_definitions/testSetup.js +++ b/cypress/support/step_definitions/testSetup.js @@ -56,19 +56,21 @@ Given('the environment has been set up for {string} tests', (test) => { Cypress.env(CONSTANTS.IS_RPC_ONLY, true); } // fetch device details dynamically - if (Cypress.env(CONSTANTS.TEST_TYPE) == CONSTANTS.DEVICE_ENV) { - cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( - (response) => { - if (response) { - const method = CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCHDEVICEDETAILS; - const requestMap = { - method: method, - params: response, - }; - cy.sendMessagetoPlatforms(requestMap); + if (Cypress.env(CONSTANTS.FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG)) { + if (CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE))) { + cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( + (response) => { + if (response) { + const method = CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCHDEVICEDETAILS; + const requestMap = { + method: method, + params: response, + }; + cy.sendMessagetoPlatforms(requestMap); + } } - } - ); + ); + } } } }); From 70ae3a5ff5efe4c1a6967066ab29b9d98dcac8cb Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Mon, 12 Aug 2024 18:59:53 +0530 Subject: [PATCH 05/22] updated deviceContentValidation --- cypress/support/step_definitions/validations.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index ee1b4f6c..90edf9fc 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -64,6 +64,17 @@ Given( const expectingError = item.expectingError; const isNullCase = item.isNullCase || false; + for (let i = 0; i < contentObject.data.length; i++) { + if (contentObject.data[i].validations[0].mode == CONSTANTS.DEVICE_CONTENT_VALIDATION) { + const type = contentObject.data[i].validations[0].type; + if (Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type)) { + contentObject.data[i].validations[0].type = Cypress.env(CONSTANTS.DEVICE_DATA)[ + type + ]; + } + } + } + // If the app ID is not passed from the feature, the default app ID will be retrieved. appId = !appId ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) From ddb6a7ffe239262117b2ca9baff24e2c117d0555 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Mon, 12 Aug 2024 19:18:50 +0530 Subject: [PATCH 06/22] added documentation for deviceContentValidation --- cypress/support/step_definitions/validations.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cypress/support/step_definitions/validations.md b/cypress/support/step_definitions/validations.md index ad0ebf12..82a04021 100644 --- a/cypress/support/step_definitions/validations.md +++ b/cypress/support/step_definitions/validations.md @@ -412,3 +412,7 @@ While validating, if a key is present in both fcs-validation jsons (eg: cypress/ } ] } + +# Device Content Validation + +For deviceContentValidation, the source of truth is fetched from an external API, which is dependent on the configuration module or platform on which we are testing. For the validation part, an override module called "fetchDeviceDetails" is expected to be in configModule to fetch the device details with the corresponding APIs mentioned for each config. DeviceId is passed from fcs to this override module as the only parameter, which is later used for fetching device details in the "configHelper" module. \ No newline at end of file From 765a8f8cfd71789949b616da7021464c23dd4d6b Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Tue, 13 Aug 2024 10:06:20 +0530 Subject: [PATCH 07/22] updated constant file --- cypress/support/constants/constants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index 6f8a1179..a1ea01ad 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -353,6 +353,7 @@ module.exports = { PERFORMANCE_THRESHOLD_VALIDATOR: 'performance.fetchPerformanceThreshold', CREATE_MARKER: 'performance.createMarker', UNLOADAPP: 'fcs.unloadApp', + FETCHDEVICEDETAILS: 'fcs.fetchDeviceDetails', }, PERFORMANCE_METRICS: 'performanceMetrics', RESPONSE: 'Response: ', From 034e7d568cafe3d49ee073b84f09cf6ba8fed465 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Tue, 13 Aug 2024 10:55:59 +0530 Subject: [PATCH 08/22] updated constants file --- cypress/support/constants/constants.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index a1ea01ad..7bea75a7 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -84,6 +84,7 @@ module.exports = { DEVICEMODULEFORMAT: 'deviceModelFormat', DEVICE_AUDIO: 'device.audio', DEVICE_CONTENT_VALIDATION: 'deviceContentValidation', + DEVICE_DATA: 'deviceData', DEVICE_ENV: 'Device', DEVICE_FIRMWARE: 'Device Firmware', DEVICE_HDCP: 'device.hdcp', @@ -189,6 +190,7 @@ module.exports = { CUSTOM: 'custom', VALIDATION_FUNCTION: 'validationFunction', NOT_SUPPORTED: 'NOT_SUPPORTED', + FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG: 'fetch_device_details_dynamically', FIRST_PARTY_APPID: 'firstPartyAppId', GENERATE_HTML_REPORT: true, GETEVENTRESPONSE_ERROR_MSG: 'Received error: Requested listener not found', From a574958cc3efd40289dc533047e1ad27c4aabbb0 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Tue, 13 Aug 2024 14:15:44 +0530 Subject: [PATCH 09/22] updated validations.js --- .../support/step_definitions/validations.js | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index 90edf9fc..567900e4 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -64,13 +64,26 @@ Given( const expectingError = item.expectingError; const isNullCase = item.isNullCase || false; - for (let i = 0; i < contentObject.data.length; i++) { - if (contentObject.data[i].validations[0].mode == CONSTANTS.DEVICE_CONTENT_VALIDATION) { - const type = contentObject.data[i].validations[0].type; - if (Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type)) { - contentObject.data[i].validations[0].type = Cypress.env(CONSTANTS.DEVICE_DATA)[ - type - ]; + if (Cypress.env(CONSTANTS.FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG)) { + if ( + CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE)) + ) { + if (contentObject && contentObject.data) { + for (let i = 0; i < contentObject.data.length; i++) { + if ( + contentObject.data[i].validations[0].mode == CONSTANTS.DEVICE_CONTENT_VALIDATION + ) { + const type = contentObject.data[i].validations[0].type; + if ( + Cypress.env(CONSTANTS.DEVICE_DATA) && + Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type) + ) { + contentObject.data[i].validations[0].type = Cypress.env( + CONSTANTS.DEVICE_DATA + )[type]; + } + } + } } } } From 9aa65a25e5f0e735e2adb450b54cd0c4b4d88a3e Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Tue, 13 Aug 2024 14:29:30 +0530 Subject: [PATCH 10/22] removed deviceContentValidation check --- cypress/support/step_definitions/validations.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index 567900e4..feac3322 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -70,18 +70,14 @@ Given( ) { if (contentObject && contentObject.data) { for (let i = 0; i < contentObject.data.length; i++) { + const type = contentObject.data[i].validations[0].type; if ( - contentObject.data[i].validations[0].mode == CONSTANTS.DEVICE_CONTENT_VALIDATION + Cypress.env(CONSTANTS.DEVICE_DATA) && + Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type) ) { - const type = contentObject.data[i].validations[0].type; - if ( - Cypress.env(CONSTANTS.DEVICE_DATA) && - Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type) - ) { - contentObject.data[i].validations[0].type = Cypress.env( - CONSTANTS.DEVICE_DATA - )[type]; - } + contentObject.data[i].validations[0].type = Cypress.env(CONSTANTS.DEVICE_DATA)[ + type + ]; } } } From 3dac48b8a9a5d5970de08830e7c643948e57d21f Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Tue, 13 Aug 2024 15:18:24 +0530 Subject: [PATCH 11/22] updated validations.js --- cypress/support/step_definitions/validations.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index feac3322..c0cd1b6a 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -68,9 +68,16 @@ Given( if ( CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE)) ) { + let type; if (contentObject && contentObject.data) { for (let i = 0; i < contentObject.data.length; i++) { - const type = contentObject.data[i].validations[0].type; + if ( + contentObject.data[i].validations && + contentObject.data[i].validations[0] && + contentObject.data[i].validations[0].type + ) { + type = contentObject.data[i].validations[0].type; + } if ( Cypress.env(CONSTANTS.DEVICE_DATA) && Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type) From 61fdbc3b63d0be97ad25c2b1ab9eb0b05fc391d2 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 14 Aug 2024 11:38:29 +0530 Subject: [PATCH 12/22] removed fetch_device_details env --- cypress/support/constants/constants.js | 1 - cypress/support/step_definitions/testSetup.js | 26 +++++++++---------- .../support/step_definitions/validations.js | 10 +++---- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index 7bea75a7..d99b6165 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -190,7 +190,6 @@ module.exports = { CUSTOM: 'custom', VALIDATION_FUNCTION: 'validationFunction', NOT_SUPPORTED: 'NOT_SUPPORTED', - FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG: 'fetch_device_details_dynamically', FIRST_PARTY_APPID: 'firstPartyAppId', GENERATE_HTML_REPORT: true, GETEVENTRESPONSE_ERROR_MSG: 'Received error: Requested listener not found', diff --git a/cypress/support/step_definitions/testSetup.js b/cypress/support/step_definitions/testSetup.js index 22719a6d..b9105453 100644 --- a/cypress/support/step_definitions/testSetup.js +++ b/cypress/support/step_definitions/testSetup.js @@ -56,21 +56,19 @@ Given('the environment has been set up for {string} tests', (test) => { Cypress.env(CONSTANTS.IS_RPC_ONLY, true); } // fetch device details dynamically - if (Cypress.env(CONSTANTS.FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG)) { - if (CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE))) { - cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( - (response) => { - if (response) { - const method = CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCHDEVICEDETAILS; - const requestMap = { - method: method, - params: response, - }; - cy.sendMessagetoPlatforms(requestMap); - } + if (CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE))) { + cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( + (response) => { + if (response) { + const method = CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCHDEVICEDETAILS; + const requestMap = { + method: method, + params: response, + }; + cy.sendMessagetoPlatforms(requestMap); } - ); - } + } + ); } } }); diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index c0cd1b6a..25b7fae8 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -64,9 +64,10 @@ Given( const expectingError = item.expectingError; const isNullCase = item.isNullCase || false; - if (Cypress.env(CONSTANTS.FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG)) { + if (CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE))) { if ( - CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE)) + Cypress.env(CONSTANTS.DEVICE_DATA) && + Object.keys(Cypress.env(CONSTANTS.DEVICE_DATA)).length > 0 ) { let type; if (contentObject && contentObject.data) { @@ -78,10 +79,7 @@ Given( ) { type = contentObject.data[i].validations[0].type; } - if ( - Cypress.env(CONSTANTS.DEVICE_DATA) && - Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type) - ) { + if (Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type)) { contentObject.data[i].validations[0].type = Cypress.env(CONSTANTS.DEVICE_DATA)[ type ]; From 1325275bea319c6cee16d96b136a9152282655f4 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 14 Aug 2024 12:29:36 +0530 Subject: [PATCH 13/22] updated validations.md file with eg: --- .../support/step_definitions/validations.md | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cypress/support/step_definitions/validations.md b/cypress/support/step_definitions/validations.md index 8015988d..65584ee0 100644 --- a/cypress/support/step_definitions/validations.md +++ b/cypress/support/step_definitions/validations.md @@ -446,9 +446,25 @@ While validating, if a key is present in both fcs-validation jsons (eg: cypress/ ] } -# Device Content Validation +# Dynamic Content Validation + +For deviceContentValidation, the source of truth is fetched from an external API, which is dependent on the configuration module or platform on which we are testing. For the validation part, an override module called "fetchDeviceDetails" is expected to be in configModule to fetch the device details with the corresponding Urls mentioned for each config to fetch the data. DeviceId is passed from fcs to this override module as the only parameter, which is later used for fetching device details in the "configHelper" module. + +The fetched data from configHelper is returned to corresponding configModule where the required data is extracted and saved to an env called "DEVICE_DATA". The data from configHelper is saved to this env as an object with the key names as the validation-key. +Initially, it maps to required object with the key as "deviceMac", if the device data is having multiple objects. +Later, for eg:, if deviceId and deviceType values are to be extracted, we will save the value into "DEVICEID" and "DEVICE_TYPE" keynames, as these are the keynames used in the validationObject. +For eg:, if activeDevicedata is the device response, the data extraction will be as follows : + +#### Format + +``` + if (activeDevicedata.id == deviceId) { + extractedData.DEVICEID = activeDevicedata.id; + extractedData.DEVICE_TYPE = activeDevicedata.data.deviceType; + } + Cypress.env(CONSTANTS.DEVICE_DATA, extractedData); +``` -For deviceContentValidation, the source of truth is fetched from an external API, which is dependent on the configuration module or platform on which we are testing. For the validation part, an override module called "fetchDeviceDetails" is expected to be in configModule to fetch the device details with the corresponding APIs mentioned for each config. DeviceId is passed from fcs to this override module as the only parameter, which is later used for fetching device details in the "configHelper" module. ## Error Content Validation From 64c28eae2c680de645c27c6863bcdc7d94c00df0 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Mon, 19 Aug 2024 16:07:49 +0530 Subject: [PATCH 14/22] updated the dynamic device details fetch flow for deviceContentValidation --- cypress/plugins/testDataProcessor.js | 10 +---- cypress/support/constants/constants.js | 1 + cypress/support/step_definitions/testSetup.js | 26 ++++++------ .../support/step_definitions/validations.js | 41 +++++++++++-------- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/cypress/plugins/testDataProcessor.js b/cypress/plugins/testDataProcessor.js index a7826d30..5a8e38ef 100644 --- a/cypress/plugins/testDataProcessor.js +++ b/cypress/plugins/testDataProcessor.js @@ -280,14 +280,8 @@ function testDataHandler(requestType, dataIdentifier, fireboltObject) { if (!deviceMac) { logger.info('Falling back to default device data path'); } - let deviceData = fetchAndParseDataFromJson(deviceDataPath, data.type); - if (deviceData === CONSTANTS.NO_DATA) { - logger.info( - `Expected deviceData not found for ${data.type}. Returning ${data.type} as is.` - ); - deviceData = data.type; - } - data.type = deviceData; + const deviceData = fetchDataFromFile(deviceDataPath); + envVariables[CONSTANTS.DEVICE_DATA] = deviceData; break; default: diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index 93e6d79c..239aa87c 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -191,6 +191,7 @@ module.exports = { CUSTOM: 'custom', VALIDATION_FUNCTION: 'validationFunction', NOT_SUPPORTED: 'NOT_SUPPORTED', + FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG: 'fetch_device_details_dynamically', FIRST_PARTY_APPID: 'firstPartyAppId', GENERATE_HTML_REPORT: true, GETEVENTRESPONSE_ERROR_MSG: 'Received error: Requested listener not found', diff --git a/cypress/support/step_definitions/testSetup.js b/cypress/support/step_definitions/testSetup.js index 0e52d89e..8a4cc0b7 100644 --- a/cypress/support/step_definitions/testSetup.js +++ b/cypress/support/step_definitions/testSetup.js @@ -55,19 +55,21 @@ Given('the environment has been set up for {string} tests', (test) => { Cypress.env(CONSTANTS.IS_RPC_ONLY, true); } // fetch device details dynamically - if (CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE))) { - cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( - (response) => { - if (response) { - const method = CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCHDEVICEDETAILS; - const requestMap = { - method: method, - params: response, - }; - cy.sendMessagetoPlatforms(requestMap); + if (Cypress.env(CONSTANTS.FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG)) { + if (CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE))) { + cy.getDeviceData(CONSTANTS.DEVICE_ID, {}, CONSTANTS.ACTION_CORE.toLowerCase()).then( + (response) => { + if (response) { + const method = CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCHDEVICEDETAILS; + const requestMap = { + method: method, + params: response, + }; + cy.sendMessagetoPlatforms(requestMap); + } } - } - ); + ); + } } } }); diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index 97c27dfd..248bdddc 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -63,26 +63,31 @@ Given( : CONSTANTS.NULL_RESPONSE; const expectingError = item.expectingError; const isNullCase = item.isNullCase || false; - - if (CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE))) { + if (Cypress.env(CONSTANTS.FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG)) { if ( - Cypress.env(CONSTANTS.DEVICE_DATA) && - Object.keys(Cypress.env(CONSTANTS.DEVICE_DATA)).length > 0 + CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE)) ) { - let type; - if (contentObject && contentObject.data) { - for (let i = 0; i < contentObject.data.length; i++) { - if ( - contentObject.data[i].validations && - contentObject.data[i].validations[0] && - contentObject.data[i].validations[0].type - ) { - type = contentObject.data[i].validations[0].type; - } - if (Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type)) { - contentObject.data[i].validations[0].type = Cypress.env(CONSTANTS.DEVICE_DATA)[ - type - ]; + if ( + Cypress.env(CONSTANTS.DEVICE_DATA) && + Object.keys(Cypress.env(CONSTANTS.DEVICE_DATA)).length > 0 + ) { + let type; + if (contentObject && contentObject.data) { + for (let i = 0; i < contentObject.data.length; i++) { + if ( + contentObject.data[i].validations && + contentObject.data[i].validations[0] && + contentObject.data[i].validations[0].type && + contentObject.data[i].validations[0].mode == + CONSTANTS.DEVICE_CONTENT_VALIDATION + ) { + type = contentObject.data[i].validations[0].type; + if (Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type)) { + contentObject.data[i].validations[0].type = Cypress.env( + CONSTANTS.DEVICE_DATA + )[type]; + } + } } } } From 05aac2ebe1be477479a092475fd8b71b9912c25d Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Mon, 19 Aug 2024 16:14:34 +0530 Subject: [PATCH 15/22] added comments for each if condition in validations.js --- cypress/support/step_definitions/validations.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index 248bdddc..e738acf0 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -63,15 +63,19 @@ Given( : CONSTANTS.NULL_RESPONSE; const expectingError = item.expectingError; const isNullCase = item.isNullCase || false; + // if dynamic device details fetch flag is true if (Cypress.env(CONSTANTS.FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG)) { + // if the current module is in dynamic details fetch list if ( CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE)) ) { + // check if the dynamic device details env is present if ( Cypress.env(CONSTANTS.DEVICE_DATA) && Object.keys(Cypress.env(CONSTANTS.DEVICE_DATA)).length > 0 ) { let type; + // if the validation object used for current validation contains the required data if (contentObject && contentObject.data) { for (let i = 0; i < contentObject.data.length; i++) { if ( @@ -82,6 +86,7 @@ Given( CONSTANTS.DEVICE_CONTENT_VALIDATION ) { type = contentObject.data[i].validations[0].type; + // if the dynamic device details env contains the validation key if (Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type)) { contentObject.data[i].validations[0].type = Cypress.env( CONSTANTS.DEVICE_DATA From e8d42e7205d109b4ee4dd43d259345db84dea497 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Tue, 20 Aug 2024 15:16:40 +0530 Subject: [PATCH 16/22] addressed review comments for dynamic_details_fetch --- README.md | 23 +++++++++ .../support/step_definitions/validations.js | 51 ++++++++----------- .../support/step_definitions/validations.md | 15 ++++-- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index e5db23cf..e327b12a 100644 --- a/README.md +++ b/README.md @@ -462,3 +462,26 @@ If you want to use simplePubSub server as the means of communication for 3rd par 7. When running FCS include env variables: - deviceMac: `` - pubSubUrl: `ws://:8080` + +# Dynamic Content Validation + +For deviceContentValidation, the source of truth is fetched from an external API, which is dependent on the configuration module or platform on which we are testing. FCS expects source of truth to be generated for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js). Config module should have a request override in [requestModules] fcs.js file as fetchDeviceDetails function. This should fetch the data and return the data in below format. If deviceId, deviceType and distributor values are to be extracted, we will save the value into "DEVICEID", "DEVICE_TYPE" and "DEVICE_DISTRIBUTOR" keynames, as these are the keynames used in the validationObject. These values will be then replaced to the .json values which is saved in an environment variable "DEVICE_DATA" in fcs. +For eg:, if activeDevicedata is the device response, the data extraction will be as follows : + + +#### Format + +``` + if (activeDevicedata.id == deviceId) { + extractedData.DEVICEID = activeDevicedata.id; + extractedData.DEVICE_TYPE = activeDevicedata.data.deviceType; + extractedData.DEVICE_DISTRIBUTOR = deviceData[0].data.partner; + + } + Cypress.env(CONSTANTS.DEVICE_DATA, extractedData); +``` + +For the validation part, an env variable is expected in configModule as "FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG" which acts like a flag to indicate whether dynamic details fetching is enabled or not. And an override module called "fetchDeviceDetails" is expected to be in configModule to fetch the device details with the corresponding Urls mentioned for each config to fetch the data. DeviceId is passed from fcs to this override module as the only parameter, which is later used for extracting device details. + +The fetched data from configHelper is returned to corresponding configModule where the required data is extracted and saved to an env called "DEVICE_DATA" where the existing mac.json values are overriden with dynamic values. The data from configHelper is saved to this env as an object with the key names as the validation-key.If the data is having multiple objects, the required device details are fetched by mapping with corresponding deviceId which is passed from fcs to configModule. + diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index 3db7def8..f8e6e704 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -63,36 +63,27 @@ Given( : CONSTANTS.NULL_RESPONSE; const expectingError = item.expectingError; const isNullCase = item.isNullCase || false; - // if dynamic device details fetch flag is true - if (Cypress.env(CONSTANTS.FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG)) { - // if the current module is in dynamic details fetch list - if ( - CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_TYPE)) - ) { - // check if the dynamic device details env is present - if ( - Cypress.env(CONSTANTS.DEVICE_DATA) && - Object.keys(Cypress.env(CONSTANTS.DEVICE_DATA)).length > 0 - ) { - let type; - // if the validation object used for current validation contains the required data - if (contentObject && contentObject.data) { - for (let i = 0; i < contentObject.data.length; i++) { - if ( - contentObject.data[i].validations && - contentObject.data[i].validations[0] && - contentObject.data[i].validations[0].type && - contentObject.data[i].validations[0].mode == - CONSTANTS.DEVICE_CONTENT_VALIDATION - ) { - type = contentObject.data[i].validations[0].type; - // if the dynamic device details env contains the validation key - if (Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type)) { - contentObject.data[i].validations[0].type = Cypress.env( - CONSTANTS.DEVICE_DATA - )[type]; - } - } + // check if the dynamic device details env is present + if ( + Cypress.env(CONSTANTS.DEVICE_DATA) && + Object.keys(Cypress.env(CONSTANTS.DEVICE_DATA)).length > 0 + ) { + let type; + // if the validation object used for current validation contains the required data + if (contentObject && contentObject.data) { + for (let i = 0; i < contentObject.data.length; i++) { + if ( + contentObject.data[i].validations && + contentObject.data[i].validations[0] && + contentObject.data[i].validations[0].type && + contentObject.data[i].validations[0].mode == CONSTANTS.DEVICE_CONTENT_VALIDATION + ) { + type = contentObject.data[i].validations[0].type; + // if the dynamic device details env contains the validation key + if (Cypress.env(CONSTANTS.DEVICE_DATA).hasOwnProperty(type)) { + contentObject.data[i].validations[0].type = Cypress.env(CONSTANTS.DEVICE_DATA)[ + type + ]; } } } diff --git a/cypress/support/step_definitions/validations.md b/cypress/support/step_definitions/validations.md index 75bbfc4e..cbb9de73 100644 --- a/cypress/support/step_definitions/validations.md +++ b/cypress/support/step_definitions/validations.md @@ -447,23 +447,28 @@ While validating, if a key is present in both fcs-validation jsons (eg: cypress/ # Dynamic Content Validation -For deviceContentValidation, the source of truth is fetched from an external API, which is dependent on the configuration module or platform on which we are testing. For the validation part, an override module called "fetchDeviceDetails" is expected to be in configModule to fetch the device details with the corresponding Urls mentioned for each config to fetch the data. DeviceId is passed from fcs to this override module as the only parameter, which is later used for fetching device details in the "configHelper" module. - -The fetched data from configHelper is returned to corresponding configModule where the required data is extracted and saved to an env called "DEVICE_DATA". The data from configHelper is saved to this env as an object with the key names as the validation-key. -Initially, it maps to required object with the key as "deviceMac", if the device data is having multiple objects. -Later, for eg:, if deviceId and deviceType values are to be extracted, we will save the value into "DEVICEID" and "DEVICE_TYPE" keynames, as these are the keynames used in the validationObject. +For deviceContentValidation, the source of truth is fetched from an external API, which is dependent on the configuration module or platform on which we are testing. FCS expects source of truth to be generated for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js). Config module should have a request override in [requestModules] fcs.js file as fetchDeviceDetails function. This should fetch the data and return the data in below format. If deviceId, deviceType and distributor values are to be extracted, we will save the value into "DEVICEID", "DEVICE_TYPE" and "DEVICE_DISTRIBUTOR" keynames, as these are the keynames used in the validationObject. These values will be then replaced to the .json values which is saved in an environment variable "DEVICE_DATA" in fcs. For eg:, if activeDevicedata is the device response, the data extraction will be as follows : + #### Format ``` if (activeDevicedata.id == deviceId) { extractedData.DEVICEID = activeDevicedata.id; extractedData.DEVICE_TYPE = activeDevicedata.data.deviceType; + extractedData.DEVICE_DISTRIBUTOR = deviceData[0].data.partner; + } Cypress.env(CONSTANTS.DEVICE_DATA, extractedData); ``` +For the validation part, an env variable is expected in configModule as "FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG" which acts like a flag to indicate whether dynamic details fetching is enabled or not. And an override module called "fetchDeviceDetails" is expected to be in configModule to fetch the device details with the corresponding Urls mentioned for each config to fetch the data. DeviceId is passed from fcs to this override module as the only parameter, which is later used for extracting device details. + +The fetched data from configHelper is returned to corresponding configModule where the required data is extracted and saved to an env called "DEVICE_DATA" where the existing mac.json values are overriden with dynamic values. The data from configHelper is saved to this env as an object with the key names as the validation-key.If the data is having multiple objects, the required device details are fetched by mapping with corresponding deviceId which is passed from fcs to configModule. + + + ## Error Content Validation From 4db89d6775e9387107b11a24f83f6d48038de9fc Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 21 Aug 2024 09:50:59 +0530 Subject: [PATCH 17/22] updated readme.doc --- README.md | 57 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index e327b12a..cb206212 100644 --- a/README.md +++ b/README.md @@ -398,6 +398,40 @@ HTTP call to the platform:
} ``` +### fetchDeviceDetails: + +- Request:
+ Making a call to fetch device details and the token required for fetching details dynamically.
+ + Format: + ``` + { + "method": "fcs.fetchDeviceDetails", + "params": + } + + ``` + Examples: + ``` + { + + "method": "fcs.fetchDeviceDetails", + "params": "354444327" + } + ``` +- Response:
+ Receives updated env variable of device_data with dynamic device details . + Example: + + ``` + { + "DEVICEID": "354444327", + "DEVICE_TYPE": "ipstb", + "DEVICE_MODEL": "VALUE", + ... +} + ``` + ## Interaction Log service See [Interaction_Logs,md](/Docs//Interaction_Logs.md) @@ -462,26 +496,3 @@ If you want to use simplePubSub server as the means of communication for 3rd par 7. When running FCS include env variables: - deviceMac: `` - pubSubUrl: `ws://:8080` - -# Dynamic Content Validation - -For deviceContentValidation, the source of truth is fetched from an external API, which is dependent on the configuration module or platform on which we are testing. FCS expects source of truth to be generated for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js). Config module should have a request override in [requestModules] fcs.js file as fetchDeviceDetails function. This should fetch the data and return the data in below format. If deviceId, deviceType and distributor values are to be extracted, we will save the value into "DEVICEID", "DEVICE_TYPE" and "DEVICE_DISTRIBUTOR" keynames, as these are the keynames used in the validationObject. These values will be then replaced to the .json values which is saved in an environment variable "DEVICE_DATA" in fcs. -For eg:, if activeDevicedata is the device response, the data extraction will be as follows : - - -#### Format - -``` - if (activeDevicedata.id == deviceId) { - extractedData.DEVICEID = activeDevicedata.id; - extractedData.DEVICE_TYPE = activeDevicedata.data.deviceType; - extractedData.DEVICE_DISTRIBUTOR = deviceData[0].data.partner; - - } - Cypress.env(CONSTANTS.DEVICE_DATA, extractedData); -``` - -For the validation part, an env variable is expected in configModule as "FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG" which acts like a flag to indicate whether dynamic details fetching is enabled or not. And an override module called "fetchDeviceDetails" is expected to be in configModule to fetch the device details with the corresponding Urls mentioned for each config to fetch the data. DeviceId is passed from fcs to this override module as the only parameter, which is later used for extracting device details. - -The fetched data from configHelper is returned to corresponding configModule where the required data is extracted and saved to an env called "DEVICE_DATA" where the existing mac.json values are overriden with dynamic values. The data from configHelper is saved to this env as an object with the key names as the validation-key.If the data is having multiple objects, the required device details are fetched by mapping with corresponding deviceId which is passed from fcs to configModule. - From 4bff98822d5f56d4c8ac6da5a7cb6cb6387ac6a6 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 21 Aug 2024 11:50:08 +0530 Subject: [PATCH 18/22] updated validations.md file with dynamic details fetch doc --- .../support/step_definitions/validations.md | 66 +++++++++++++++++-- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/cypress/support/step_definitions/validations.md b/cypress/support/step_definitions/validations.md index cbb9de73..69671288 100644 --- a/cypress/support/step_definitions/validations.md +++ b/cypress/support/step_definitions/validations.md @@ -447,9 +447,46 @@ While validating, if a key is present in both fcs-validation jsons (eg: cypress/ # Dynamic Content Validation -For deviceContentValidation, the source of truth is fetched from an external API, which is dependent on the configuration module or platform on which we are testing. FCS expects source of truth to be generated for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js). Config module should have a request override in [requestModules] fcs.js file as fetchDeviceDetails function. This should fetch the data and return the data in below format. If deviceId, deviceType and distributor values are to be extracted, we will save the value into "DEVICEID", "DEVICE_TYPE" and "DEVICE_DISTRIBUTOR" keynames, as these are the keynames used in the validationObject. These values will be then replaced to the .json values which is saved in an environment variable "DEVICE_DATA" in fcs. -For eg:, if activeDevicedata is the device response, the data extraction will be as follows : +### Background: +For the fixture validations mentioned in [Supported Validations](./validations.md#supported-validations), deviceContentValidation is used when the validation is done based on device specific value. +For eg : + +``` + "DEVICE_ID": { + "data": [ + { + "type": "fixture", + "validations": [ + { + "mode": "deviceContentValidation", + "type": "DEVICEID", + "description": "Validation of the Device Id Format" + } + ] + } + ] + } + +``` + +When the validation mode is "deviceContentValidation", the source of truth for the validation can be taken in two ways: +1. Static data +2. Dynamic data + +Static data : +For the static data, the source of truth is saved in file placed in [here](../../fixtures/external/devices/) based on deviceMac value we are testing currently. And later when the test starts, these values will be saved as an object in an env variable "deviceData". If the deviceMac.json is not found in the mentioned path, the values will be saved as it is , for eg : DEVICEID: "DEVICEID" + +Dynamic data : +For the dynamic data, the source of truth is fetched from configModule's override function called "fetchDeviceDetails" explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). +### Usage : +For fetching dynamic data from configModule, we have to set an env "fetch_device_details_dynamically" as true in the [supportConfig.json](../../../supportConfig.json). If this env is true, based on the platform, the dynamic details will be fetched from configModule and then overrides the existing env variable "deviceData" which is the static data of saved when the test starts. +If the dynamic device details fetching fails in configModule, the data will be the static data fetched as it is. FCS expects source of truth to be generated for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js). + +### Implementation : +Config module should have a override function "fetchDeviceDetails" explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). This function should fetch the data and return the data in below format. If deviceId, deviceType and distributor values are to be extracted, we will save the value into "DEVICEID", "DEVICE_TYPE" and "DEVICE_DISTRIBUTOR" keynames, as these are the keynames used in the validationObject. These values will be then replaced to the values which is saved in an environment variable "DEVICE_DATA" in fcs. +When the test starts, deviceId is passed from fcs to this override function for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js) as the only parameter, which is later used for extracting device details. If the data is having multiple objects, the required device details are fetched by mapping with corresponding deviceId which is passed from fcs to configModule. +For eg:, if activeDevicedata is the device response, the data extraction will be as follows : #### Format @@ -463,11 +500,26 @@ For eg:, if activeDevicedata is the device response, the data extraction will be Cypress.env(CONSTANTS.DEVICE_DATA, extractedData); ``` -For the validation part, an env variable is expected in configModule as "FETCH_DEVICE_DETAILS_DYNAMICALLY_FLAG" which acts like a flag to indicate whether dynamic details fetching is enabled or not. And an override module called "fetchDeviceDetails" is expected to be in configModule to fetch the device details with the corresponding Urls mentioned for each config to fetch the data. DeviceId is passed from fcs to this override module as the only parameter, which is later used for extracting device details. - -The fetched data from configHelper is returned to corresponding configModule where the required data is extracted and saved to an env called "DEVICE_DATA" where the existing mac.json values are overriden with dynamic values. The data from configHelper is saved to this env as an object with the key names as the validation-key.If the data is having multiple objects, the required device details are fetched by mapping with corresponding deviceId which is passed from fcs to configModule. - - +### Example : +From fcs, the override function is invoked in the below format : + Format: + ``` + { + "method": "fcs.fetchDeviceDetails", + "params": + } + +The response by overriding the static values in env will be as : + Example: + + ``` + { + "DEVICEID": "354444327", + "DEVICE_TYPE": "ipstb", + "DEVICE_MODEL": "VALUE", + ... +} + ``` ## Error Content Validation From bf5710f965bbb54019267b17ae169c3950ba03fe Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 21 Aug 2024 15:46:19 +0530 Subject: [PATCH 19/22] updated validations.md file --- .../support/step_definitions/validations.md | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cypress/support/step_definitions/validations.md b/cypress/support/step_definitions/validations.md index 69671288..8c54cbbf 100644 --- a/cypress/support/step_definitions/validations.md +++ b/cypress/support/step_definitions/validations.md @@ -474,19 +474,24 @@ When the validation mode is "deviceContentValidation", the source of truth for t 2. Dynamic data Static data : -For the static data, the source of truth is saved in file placed in [here](../../fixtures/external/devices/) based on deviceMac value we are testing currently. And later when the test starts, these values will be saved as an object in an env variable "deviceData". If the deviceMac.json is not found in the mentioned path, the values will be saved as it is , for eg : DEVICEID: "DEVICEID" +For static data, the source of truth is stored in a file placed [here](../../fixtures/external/devices/) based on the deviceMac value being tested. When the test begins, these values are loaded into an object stored in an environment variable called deviceData. If deviceMac.json is not found in the specified path, the values are saved as they are, for example: DEVICEID: "DEVICEID". Dynamic data : -For the dynamic data, the source of truth is fetched from configModule's override function called "fetchDeviceDetails" explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). +For dynamic data, the source of truth is fetched from the configModule's override function called "fetchDeviceDetails" explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). ### Usage : -For fetching dynamic data from configModule, we have to set an env "fetch_device_details_dynamically" as true in the [supportConfig.json](../../../supportConfig.json). If this env is true, based on the platform, the dynamic details will be fetched from configModule and then overrides the existing env variable "deviceData" which is the static data of saved when the test starts. -If the dynamic device details fetching fails in configModule, the data will be the static data fetched as it is. FCS expects source of truth to be generated for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js). + +To fetch dynamic data from configModule, set an environment variable fetch_device_details_dynamically as true in the [supportConfig.json](../../../supportConfig.json). If this environment variable is true, dynamic details will be fetched from configModule based on the platform and override the existing environment variable deviceData, which holds the static data from . + +If the dynamic device details fetching fails in configModule, the data will default to the static data. FCS expects the source of truth to be generated for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js). + ### Implementation : -Config module should have a override function "fetchDeviceDetails" explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). This function should fetch the data and return the data in below format. If deviceId, deviceType and distributor values are to be extracted, we will save the value into "DEVICEID", "DEVICE_TYPE" and "DEVICE_DISTRIBUTOR" keynames, as these are the keynames used in the validationObject. These values will be then replaced to the values which is saved in an environment variable "DEVICE_DATA" in fcs. -When the test starts, deviceId is passed from fcs to this override function for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js) as the only parameter, which is later used for extracting device details. If the data is having multiple objects, the required device details are fetched by mapping with corresponding deviceId which is passed from fcs to configModule. -For eg:, if activeDevicedata is the device response, the data extraction will be as follows : + +The configModule should have an override function "fetchDeviceDetails" as explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). This function should fetch the data and return it in the format specified below. If deviceId, deviceType, and distributor values need to be extracted, they should be saved as "DEVICEID", "DEVICE_TYPE", and "DEVICE_DISTRIBUTOR" keys, as these are the key names used in the validationObject. These values will then replace the values in stored in the environment variable "DEVICE_DATA" in FCS. + +When the test starts, deviceId is passed from FCS to this override function for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js) as the only parameter, which is later used to extract device details. If the data contains multiple objects, the required device details are fetched by mapping them with the corresponding deviceId passed from FCS to configModule. +For example, if activeDevicedata is the dynamic device response, the data extraction will be as follows: #### Format @@ -501,16 +506,16 @@ For eg:, if activeDevicedata is the device response, the data extraction will be ``` ### Example : -From fcs, the override function is invoked in the below format : - Format: +From FCS, the override function is invoked in the following format: +Format: ``` { "method": "fcs.fetchDeviceDetails", "params": } -The response by overriding the static values in env will be as : - Example: +The response by overriding the static values in the environment will be as follows: +Example: ``` { From c5585fb81598ae864f18ab2712213d48fd8be841 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 21 Aug 2024 15:49:34 +0530 Subject: [PATCH 20/22] updated readme file with fetchDeviceDetails override function --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cb206212..5ba8174d 100644 --- a/README.md +++ b/README.md @@ -401,7 +401,7 @@ HTTP call to the platform:
### fetchDeviceDetails: - Request:
- Making a call to fetch device details and the token required for fetching details dynamically.
+ Making a call to fetch device details and the token required for dynamically fetching details .
Format: ``` @@ -420,8 +420,8 @@ HTTP call to the platform:
} ``` - Response:
- Receives updated env variable of device_data with dynamic device details . - Example: + Receives the updated environment variable device_data with dynamic device details. +Example: ``` { From 6ccbf02943c6446d0a16834340b33ecdf523cc52 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Thu, 22 Aug 2024 09:43:46 +0530 Subject: [PATCH 21/22] addressed review comments for documentation --- Docs/Request_Overrides.md | 183 ++++++++++++++++++ README.md | 178 +---------------- .../support/step_definitions/validations.js | 6 +- 3 files changed, 188 insertions(+), 179 deletions(-) create mode 100644 Docs/Request_Overrides.md diff --git a/Docs/Request_Overrides.md b/Docs/Request_Overrides.md new file mode 100644 index 00000000..84be5a09 --- /dev/null +++ b/Docs/Request_Overrides.md @@ -0,0 +1,183 @@ +# Request overrides + +## fetchPerformanceThreshold: + +- Request:
+ Makes an HTTP request to graphite with deviceMac, processType with how much percentile, and from what time to fetch the metrics.
+ Format: + ``` + { + method: 'performance.fetchPerformanceThreshold', + params: {'type': '<(device|process|all)>', process: '<(memory|load|set size|required)>', percentile: 70, threshold: ''} + } + ``` + Examples: + ``` + { + method: 'performance.fetchPerformanceThreshold', + params: {'type': 'device', process: 'memory', percentile: 70, threshold: '35000000'} + } + { + method: 'performance.fetchPerformanceThreshold', + params: {'type': 'process', process: 'set size', percentile: 70, threshold: '75000000'} + } + { + method: 'performance.fetchPerformanceThreshold', + params: {'type': 'all', process: 'required', percentile: 70, threshold: '75000000'} + } + ``` +- Response:
+ Receives an array of objects, which contains success and message properties, success defines the execution is a success or failure and message defines either response or any custom message that descibes the pass/fail. + Example: + ``` + [ + { + "success": true, + "message": "Expected received threshold for set sizeRSS is 37748736 to be less than the expected threshold of 1073741824" + }, + { + "success": true, + "message": "Expected received threshold for set sizePSS is 41964544 to be less than the expected threshold of 1073741824" + } + ] + ``` + +## createMarker: + +- Request:
+ Making an HTTP call to grafana to create a marker on dashboard with given description.
+ Format: + ``` + { + method: 'performance.createMarker', + params: + } + ``` + Examples: + ``` + { + method: 'performance.createMarker', + params: 'Account.id - Positive Scenario: Validate account ID' + } + ``` +- Response:
+ Recieves an object with success and message properties. + Example: + ``` + { + "success": true, + "message": "Marker has been created successfully" + } + { + "success": false, + "message": `Unable to create marker, failed with status code- 200 and error- unable to find the dashboard` + } + ``` + +## setTestProvider: + +- Request:
+ Making a call which sends necessary message to the platform to use a test provider for simulating user inputs.
+ Format: + ``` + { + method: 'fcs.setTestProvider', + params: + } + ``` + Examples: + ``` + { + method: 'fcs.setTestProvider', + params: 'pinChallenge' + } + ``` +- Response:
+ Receives an object with intent message. + Example: + ``` + { + "action": "search", + "context": { + "source": "device" + }, + "data": { + "query": "{\"task\":\"registerProviderHandler\",\"params\":{\"provider\":\"pinChallenge\"},\"action\":\"CORE\",\"context\":{\"communicationMode\":\"SDK\"},\"asynchronous\":false}" + } + } + ``` + +## recordLifecycleHistory: + +- Request:
+ Making a call to the platform to start/stop the lifecycle history recording.
+ Format: + ``` + { + "method": "fcs.recordLifecycleHistory", + "params": { + "task": "", + "appId": "" + } + } + + ``` + Examples: + ``` + { + "method": "fcs.recordLifecycleHistory", + "params": { + "task": "start", + "appId": "test" + } + } + ``` +- Response:
+ Receives an object with intent message and transport type. + Example: + ``` + "transport": "", + "payload": { + "action": "search", + "context": { + "source": "device" + }, + "data": { + "query": "{\"task\":\"start\",\"params\":{\"provider\":\"pinChallenge\"},\"action\":\"CORE\",\"context\":{\"communicationMode\":\"SDK\"},\"asynchronous\":false}" + } + } + ``` + +## fetchDeviceDetails: + +- Request:
+ Making a call to fetch device details and the token required for dynamically fetching details .
+ + Format: + ``` + { + "method": "fcs.fetchDeviceDetails", + "params": + } + + ``` + Examples: + ``` + { + + "method": "fcs.fetchDeviceDetails", + "params": "354444327" + } + ``` +- Response:
+ Receives the updated environment variable device_data with dynamic device details. +Example: + + ``` + { + "DEVICEID": "354444327", + "DEVICE_TYPE": "ipstb", + "DEVICE_MODEL": "VALUE", + ... +} + ``` diff --git a/README.md b/README.md index 5ba8174d..1fca1099 100644 --- a/README.md +++ b/README.md @@ -253,184 +253,8 @@ HTTP call to the platform:
## Request overrides -### fetchPerformanceThreshold: +Documentation added in [Request_Overrides.md](/Docs/Request_Overrides.md) -- Request:
- Makes an HTTP request to graphite with deviceMac, processType with how much percentile, and from what time to fetch the metrics.
- Format: - ``` - { - method: 'performance.fetchPerformanceThreshold', - params: {'type': '<(device|process|all)>', process: '<(memory|load|set size|required)>', percentile: 70, threshold: ''} - } - ``` - Examples: - ``` - { - method: 'performance.fetchPerformanceThreshold', - params: {'type': 'device', process: 'memory', percentile: 70, threshold: '35000000'} - } - { - method: 'performance.fetchPerformanceThreshold', - params: {'type': 'process', process: 'set size', percentile: 70, threshold: '75000000'} - } - { - method: 'performance.fetchPerformanceThreshold', - params: {'type': 'all', process: 'required', percentile: 70, threshold: '75000000'} - } - ``` -- Response:
- Receives an array of objects, which contains success and message properties, success defines the execution is a success or failure and message defines either response or any custom message that descibes the pass/fail. - Example: - ``` - [ - { - "success": true, - "message": "Expected received threshold for set sizeRSS is 37748736 to be less than the expected threshold of 1073741824" - }, - { - "success": true, - "message": "Expected received threshold for set sizePSS is 41964544 to be less than the expected threshold of 1073741824" - } - ] - ``` -### createMarker: - -- Request:
- Making an HTTP call to grafana to create a marker on dashboard with given description.
- Format: - ``` - { - method: 'performance.createMarker', - params: - } - ``` - Examples: - ``` - { - method: 'performance.createMarker', - params: 'Account.id - Positive Scenario: Validate account ID' - } - ``` -- Response:
- Recieves an object with success and message properties. - Example: - ``` - { - "success": true, - "message": "Marker has been created successfully" - } - { - "success": false, - "message": `Unable to create marker, failed with status code- 200 and error- unable to find the dashboard` - } - ``` - ### setTestProvider: - -- Request:
- Making a call which sends necessary message to the platform to use a test provider for simulating user inputs.
- Format: - ``` - { - method: 'fcs.setTestProvider', - params: - } - ``` - Examples: - ``` - { - method: 'fcs.setTestProvider', - params: 'pinChallenge' - } - ``` -- Response:
- Receives an object with intent message. - Example: - ``` - { - "action": "search", - "context": { - "source": "device" - }, - "data": { - "query": "{\"task\":\"registerProviderHandler\",\"params\":{\"provider\":\"pinChallenge\"},\"action\":\"CORE\",\"context\":{\"communicationMode\":\"SDK\"},\"asynchronous\":false}" - } - } - ``` -### recordLifecycleHistory: - -- Request:
- Making a call to the platform to start/stop the lifecycle history recording.
- Format: - ``` - { - "method": "fcs.recordLifecycleHistory", - "params": { - "task": "", - "appId": "" - } - } - - ``` - Examples: - ``` - { - "method": "fcs.recordLifecycleHistory", - "params": { - "task": "start", - "appId": "test" - } - } - ``` -- Response:
- Receives an object with intent message and transport type. - Example: - ``` - "transport": "", - "payload": { - "action": "search", - "context": { - "source": "device" - }, - "data": { - "query": "{\"task\":\"start\",\"params\":{\"provider\":\"pinChallenge\"},\"action\":\"CORE\",\"context\":{\"communicationMode\":\"SDK\"},\"asynchronous\":false}" - } - } - ``` - -### fetchDeviceDetails: - -- Request:
- Making a call to fetch device details and the token required for dynamically fetching details .
- - Format: - ``` - { - "method": "fcs.fetchDeviceDetails", - "params": - } - - ``` - Examples: - ``` - { - - "method": "fcs.fetchDeviceDetails", - "params": "354444327" - } - ``` -- Response:
- Receives the updated environment variable device_data with dynamic device details. -Example: - - ``` - { - "DEVICEID": "354444327", - "DEVICE_TYPE": "ipstb", - "DEVICE_MODEL": "VALUE", - ... -} - ``` ## Interaction Log service diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index f8e6e704..8c06ccf3 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -18,7 +18,7 @@ import { Given, Then } from '@badeball/cypress-cucumber-preprocessor'; const CONSTANTS = require('../constants/constants'); const { _ } = Cypress; -import UTILS from '../cypress-support/src/utils'; +import UTILS, { fireLog } from '../cypress-support/src/utils'; /** * @module validations @@ -63,7 +63,7 @@ Given( : CONSTANTS.NULL_RESPONSE; const expectingError = item.expectingError; const isNullCase = item.isNullCase || false; - // check if the dynamic device details env is present + // check if the device details env is present if ( Cypress.env(CONSTANTS.DEVICE_DATA) && Object.keys(Cypress.env(CONSTANTS.DEVICE_DATA)).length > 0 @@ -88,6 +88,8 @@ Given( } } } + } else { + fireLog.info('deviceData environment variable does not have the required data'); } // If the app ID is not passed from the feature, the default app ID will be retrieved. From c0be880434c877ce32d2840061d13f126293cbbf Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Mon, 26 Aug 2024 11:18:24 +0530 Subject: [PATCH 22/22] added dynamicContentValidations.md --- .../dynamicContentValidations.md | 92 +++++++++++++++++++ .../support/step_definitions/validations.md | 85 +---------------- 2 files changed, 96 insertions(+), 81 deletions(-) create mode 100644 cypress/support/step_definitions/dynamicContentValidations.md diff --git a/cypress/support/step_definitions/dynamicContentValidations.md b/cypress/support/step_definitions/dynamicContentValidations.md new file mode 100644 index 00000000..09f0ccc8 --- /dev/null +++ b/cypress/support/step_definitions/dynamicContentValidations.md @@ -0,0 +1,92 @@ +# Dynamic Content Validation + +### Background: +While executing the validations step in fcs tests, there are mainly seven modes of validation, which are mentioned in [Supported Validations](./validations.md#supported-validations). Out of these seven, deviceContentValidation is used when the validation is to be done based on device specific value of the device which we are currently testing on. +While executing the test, the validation key will be fetched from the cypress/fixtures/fireboltCalls/ folder based on the current executing module. For example, if the "expected device id" is the validation key used in the validation step, it will be placed in the device.json file inside the fireboltCalls folder as: + +``` + "EXPECTED_DEVICE_ID": { + "method": "device.id", + "validationJsonPath": "result", + "content": + + } +``` +Later, the content specified in this object is searched inside the cypress/fixtures/objects/validationObjects/ folder, and it is expected to be in the following format: + +``` + + : { + "data": [ + { + "type": "fixture", + "validations": [ + { + "mode": "deviceContentValidation", + "type": "DEVICEID", + "description": "Validation of the Device Id Format" + } + ] + } + ] + }, +``` + +In the validationObject, when the validation mode is "deviceContentValidation", the source of truth for the validation can be one of the following two ways: +1. Static data +2. Dynamic data + +Static data : +For static data, the source of truth is stored in a file placed inside configModule's cypress/fixtures/devices/ folder, based on the deviceMac value of the device currently being tested. When the test begins, these values are loaded into an object and stored in an environment variable called "deviceData". If deviceMac.json is not found in the specified path, the values are saved as they are, for example: DEVICEID as "DEVICEID". + +Dynamic data : +For dynamic data, the source of truth is fetched from the configModule's override function called "fetchDeviceDetails" explained in [Request overrides](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). + +### Dynamic data usage : + +To fetch dynamic data from configModule, we have to set an environment variable called "fetch_device_details_dynamically" as true in the config.json file inside configModule's (constants/) folder. If this environment variable is true, dynamic device details will be fetched from configModule's override function called "fetchDeviceDetails". Later, the static data saved in "deviceData" environment variable will be overriden with the dynamic data fetched from the override fucntion. If the dynamic device details fetching fails in configModule, the data will default to the static data. +FCS expects the source of truth to be generated for the modules listed in constant "DYNAMIC_DEVICE_DETAILS_MODULES" inside [constants.js file](../constants/constants.js). + + +### Dynamic data implementation : + +The configModule should have an override function "fetchDeviceDetails" as explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). So, if the "fetch_device_details_dynamically" is set to true and "fetchDeviceDetails" override function is implemented in configModule, when the test executes the step "Given the environment has been set up for '' tests", the "fetchDeviceDetails" override function is called if the "testType" is present in "DYNAMIC_DEVICE_DETAILS_MODULES" constant. + +In the override function "fetchDeviceDetails" the logic to fetch dynamic data is added as per platform's requirement using corresponding urls. Once dynamic data is fetched inside configModule, it is then saved into the "deviceData" environment variable, where the existing static data is overriden with the dynamic data. For eg:, from override function if we gets the values for deviceId, deviceType and distributor, we have to override the "deviceData" environment variable with these values as : + +#### Format + +``` + let deviceData = Cypress.env(CONSTANTS.DEVICE_DATA) #saves the env variable to "deviceData" + + deviceData.DEVICEID = deviceId; + deviceData.DEVICE_TYPE = deviceType; + deviceData.DEVICE_DISTRIBUTOR = distributor; + + Cypress.env(CONSTANTS.DEVICE_DATA, deviceData); #updated the env variable with dynamic data + +``` + +### Example : +From FCS, the override function is invoked in the following format: +Format: + ``` + { + "method": "fcs.fetchDeviceDetails", + "params": + } + +The response by overriding the static values in the environment will be as follows: +Example: + +``` + { + "DEVICEID": "12345", + "DEVICE_TYPE": "xxxxxx", + "DEVICE_DISTRIBUTOR": "xxxxxx", + ... +} + +``` + +Here, "deviceId" is the only parameter we are passing from fcs while invoking override function, as this value might be used to extract the required data, if dynamic response contains more than one value. diff --git a/cypress/support/step_definitions/validations.md b/cypress/support/step_definitions/validations.md index 8c54cbbf..e49b3621 100644 --- a/cypress/support/step_definitions/validations.md +++ b/cypress/support/step_definitions/validations.md @@ -408,6 +408,10 @@ The 'schemaOnly` validation type allows to skip content validation and stops at } ``` +# Dynamic Content Validation + +Documentation added in [dynamicContentValidations.md](./dynamicContentValidations.md) + # Validation Override ## Format @@ -445,87 +449,6 @@ While validating, if a key is present in both fcs-validation jsons (eg: cypress/ ] } -# Dynamic Content Validation - -### Background: -For the fixture validations mentioned in [Supported Validations](./validations.md#supported-validations), deviceContentValidation is used when the validation is done based on device specific value. -For eg : - -``` - "DEVICE_ID": { - "data": [ - { - "type": "fixture", - "validations": [ - { - "mode": "deviceContentValidation", - "type": "DEVICEID", - "description": "Validation of the Device Id Format" - } - ] - } - ] - } - -``` - -When the validation mode is "deviceContentValidation", the source of truth for the validation can be taken in two ways: -1. Static data -2. Dynamic data - -Static data : -For static data, the source of truth is stored in a file placed [here](../../fixtures/external/devices/) based on the deviceMac value being tested. When the test begins, these values are loaded into an object stored in an environment variable called deviceData. If deviceMac.json is not found in the specified path, the values are saved as they are, for example: DEVICEID: "DEVICEID". - -Dynamic data : -For dynamic data, the source of truth is fetched from the configModule's override function called "fetchDeviceDetails" explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). - -### Usage : - -To fetch dynamic data from configModule, set an environment variable fetch_device_details_dynamically as true in the [supportConfig.json](../../../supportConfig.json). If this environment variable is true, dynamic details will be fetched from configModule based on the platform and override the existing environment variable deviceData, which holds the static data from . - -If the dynamic device details fetching fails in configModule, the data will default to the static data. FCS expects the source of truth to be generated for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js). - - -### Implementation : - -The configModule should have an override function "fetchDeviceDetails" as explained [here](https://github.com/rdkcentral/firebolt-certification-suite?tab=readme-ov-file#request-overrides). This function should fetch the data and return it in the format specified below. If deviceId, deviceType, and distributor values need to be extracted, they should be saved as "DEVICEID", "DEVICE_TYPE", and "DEVICE_DISTRIBUTOR" keys, as these are the key names used in the validationObject. These values will then replace the values in stored in the environment variable "DEVICE_DATA" in FCS. - -When the test starts, deviceId is passed from FCS to this override function for the modules listed in [DYNAMIC_DEVICE_DETAILS_MODULES](../constants/constants.js) as the only parameter, which is later used to extract device details. If the data contains multiple objects, the required device details are fetched by mapping them with the corresponding deviceId passed from FCS to configModule. -For example, if activeDevicedata is the dynamic device response, the data extraction will be as follows: - -#### Format - -``` - if (activeDevicedata.id == deviceId) { - extractedData.DEVICEID = activeDevicedata.id; - extractedData.DEVICE_TYPE = activeDevicedata.data.deviceType; - extractedData.DEVICE_DISTRIBUTOR = deviceData[0].data.partner; - - } - Cypress.env(CONSTANTS.DEVICE_DATA, extractedData); -``` - -### Example : -From FCS, the override function is invoked in the following format: -Format: - ``` - { - "method": "fcs.fetchDeviceDetails", - "params": - } - -The response by overriding the static values in the environment will be as follows: -Example: - - ``` - { - "DEVICEID": "354444327", - "DEVICE_TYPE": "ipstb", - "DEVICE_MODEL": "VALUE", - ... -} - ``` - ## Error Content Validation