Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support in env setup glue for fetching device details dynamically #188

Merged
merged 27 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
91083ee
added support in env setup glue for fetching device details dynamically
anjalimukundan Aug 6, 2024
e4e2ae7
addressed review comments for error handling msg
anjalimukundan Aug 7, 2024
03660a0
added support in fcs to fetch device details dynamically
anjalimukundan Aug 9, 2024
00a8bd7
addressed review comments
anjalimukundan Aug 12, 2024
70ae3a5
updated deviceContentValidation
anjalimukundan Aug 12, 2024
ddb6a7f
added documentation for deviceContentValidation
anjalimukundan Aug 12, 2024
765a8f8
updated constant file
anjalimukundan Aug 13, 2024
034e7d5
updated constants file
anjalimukundan Aug 13, 2024
a574958
updated validations.js
anjalimukundan Aug 13, 2024
25bc6c9
resolved conflicts
anjalimukundan Aug 13, 2024
9aa65a2
removed deviceContentValidation check
anjalimukundan Aug 13, 2024
3dac48b
updated validations.js
anjalimukundan Aug 13, 2024
61fdbc3
removed fetch_device_details env
anjalimukundan Aug 14, 2024
1325275
updated validations.md file with eg:
anjalimukundan Aug 14, 2024
4d17a6d
Merge branch 'dev' into fetch_device_details
anjalimukundan Aug 19, 2024
64c28ea
updated the dynamic device details fetch flow for deviceContentValida…
anjalimukundan Aug 19, 2024
05aac2e
added comments for each if condition in validations.js
anjalimukundan Aug 19, 2024
6ee0c9b
resolved conflicts
anjalimukundan Aug 20, 2024
e8d42e7
addressed review comments for dynamic_details_fetch
anjalimukundan Aug 20, 2024
4db89d6
updated readme.doc
anjalimukundan Aug 21, 2024
cd359a1
Merge branch 'dev' into fetch_device_details
anjalimukundan Aug 21, 2024
4bff988
updated validations.md file with dynamic details fetch doc
anjalimukundan Aug 21, 2024
bf5710f
updated validations.md file
anjalimukundan Aug 21, 2024
c5585fb
updated readme file with fetchDeviceDetails override function
anjalimukundan Aug 21, 2024
6ccbf02
addressed review comments for documentation
anjalimukundan Aug 22, 2024
c9a7083
Merge branch 'dev' into fetch_device_details
anjalimukundan Aug 26, 2024
c0be880
added dynamicContentValidations.md
anjalimukundan Aug 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cypress/support/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -99,6 +101,7 @@ module.exports = {
DEVICE_PLATFORM: 'device.platform',
DEVICE_VIDEORESOLUTION: 'device.videoResolution',
DISCOVERY_LAUNCH: 'discovery.launch',
DYNAMIC_DEVICE_DETAILS_MODULES: ['Device'],
EMAIL: 'email',
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
ENV_PLATFORM_SDK_VERSION: 'platformSdkVersion',
ENV_PLATFORM: 'platform',
Expand Down Expand Up @@ -351,6 +354,7 @@ module.exports = {
PERFORMANCE_THRESHOLD_VALIDATOR: 'performance.fetchPerformanceThreshold',
CREATE_MARKER: 'performance.createMarker',
UNLOADAPP: 'fcs.unloadApp',
FETCHDEVICEDETAILS: 'fcs.fetchDeviceDetails',
},
PERFORMANCE_METRICS: 'performanceMetrics',
RESPONSE: 'Response: ',
Expand Down
15 changes: 15 additions & 0 deletions cypress/support/step_definitions/testSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ 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
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
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);
}
}
);
}
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
}
});

Expand Down
25 changes: 25 additions & 0 deletions cypress/support/step_definitions/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@ Given(
const expectingError = item.expectingError;
const isNullCase = item.isNullCase || false;

neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
if (CONSTANTS.DYNAMIC_DEVICE_DETAILS_MODULES.includes(Cypress.env(CONSTANTS.TEST_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
) {
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
];
}
}
}
}
}
anjalimukundan marked this conversation as resolved.
Show resolved Hide resolved

// If the app ID is not passed from the feature, the default app ID will be retrieved.
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
appId = !appId
? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID)
Expand Down
19 changes: 19 additions & 0 deletions cypress/support/step_definitions/validations.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,25 @@ While validating, if a key is present in both fcs-validation jsons (eg: cypress/
]
}

# Dynamic Content Validation
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved

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);
```

neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved

## Error Content Validation

Expand Down
Loading