From 911faedbe6c2798043c5344c0c7fb30756c7a89a Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Thu, 5 Dec 2024 17:12:01 +0530 Subject: [PATCH 01/18] added glue code for dismissing an app --- cypress/support/constants/constants.js | 1 + .../support/step_definitions/fireboltCalls.js | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index 34f4cdd3..684fe8b5 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -368,6 +368,7 @@ module.exports = { FETCHDEVICEDETAILS: 'fcs.fetchDeviceDetails', SCREENSHOT: 'fcs.screenshot', GETAPPSTATE: 'fcs.getAppState', + DISMISS: 'fcs.dismissApp', }, REQUEST_MAP_INTERACTIONS_SERVICE: 'Request map for firebolt interactions service : ', RESPONSE: 'Response: ', diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 5ec85a61..0cd82356 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -365,3 +365,63 @@ Given('device is rebooted', () => { throw new Error(CONSTANTS.STEP_IMPLEMENTATION_MISSING); }); }); + +/** + * @module fireboltCalls + * @function And 3rd party '(.+)' app is dismissed + * @description To dismiss the launched app + * @param {String} app - app name. + * @example + * And 3rd party 'firebolt' app is dismissed + */ +Given(/3rd party '(.+)' app is dismissed$/, async (app) => { + let appId = Cypress.env(CONSTANTS.RUNTIME).appId + let KeyPressSequence + if (Cypress.env(CONSTANTS.RUNTIME) && Cypress.env(CONSTANTS.RUNTIME).intent && Cypress.env(CONSTANTS.RUNTIME).intent.keyPressSequence) { + KeyPressSequence = Cypress.env(CONSTANTS.RUNTIME).intent.keyPressSequence + } else if (Cypress.env('app_metadata') && Cypress.env('app_metadata')[appId] && Cypress.env('app_metadata')[appId].defaultKeyPressSequence) { + KeyPressSequence = Cypress.env('app_metadata')[appId].defaultKeyPressSequence + } else if (Cypress.env('app_metadata') && Cypress.env('app_metadata').defaultKeyPressSequence) { + KeyPressSequence = Cypress.env('app_metadata').defaultKeyPressSequence + } else { + throw new Error("No KeyPressSequence "); + } + const requestMap = { + method: CONSTANTS.REQUEST_OVERRIDE_CALLS.DISMISS, + params: KeyPressSequence.dismiss, + }; + + cy.sendMessagetoPlatforms(requestMap).then((response) => { + fireLog.info("Response of app dismiss function ", JSON.stringify(response)) + }) +}) + +/** + * @module fireboltCalls + * @function And 3rd party '(.+)' app should be exited + * @description To validate that the app is dismissed + * @param {String} app - app name. + * @example + * Then 3rd party 'firebolt' app should be exited + */ +Given(/3rd party '(.+)' app should be exited$/, async (app) => { + const appId = Cypress.env(CONSTANTS.CURRENT_APP_ID); + const requestMap = { + method: CONSTANTS.REQUEST_OVERRIDE_CALLS.GETAPPSTATE, + params: appId, + }; + fireLog.info(`Sending request to fetch app state: ${JSON.stringify(requestMap)}`); + cy.sendMessagetoPlatforms(requestMap).then((response) => { + let responseString = JSON.stringify(response) + if (Object.keys(response).length === 0) { + fireLog.info( + `State validation successful: Current state of ${appId} app is ${responseString} as expected` + ); + } else { + fireLog.fail( + `${appId} app is not dismissed. Response :${responseString}` + ); + } + }) +}) + From 48d131cc401f135226462dd5c6e50d946094d0a7 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Thu, 5 Dec 2024 18:05:28 +0530 Subject: [PATCH 02/18] fixed lint issues --- .../support/step_definitions/fireboltCalls.js | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 0cd82356..7642a0ad 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -375,16 +375,24 @@ Given('device is rebooted', () => { * And 3rd party 'firebolt' app is dismissed */ Given(/3rd party '(.+)' app is dismissed$/, async (app) => { - let appId = Cypress.env(CONSTANTS.RUNTIME).appId - let KeyPressSequence - if (Cypress.env(CONSTANTS.RUNTIME) && Cypress.env(CONSTANTS.RUNTIME).intent && Cypress.env(CONSTANTS.RUNTIME).intent.keyPressSequence) { - KeyPressSequence = Cypress.env(CONSTANTS.RUNTIME).intent.keyPressSequence - } else if (Cypress.env('app_metadata') && Cypress.env('app_metadata')[appId] && Cypress.env('app_metadata')[appId].defaultKeyPressSequence) { - KeyPressSequence = Cypress.env('app_metadata')[appId].defaultKeyPressSequence + const appId = Cypress.env(CONSTANTS.RUNTIME).appId; + let KeyPressSequence; + if ( + Cypress.env(CONSTANTS.RUNTIME) && + Cypress.env(CONSTANTS.RUNTIME).intent && + Cypress.env(CONSTANTS.RUNTIME).intent.keyPressSequence + ) { + KeyPressSequence = Cypress.env(CONSTANTS.RUNTIME).intent.keyPressSequence; + } else if ( + Cypress.env('app_metadata') && + Cypress.env('app_metadata')[appId] && + Cypress.env('app_metadata')[appId].defaultKeyPressSequence + ) { + KeyPressSequence = Cypress.env('app_metadata')[appId].defaultKeyPressSequence; } else if (Cypress.env('app_metadata') && Cypress.env('app_metadata').defaultKeyPressSequence) { - KeyPressSequence = Cypress.env('app_metadata').defaultKeyPressSequence + KeyPressSequence = Cypress.env('app_metadata').defaultKeyPressSequence; } else { - throw new Error("No KeyPressSequence "); + throw new Error('No KeyPressSequence '); } const requestMap = { method: CONSTANTS.REQUEST_OVERRIDE_CALLS.DISMISS, @@ -392,9 +400,9 @@ Given(/3rd party '(.+)' app is dismissed$/, async (app) => { }; cy.sendMessagetoPlatforms(requestMap).then((response) => { - fireLog.info("Response of app dismiss function ", JSON.stringify(response)) - }) -}) + fireLog.info('Response of app dismiss function ', JSON.stringify(response)); + }); +}); /** * @module fireboltCalls @@ -412,16 +420,13 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { }; fireLog.info(`Sending request to fetch app state: ${JSON.stringify(requestMap)}`); cy.sendMessagetoPlatforms(requestMap).then((response) => { - let responseString = JSON.stringify(response) + const responseString = JSON.stringify(response); if (Object.keys(response).length === 0) { fireLog.info( `State validation successful: Current state of ${appId} app is ${responseString} as expected` ); } else { - fireLog.fail( - `${appId} app is not dismissed. Response :${responseString}` - ); + fireLog.fail(`${appId} app is not dismissed. Response :${responseString}`); } - }) -}) - + }); +}); From c002b1b4fe9943a916c1d10761d212687fc3561f Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Fri, 6 Dec 2024 16:02:27 +0530 Subject: [PATCH 03/18] added screenshot and fireboltInteraction validations --- .../support/step_definitions/fireboltCalls.js | 73 ++++++++++++++++--- 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 7642a0ad..a799376d 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -413,20 +413,73 @@ Given(/3rd party '(.+)' app is dismissed$/, async (app) => { * Then 3rd party 'firebolt' app should be exited */ Given(/3rd party '(.+)' app should be exited$/, async (app) => { + // getAppState validation const appId = Cypress.env(CONSTANTS.CURRENT_APP_ID); - const requestMap = { + const requestMapForGetAppState = { method: CONSTANTS.REQUEST_OVERRIDE_CALLS.GETAPPSTATE, params: appId, }; - fireLog.info(`Sending request to fetch app state: ${JSON.stringify(requestMap)}`); - cy.sendMessagetoPlatforms(requestMap).then((response) => { - const responseString = JSON.stringify(response); - if (Object.keys(response).length === 0) { + fireLog.info(`Sending request to fetch app state: ${JSON.stringify(requestMapForGetAppState)}`); + cy.sendMessagetoPlatforms(requestMapForGetAppState) + .then((response) => { + const responseString = JSON.stringify(response); + if (Object.keys(response).length === 0) { + fireLog.info( + `State validation successful: Current state of ${appId} app is ${responseString} as expected` + ); + } else { + fireLog.fail(`${appId} app is not dismissed. Response :${responseString}`); + } + }) + .then(() => { + // screenShot validation + const requestMapForScreenShotValidation = { + method: CONSTANTS.REQUEST_OVERRIDE_CALLS.SCREENSHOT, + params: { + validations: [ + { + type: 'image', + label: 'home', + confidence: 50, + }, + ], + }, + }; fireLog.info( - `State validation successful: Current state of ${appId} app is ${responseString} as expected` + `Sending request to get screenshot : ${JSON.stringify(requestMapForScreenShotValidation)}` ); - } else { - fireLog.fail(`${appId} app is not dismissed. Response :${responseString}`); - } - }); + cy.sendMessagetoPlatforms(requestMapForScreenShotValidation).then((response) => { + fireLog.info('Screenshot Validation Response: ' + JSON.stringify(response)); + if (response.status != 'pass') { + fireLog.fail('Screenshot validation failed'); + } + }); + }) + .then(() => { + // fireboltInteraction validation + + const logs = UTILS.getEnvVariable(CONSTANTS.FB_INTERACTIONLOGS).getLogs( + Cypress.env(CONSTANTS.SCENARIO_NAME) + ); + console.log('logs', logs); + if (!logs) { + UTILS.fireLog.assert( + false, + `No interaction logs found for the scenario - ${Cypress.env(CONSTANTS.SCENARIO_NAME)}` + ); + } + const contentObject = { + logs: logs, + content: { + type: { + methods: { + 'lifecyclemanagement.session': [], + }, + }, + description: 'Validating of all methods interaction logs', + }, + }; + console.log('contentObject', contentObject); + cy.customValidation(fireboltData.content.data[0], contentObject); + }); }); From 8512334e3970854ab5e2b7b627ecf1e3bc35de74 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Fri, 6 Dec 2024 16:16:05 +0530 Subject: [PATCH 04/18] updated method name in interaction validation --- cypress/support/step_definitions/fireboltCalls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index a799376d..1c7825e1 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -473,7 +473,7 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { content: { type: { methods: { - 'lifecyclemanagement.session': [], + 'lifecycle.close': [], }, }, description: 'Validating of all methods interaction logs', From 0d0218e705214e90e0af39ed338dbd8b0ddc6c00 Mon Sep 17 00:00:00 2001 From: Abhishek urs C J Date: Fri, 6 Dec 2024 19:29:34 +0530 Subject: [PATCH 05/18] Added logs --- cypress/support/step_definitions/fireboltCalls.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 1c7825e1..769bdc21 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -374,7 +374,7 @@ Given('device is rebooted', () => { * @example * And 3rd party 'firebolt' app is dismissed */ -Given(/3rd party '(.+)' app is dismissed$/, async (app) => { +Given(/3rd party '(.+)' app is dismissed$/, async (appType) => { const appId = Cypress.env(CONSTANTS.RUNTIME).appId; let KeyPressSequence; if ( @@ -399,8 +399,11 @@ Given(/3rd party '(.+)' app is dismissed$/, async (app) => { params: KeyPressSequence.dismiss, }; + fireLog.info( + `Request sent to platform to dismiss the ${appId} app: ${JSON.stringify(requestMap)}` + ); cy.sendMessagetoPlatforms(requestMap).then((response) => { - fireLog.info('Response of app dismiss function ', JSON.stringify(response)); + fireLog.info(`Response from platform: ${JSON.stringify(response)}`); }); }); @@ -419,7 +422,7 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { method: CONSTANTS.REQUEST_OVERRIDE_CALLS.GETAPPSTATE, params: appId, }; - fireLog.info(`Sending request to fetch app state: ${JSON.stringify(requestMapForGetAppState)}`); + fireLog.info(`Sending request to fetch ${appId} app state: ${JSON.stringify(requestMapForGetAppState)}`); cy.sendMessagetoPlatforms(requestMapForGetAppState) .then((response) => { const responseString = JSON.stringify(response); @@ -433,6 +436,7 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { }) .then(() => { // screenShot validation + fireLog.info('Started Screenshot validation'); const requestMapForScreenShotValidation = { method: CONSTANTS.REQUEST_OVERRIDE_CALLS.SCREENSHOT, params: { @@ -451,7 +455,7 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { cy.sendMessagetoPlatforms(requestMapForScreenShotValidation).then((response) => { fireLog.info('Screenshot Validation Response: ' + JSON.stringify(response)); if (response.status != 'pass') { - fireLog.fail('Screenshot validation failed'); + fireLog.fail(`Screenshot validation failed ${response.validations}`); } }); }) From a4b6cbabce7aed3aee891181cd801447d8ee5884 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Tue, 10 Dec 2024 18:50:24 +0530 Subject: [PATCH 06/18] updated validation steps for dismissing an app --- .../support/step_definitions/fireboltCalls.js | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 769bdc21..8a0268e1 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -392,7 +392,7 @@ Given(/3rd party '(.+)' app is dismissed$/, async (appType) => { } else if (Cypress.env('app_metadata') && Cypress.env('app_metadata').defaultKeyPressSequence) { KeyPressSequence = Cypress.env('app_metadata').defaultKeyPressSequence; } else { - throw new Error('No KeyPressSequence '); + throw new Error(`Expected KeyPressSequence was not found for ${appId} in app_metadata.json`); } const requestMap = { method: CONSTANTS.REQUEST_OVERRIDE_CALLS.DISMISS, @@ -422,7 +422,9 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { method: CONSTANTS.REQUEST_OVERRIDE_CALLS.GETAPPSTATE, params: appId, }; - fireLog.info(`Sending request to fetch ${appId} app state: ${JSON.stringify(requestMapForGetAppState)}`); + fireLog.info( + `Sending request to fetch ${appId} app state: ${JSON.stringify(requestMapForGetAppState)}` + ); cy.sendMessagetoPlatforms(requestMapForGetAppState) .then((response) => { const responseString = JSON.stringify(response); @@ -440,13 +442,7 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { const requestMapForScreenShotValidation = { method: CONSTANTS.REQUEST_OVERRIDE_CALLS.SCREENSHOT, params: { - validations: [ - { - type: 'image', - label: 'home', - confidence: 50, - }, - ], + validations: Cypress.env(CONSTANTS.RUNTIME).fireboltCall.screenshot.validations, }, }; fireLog.info( @@ -474,16 +470,16 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { } const contentObject = { logs: logs, - content: { - type: { - methods: { - 'lifecycle.close': [], - }, - }, - description: 'Validating of all methods interaction logs', - }, + content: [ + Cypress.env(CONSTANTS.RUNTIME).fireboltCall.fireboltInteraction.content.data[0] + .validations[0], + ], }; + console.log('contentObject', contentObject); - cy.customValidation(fireboltData.content.data[0], contentObject); + cy.customValidation( + Cypress.env(CONSTANTS.RUNTIME).fireboltCall.fireboltInteraction, + contentObject + ); }); }); From d68d00287bdd44a3d26e999814984a39c342a0f3 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 11 Dec 2024 14:46:55 +0530 Subject: [PATCH 07/18] addressed review comments --- cypress/fixtures/intentTemplates.js | 2 -- cypress/support/step_definitions/fireboltCalls.js | 15 ++++----------- cypress/support/step_definitions/launchApp.js | 1 + 3 files changed, 5 insertions(+), 13 deletions(-) delete mode 100644 cypress/fixtures/intentTemplates.js diff --git a/cypress/fixtures/intentTemplates.js b/cypress/fixtures/intentTemplates.js deleted file mode 100644 index 68d83123..00000000 --- a/cypress/fixtures/intentTemplates.js +++ /dev/null @@ -1,2 +0,0 @@ -const firebolt = {}; -module.exports = { firebolt }; diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 8a0268e1..679c3ffe 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -394,15 +394,7 @@ Given(/3rd party '(.+)' app is dismissed$/, async (appType) => { } else { throw new Error(`Expected KeyPressSequence was not found for ${appId} in app_metadata.json`); } - const requestMap = { - method: CONSTANTS.REQUEST_OVERRIDE_CALLS.DISMISS, - params: KeyPressSequence.dismiss, - }; - - fireLog.info( - `Request sent to platform to dismiss the ${appId} app: ${JSON.stringify(requestMap)}` - ); - cy.sendMessagetoPlatforms(requestMap).then((response) => { + cy.exitAppSession('dismissApp', KeyPressSequence.dismiss).then((response) => { fireLog.info(`Response from platform: ${JSON.stringify(response)}`); }); }); @@ -468,17 +460,18 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { `No interaction logs found for the scenario - ${Cypress.env(CONSTANTS.SCENARIO_NAME)}` ); } + const app_type = Cypress.env(CONSTANTS.APP_TYPE); const contentObject = { logs: logs, content: [ - Cypress.env(CONSTANTS.RUNTIME).fireboltCall.fireboltInteraction.content.data[0] + Cypress.env(CONSTANTS.RUNTIME).fireboltCall[app_type].fireboltInteraction.content.data[0] .validations[0], ], }; console.log('contentObject', contentObject); cy.customValidation( - Cypress.env(CONSTANTS.RUNTIME).fireboltCall.fireboltInteraction, + Cypress.env(CONSTANTS.RUNTIME).fireboltCall[app_type].fireboltInteraction, contentObject ); }); diff --git a/cypress/support/step_definitions/launchApp.js b/cypress/support/step_definitions/launchApp.js index 61fdbeef..87c74bf2 100644 --- a/cypress/support/step_definitions/launchApp.js +++ b/cypress/support/step_definitions/launchApp.js @@ -36,6 +36,7 @@ import UTILS from '../cypress-support/src/utils'; Given( /3rd party '(.+)' app is launched(?: with '(.+)' appId)?(?: with '(.+)' state)?(?: with '(.+)' intent)?$/, (appType, appCallSign, state, intent) => { + Cypress.env(CONSTANTS.APP_TYPE, appType); if ( !UTILS.getEnvVariable(CONSTANTS.APP_LAUNCH_STATUS, false) || UTILS.getEnvVariable(CONSTANTS.LIFECYCLE_CLOSE_TEST_TYPES).includes( From 8c7aab6262401bef200dd9a3d5feb0bc3021fe62 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 11 Dec 2024 14:58:22 +0530 Subject: [PATCH 08/18] reverted intentTemplates.js changes --- cypress/fixtures/intentTemplates.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 cypress/fixtures/intentTemplates.js diff --git a/cypress/fixtures/intentTemplates.js b/cypress/fixtures/intentTemplates.js new file mode 100644 index 00000000..f5123fa3 --- /dev/null +++ b/cypress/fixtures/intentTemplates.js @@ -0,0 +1,3 @@ +const firebolt = { +}; +module.exports = { firebolt }; \ No newline at end of file From 2ad9d63c584645eff8407e09022ef5812d61100d Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 11 Dec 2024 15:02:13 +0530 Subject: [PATCH 09/18] fixed lint issues --- cypress/fixtures/intentTemplates.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cypress/fixtures/intentTemplates.js b/cypress/fixtures/intentTemplates.js index f5123fa3..68d83123 100644 --- a/cypress/fixtures/intentTemplates.js +++ b/cypress/fixtures/intentTemplates.js @@ -1,3 +1,2 @@ -const firebolt = { -}; -module.exports = { firebolt }; \ No newline at end of file +const firebolt = {}; +module.exports = { firebolt }; From b102e3b9581b0e9d464d8f148ad62a9721bdfdde Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Thu, 12 Dec 2024 20:32:56 +0530 Subject: [PATCH 10/18] updated the code with design change in getAppState --- cypress/support/constants/constants.js | 1 + .../support/step_definitions/dynamicCalls.js | 2 +- .../support/step_definitions/fireboltCalls.js | 52 +++++++------------ 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index 962cf13c..ccfd40c6 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -469,6 +469,7 @@ module.exports = { VALIDATIONJSONPATH: 'validationJsonPath', VARIABLES_PREFIX_LIST: 'variableObjectsPrefixLists', VERSION: 'version', + VISIBLE: 'VISIBLE', WRITE_FAILED: 'Unable to write report json to file', WRITE_TO_FILE: 'writeToFile', CENSOR_DATA_PATH: 'censorData.json', diff --git a/cypress/support/step_definitions/dynamicCalls.js b/cypress/support/step_definitions/dynamicCalls.js index e4fe9b0d..6393554d 100644 --- a/cypress/support/step_definitions/dynamicCalls.js +++ b/cypress/support/step_definitions/dynamicCalls.js @@ -404,7 +404,7 @@ Given(/'(.+)' (on|with) '(.+)' page/, (validationObjectKey, type, page) => { // Sending the request to the platform to retrieve the app state. cy.sendMessagetoPlatforms(requestMap).then((response) => { - if (response.toUpperCase() === CONSTANTS.FOREGROUND) { + if (response.appState.toUpperCase() === CONSTANTS.FOREGROUND) { fireLog.info( `State validation successful: Current state of ${appId} app is ${response} as expected` ); diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 679c3ffe..79756932 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -420,12 +420,24 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { cy.sendMessagetoPlatforms(requestMapForGetAppState) .then((response) => { const responseString = JSON.stringify(response); - if (Object.keys(response).length === 0) { - fireLog.info( - `State validation successful: Current state of ${appId} app is ${responseString} as expected` - ); - } else { - fireLog.fail(`${appId} app is not dismissed. Response :${responseString}`); + if (response && response.appState && response.visibilityState) { + if ( + response.appState.toUpperCase() === CONSTANTS.LIFECYCLE_STATES.INACTIVE && + response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE + ) { + fireLog.info( + `State validation successful: Current state of ${appId} app is ${responseString} as expected` + ); + } else if ( + !response.appState && + response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE + ) { + cy.log( + `State validation successful: Current state of ${appId} app is ${responseString} as expected` + ); + } else { + fireLog.fail(`${appId} app is not dismissed. Response :${responseString}`); + } } }) .then(() => { @@ -446,33 +458,5 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { fireLog.fail(`Screenshot validation failed ${response.validations}`); } }); - }) - .then(() => { - // fireboltInteraction validation - - const logs = UTILS.getEnvVariable(CONSTANTS.FB_INTERACTIONLOGS).getLogs( - Cypress.env(CONSTANTS.SCENARIO_NAME) - ); - console.log('logs', logs); - if (!logs) { - UTILS.fireLog.assert( - false, - `No interaction logs found for the scenario - ${Cypress.env(CONSTANTS.SCENARIO_NAME)}` - ); - } - const app_type = Cypress.env(CONSTANTS.APP_TYPE); - const contentObject = { - logs: logs, - content: [ - Cypress.env(CONSTANTS.RUNTIME).fireboltCall[app_type].fireboltInteraction.content.data[0] - .validations[0], - ], - }; - - console.log('contentObject', contentObject); - cy.customValidation( - Cypress.env(CONSTANTS.RUNTIME).fireboltCall[app_type].fireboltInteraction, - contentObject - ); }); }); From 50cd86e119f0f4eef413515d2a6d84d14543fe3b Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Fri, 13 Dec 2024 12:44:53 +0530 Subject: [PATCH 11/18] addressed review comments --- .../objects/appData/app_metadata.json | 17 ++++++ .../support/step_definitions/fireboltCalls.js | 57 ++++++++++++------- 2 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 cypress/fixtures/objects/appData/app_metadata.json diff --git a/cypress/fixtures/objects/appData/app_metadata.json b/cypress/fixtures/objects/appData/app_metadata.json new file mode 100644 index 00000000..80dc9ea6 --- /dev/null +++ b/cypress/fixtures/objects/appData/app_metadata.json @@ -0,0 +1,17 @@ +{ + "defaultKeyPressSequence": { + "dismiss": ["exit", "exit", "exit"] + }, + "appId": { + "intentName": { + "entityId": "", + "keyPressSequence": { + "dismiss": ["exit", "exit", "exit"] + } + }, + "defaultKeyPressSequence": { + "dismiss": ["exit", "exit", "exit"] + } + } + +} \ No newline at end of file diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 79756932..500691d1 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -378,21 +378,31 @@ Given(/3rd party '(.+)' app is dismissed$/, async (appType) => { const appId = Cypress.env(CONSTANTS.RUNTIME).appId; let KeyPressSequence; if ( + // Check if keyPressSequence is defined in the runtime environment variables for the specific intent Cypress.env(CONSTANTS.RUNTIME) && Cypress.env(CONSTANTS.RUNTIME).intent && Cypress.env(CONSTANTS.RUNTIME).intent.keyPressSequence ) { KeyPressSequence = Cypress.env(CONSTANTS.RUNTIME).intent.keyPressSequence; } else if ( + // Check if defaultKeyPressSequence is defined for the specific appId in app_metadata Cypress.env('app_metadata') && Cypress.env('app_metadata')[appId] && Cypress.env('app_metadata')[appId].defaultKeyPressSequence ) { KeyPressSequence = Cypress.env('app_metadata')[appId].defaultKeyPressSequence; - } else if (Cypress.env('app_metadata') && Cypress.env('app_metadata').defaultKeyPressSequence) { + } else if ( + // Check if defaultKeyPressSequence is defined in the app_metadata globally + Cypress.env('app_metadata') && + Cypress.env('app_metadata').defaultKeyPressSequence + ) { KeyPressSequence = Cypress.env('app_metadata').defaultKeyPressSequence; } else { - throw new Error(`Expected KeyPressSequence was not found for ${appId} in app_metadata.json`); + // If no keyPressSequence is found, throw an error with details from the app_metadata file + const configModuleConst = require('../../fixtures/objects/appData/app_metadata.json'); + throw new Error( + `Expected KeyPressSequence was not found for ${appId} in app_metadata.json. More details on app_metadata present in: ${configModuleConst}` + ); } cy.exitAppSession('dismissApp', KeyPressSequence.dismiss).then((response) => { fireLog.info(`Response from platform: ${JSON.stringify(response)}`); @@ -420,24 +430,31 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { cy.sendMessagetoPlatforms(requestMapForGetAppState) .then((response) => { const responseString = JSON.stringify(response); - if (response && response.appState && response.visibilityState) { - if ( - response.appState.toUpperCase() === CONSTANTS.LIFECYCLE_STATES.INACTIVE && - response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE - ) { - fireLog.info( - `State validation successful: Current state of ${appId} app is ${responseString} as expected` - ); - } else if ( - !response.appState && - response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE - ) { - cy.log( - `State validation successful: Current state of ${appId} app is ${responseString} as expected` - ); - } else { - fireLog.fail(`${appId} app is not dismissed. Response :${responseString}`); - } + if ( + // Check if response exists and contains appState, visibilityState + // and if appState is INACTIVE and visibilityState is VISIBLE + response && + response.appState && + response.visibilityState && + response.appState.toUpperCase() === CONSTANTS.LIFECYCLE_STATES.INACTIVE && + response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE + ) { + fireLog.info( + `State validation successful: Current state of ${appId} app is ${responseString} as expected` + ); + } else if ( + // Check if appState is missing, visibilityState exists, and visibilityState is VISIBLE + response && + !response.appState && + response.visibilityState && + response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE + ) { + cy.log( + `State validation successful: Current state of ${appId} app is ${responseString} as expected` + ); + } else { + // Log failure message if none of the above conditions are met + fireLog.fail(`${appId} app is not dismissed. Response :${responseString}`); } }) .then(() => { From 5a55bd13d79992334b789e70c72b295c090d3b16 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Fri, 13 Dec 2024 13:29:09 +0530 Subject: [PATCH 12/18] addressed review comments --- cypress/support/step_definitions/fireboltCalls.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 500691d1..e966015a 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -399,9 +399,9 @@ Given(/3rd party '(.+)' app is dismissed$/, async (appType) => { KeyPressSequence = Cypress.env('app_metadata').defaultKeyPressSequence; } else { // If no keyPressSequence is found, throw an error with details from the app_metadata file - const configModuleConst = require('../../fixtures/objects/appData/app_metadata.json'); + const appMetadataJSON = require('../../fixtures/objects/appData/app_metadata.json'); throw new Error( - `Expected KeyPressSequence was not found for ${appId} in app_metadata.json. More details on app_metadata present in: ${configModuleConst}` + `Expected KeyPressSequence was not found for ${appId} in app_metadata.json. More details on app_metadata present in: ${appMetadataJSON}` ); } cy.exitAppSession('dismissApp', KeyPressSequence.dismiss).then((response) => { From 422253638d80a60572a0b9b7c0e63fa825659409 Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Fri, 13 Dec 2024 16:09:53 +0530 Subject: [PATCH 13/18] updated log --- cypress/support/step_definitions/fireboltCalls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index e966015a..37a1034c 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -449,7 +449,7 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { response.visibilityState && response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE ) { - cy.log( + fireLog.info( `State validation successful: Current state of ${appId} app is ${responseString} as expected` ); } else { From 3799476a5af28163155c541103bbab00b4496aec Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Mon, 16 Dec 2024 14:09:06 +0530 Subject: [PATCH 14/18] updated logs in fireboltCalls.js file --- cypress/support/step_definitions/fireboltCalls.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 37a1034c..8af2d3b2 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -431,8 +431,8 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { .then((response) => { const responseString = JSON.stringify(response); if ( - // Check if response exists and contains appState, visibilityState - // and if appState is INACTIVE and visibilityState is VISIBLE + // Check if response exists and contains the dismissed app's appState, visibilityState of launcher screen + // and if the dismissed app's appState is INACTIVE and launcher screen's visibilityState is VISIBLE response && response.appState && response.visibilityState && @@ -440,21 +440,23 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE ) { fireLog.info( - `State validation successful: Current state of ${appId} app is ${responseString} as expected` + `State validation successful: Current state of ${appId} app is ${response.appState} and launcher screen's visibility state is ${response.visibilityState} ` ); } else if ( - // Check if appState is missing, visibilityState exists, and visibilityState is VISIBLE + // Check if the dismissed app's appState is missing, and launcher screen's visibilityState is VISIBLE response && !response.appState && response.visibilityState && response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE ) { fireLog.info( - `State validation successful: Current state of ${appId} app is ${responseString} as expected` + `State validation successful: Current state of ${appId} app is ${response.appState} and launcher screen's visibility state is ${response.visibilityState}` ); } else { // Log failure message if none of the above conditions are met - fireLog.fail(`${appId} app is not dismissed. Response :${responseString}`); + fireLog.fail( + `${appId} app is not dismissed. Current state of ${appId} app is ${response.appState} and launcher screen's visibility state is ${response.visibilityState}` + ); } }) .then(() => { From 0b50ad96e8f49d19e81973efb5106b2c3122d35c Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Mon, 16 Dec 2024 14:18:10 +0530 Subject: [PATCH 15/18] moved app_metadata sample structure to docs folder --- cypress/fixtures/{objects/appData => docs}/app_metadata.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cypress/fixtures/{objects/appData => docs}/app_metadata.json (100%) diff --git a/cypress/fixtures/objects/appData/app_metadata.json b/cypress/fixtures/docs/app_metadata.json similarity index 100% rename from cypress/fixtures/objects/appData/app_metadata.json rename to cypress/fixtures/docs/app_metadata.json From cc5ff750edff0a8a1e721d5642ff940ecedb567d Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Tue, 17 Dec 2024 16:13:15 +0530 Subject: [PATCH 16/18] updated the logs --- cypress/support/step_definitions/fireboltCalls.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index 8af2d3b2..faae6138 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -450,13 +450,11 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { response.visibilityState.toUpperCase() === CONSTANTS.VISIBLE ) { fireLog.info( - `State validation successful: Current state of ${appId} app is ${response.appState} and launcher screen's visibility state is ${response.visibilityState}` + `State validation successful: ${appId} app is dismissed and launcher screen's visibility state is ${response.visibilityState}` ); } else { // Log failure message if none of the above conditions are met - fireLog.fail( - `${appId} app is not dismissed. Current state of ${appId} app is ${response.appState} and launcher screen's visibility state is ${response.visibilityState}` - ); + fireLog.fail(`${appId} app is not dismissed. Response : ${response}`); } }) .then(() => { From 32be7a75d7bbb0ab76e3c3a1a86b214b89b15f4c Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Wed, 18 Dec 2024 12:03:26 +0530 Subject: [PATCH 17/18] updated logs --- cypress/support/step_definitions/fireboltCalls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index faae6138..e0aa5682 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -454,7 +454,7 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { ); } else { // Log failure message if none of the above conditions are met - fireLog.fail(`${appId} app is not dismissed. Response : ${response}`); + fireLog.fail(`${appId} app is not dismissed. Response : ${responseString}`); } }) .then(() => { From 7c9d8f145a36ca358935b328e8c037df2175f12b Mon Sep 17 00:00:00 2001 From: anjalimukundan Date: Thu, 19 Dec 2024 19:30:45 +0530 Subject: [PATCH 18/18] updated logs --- cypress/support/step_definitions/fireboltCalls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index e0aa5682..716c3663 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -472,7 +472,7 @@ Given(/3rd party '(.+)' app should be exited$/, async (app) => { cy.sendMessagetoPlatforms(requestMapForScreenShotValidation).then((response) => { fireLog.info('Screenshot Validation Response: ' + JSON.stringify(response)); if (response.status != 'pass') { - fireLog.fail(`Screenshot validation failed ${response.validations}`); + fireLog.fail(`Screenshot validation failed ${JSON.stringify(response.validations)}`); } }); });