Skip to content

Commit

Permalink
feat: Add validation to ensure that the app launched is in foreground (
Browse files Browse the repository at this point in the history
  • Loading branch information
PreethiMaai authored Dec 3, 2024
1 parent d497320 commit 0132a0f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
42 changes: 42 additions & 0 deletions Docs/Request_Overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,46 @@ Example:
{status: "fail"}
]
}
```

## getAppState:

### Request override
- The `getAppState` request override sends message to the platform to retrieve the status of all apps. This function should be added in config module `requestModules/fcs.js` file.

#### Request format for getAppState request override function:

```javascript
{
method: 'fcs.getAppState',
params: {
appId: <'appid'>
}
}
```

**Example:**

```javascript
{
method: 'fcs.getAppState',
params: {
appId:'foo'
}
}
```
### Response override

- The `getAppState` returns the state of the app (e.g., foreground, background, etc.) based on the appId. This function should be added in config module `responseModules/fcs.js` file.

#### Return response format of getAppState response override function:

```javascript
'fireboltState'
```

**Example:** Response override function returning the fireboltState of the app based on the appId.

```javascript
'FOREGROUND'
```
2 changes: 2 additions & 0 deletions cypress/support/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ module.exports = {
UNLOADAPP: 'fcs.unloadApp',
FETCHDEVICEDETAILS: 'fcs.fetchDeviceDetails',
SCREENSHOT: 'fcs.screenshot',
GETAPPSTATE: 'fcs.getAppState',
},
REQUEST_MAP_INTERACTIONS_SERVICE: 'Request map for firebolt interactions service : ',
RESPONSE: 'Response: ',
Expand Down Expand Up @@ -511,6 +512,7 @@ module.exports = {
SCENARIO_NAME: 'scenarioName',
FIREBOLT_INTERACTION: 'FireboltInteraction',
PENDING_FEATURES: 'pendingFeatures',
FOREGROUND: 'FOREGROUND',
PERFORMANCE_VALIDATION: 'performanceValidation',
MARKER_CREATION_STATUS: 'markerCreationStatus',
};
Expand Down
5 changes: 4 additions & 1 deletion cypress/support/cypress-support/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ export default class Config {
? (fireboltResponse = JSON.stringify(fireboltResponse))
: fireboltResponse;

fireLog.info('Original Response to be converted to firebolt equivalent: ' + fireboltResponse);
fireLog.info(
'Original Response to be converted to firebolt equivalent: ' +
fireboltResponse.replace(/\s|\\n?/g, '')
);
// If we've gotten to this point, we have a config override. Call it and return its response
return methodConfig(fireboltResponse);
}
Expand Down
20 changes: 20 additions & 0 deletions cypress/support/step_definitions/dynamicCalls.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,26 @@ Given(
* Given 'third party app is launched' on 'auth' page
*/
Given(/'(.+)' on '(.+)' page/, (validationObjectKey, page) => {
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)}`);

// Sending the request to the platform to retrieve the app state.
cy.sendMessagetoPlatforms(requestMap).then((response) => {
if (response.toUpperCase() === CONSTANTS.FOREGROUND) {
fireLog.info(
`State validation successful: Current state of ${appId} app is ${response} as expected`
);
} else {
fireLog.fail(
`State validation failed: Current state of ${appId} app is ${response}, expected to be ${CONSTANTS.FOREGROUND}.`
);
}
});

// Storing the page name in runtime environment variable to use it in the validations.
if (Cypress.env(CONSTANTS.RUNTIME)) {
Cypress.env(CONSTANTS.RUNTIME).page = page;
Expand Down

0 comments on commit 0132a0f

Please sign in to comment.