Skip to content

Commit

Permalink
Merge pull request #145 from rdkcentral/FIRECERT-2128
Browse files Browse the repository at this point in the history
User triggers event implementation
  • Loading branch information
Abhishk123 authored Jul 23, 2024
2 parents 6e5f32f + dcbb87a commit c0140ae
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 23 deletions.
3 changes: 2 additions & 1 deletion cypress/TestCases/FireboltCertification/Device.feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Feature: Device
Then 'Firebolt' platform responds to '1st party app' for 'set device name to kitchen'
And 'Firebolt' platform does not trigger event for 'onDeviceNameChanged'

@Device @coreSDK @sdk @transport @notSupported
@Device @coreSDK @sdk @transport @requiresPlatformImplementation @notSupported
Scenario Outline: Device.network - Positive Scenario: <Scenario>
When '3rd party app' registers for the 'device onNetworkChanged' event using the 'Firebolt' API
And '3rd party app' invokes the 'Firebolt' API to 'fetch device network'
Expand All @@ -67,3 +67,4 @@ Feature: Device
| Validate network_Ethernet_disconnected | device network as ethernet disconnected | onNetworkChanged with ethernet disconnected | onNetworkChanged events with ethernet disconnected |
| Validate network_Hybrid_connected | device network as hybrid connected | onNetworkChanged with hybrid connected | onNetworkChanged events with hybrid connected |
| Validate network_Hybrid_disconnected | device network as hybrid disconnected | onNetworkChanged with hybrid disconnected | onNetworkChanged events with hybrid disconnected |

16 changes: 8 additions & 8 deletions cypress/TestCases/FireboltCertification/SecondScreen.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ Feature: Secondscreen
Then 'Firebolt' platform responds to '1st party app' for 'set friendlyName to guest room'
And 'Firebolt' platform does not trigger event for 'onFriendlyNameChanged'

@Secondscreen @coreSDK @regression @sdk @notSupported
@Secondscreen @coreSDK @regression @sdk @requiresPlatformImplementation @notSupported
Scenario Outline: Secondscreen.<EventName> - Positive Scenario: Validating event name in response
When '3rd party app' registers for the '<RegisteredEvent>' event using the 'Firebolt' API
And User triggers event with value as '<EventParams>'
Then 'Firebolt' platform responds with '<Event_Validation_Key>'
Then 'Firebolt' platform triggers event '<Event_Validation_Key>'

Examples:
| EventName | RegisteredEvent | Event_Validation_Key | EventParams |
| onLaunchRequest | secondscreen onLaunchRequest | expected secondscreen onLaunchRequest event | onLaunchRequest event |
| onLaunchRequest | secondscreen onLaunchRequest | expected secondscreen onLaunchRequest event | onLaunchRequest event |
| onCloseRequest | secondscreen onCloseRequest | expected secondscreen onCloseRequest event | onCloseRequest event |
| onCloseRequest | secondscreen onCloseRequest | expected secondscreen onCloseRequest event | onCloseRequest event |
| EventName | RegisteredEvent | Event_Validation_Key | EventParams |
| onLaunchRequest | secondscreen onLaunchRequest | secondscreen onLaunchRequest event | onLaunchRequest event |
| onLaunchRequest | secondscreen onLaunchRequest | secondscreen onLaunchRequest event | onLaunchRequest event |
| onCloseRequest | secondscreen onCloseRequest | secondscreen onCloseRequest event | onCloseRequest event |
| onCloseRequest | secondscreen onCloseRequest | secondscreen onCloseRequest event | onCloseRequest event |

@Secondscreen @coreSDK @regression @sdk @notSupported @requiresPlatformImplementation
@Secondscreen @coreSDK @regression @sdk @requiresPlatformImplementation @notSupported
Scenario Outline: Secondscreen.<Event_Name> - Positive Scenario: Validating event Clearing listeners
When '3rd party app' registers for the '<Registered_Event>' event using the 'Firebolt' API
And I clear '<Clear_Event_Name>' listeners
Expand Down
6 changes: 3 additions & 3 deletions cypress/fixtures/fireboltCalls/secondscreen.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@
"content": "INVALID_REQUEST",
"expectingError": true
},
"EXPECTED_SECONDSCREEN_ONLAUNCHREQUEST_EVENT": {
"SECONDSCREEN_ONLAUNCHREQUEST_EVENT": {
"event": "secondscreen.onLaunchRequest",
"validationJsonPath": "eventResponse",
"content": "SECONDSCREEN_ONLAUNCHREQUEST"
"content": "SECONDSCREEN_ONLAUNCHREQUEST_TYPE_DIAL_WITH_TEST_DATA"
},
"EXPECTED_SECONDSCREEN_ONCLOSEREQUEST_EVENT": {
"SECONDSCREEN_ONCLOSEREQUEST_EVENT": {
"event": "secondscreen.onCloseRequest",
"validationJsonPath": "eventResponse",
"content": "SECONDSCREEN_ONCLOSEREQUEST"
Expand Down
4 changes: 2 additions & 2 deletions cypress/fixtures/modules/device.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@
"method": "device.onNetworkChanged",
"result": {
"state": "connected",
"type": "ethernet"
"type": "hybrid"
}
},
"ONNETWORKCHANGED_HYBRIDDISCONNECT_EVENTS": {
"method": "device.onNetworkChanged",
"result": {
"state": "disconnected",
"type": "ethernet"
"type": "hybrid"
}
}
}
5 changes: 5 additions & 0 deletions cypress/fixtures/modules/secondscreen.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"version": "1.7",
"data": "{\"code\":\"AQDPQZiQcb3KQ7gY7yy5tHTMbbkGHR9Zjp-KL53H3eKBZIeAt7O9UKYPu6B21l2UZVmIqkFXDXBmXvK4g2e3EgZtjMNmKPsTltgnRl95DImtOXjSpWtTjSaOkW4w1kZKUTwLKdwVWTzBVH8ERHorvLU6vCGOVHxXt65LNwdl5HKRweShVC1V9QsyvRnQS61ov0UclmrH_xZML2Bt-Q-rZFjey5MjwupIb4x4f53XUJMhjHpDHoIUKrjpdPDQvK2a\",\"friendlyName\":\"Operator_TX061AEI\",\"UDN\":\"608fef11-2800-482a-962b-23a6690c93c1\"}"
},
"ONLAUNCHREQUEST_TYPE_DIAL_WITH_TEST_DATA": {
"type": "dial",
"version": "1.7",
"data": "test"
},
"ONCLOSEREQUEST_TYPE_DIAL": {
"type": "dial",
"version": "1.7"
Expand Down
19 changes: 17 additions & 2 deletions cypress/fixtures/objects/validationObjects/secondscreen.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
}
]
},
"ONCLOSEREQUEST": {
"SECONDSCREEN_ONCLOSEREQUEST": {
"method": "secondscreen.onCloseRequest",
"data": [
{
Expand All @@ -73,6 +73,21 @@
]
}
]
},

"SECONDSCREEN_ONLAUNCHREQUEST_TYPE_DIAL_WITH_TEST_DATA": {
"method": "secondscreen.onCloseRequest",
"data": [
{
"type": "fixture",
"validations": [
{
"mode": "staticContentValidation",
"type": "SECONDSCREEN_ONLAUNCHREQUEST_TYPE_DIAL_WITH_TEST_DATA",
"description": "Validation of the Secondscreen onLaunchRequest event"
}
]
}
]
}

}
4 changes: 4 additions & 0 deletions cypress/support/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = {
COMBINEVALIDATIONOBJECTSJSON: 'combineValidationObjectsJson',
COMMUNICATION_MODE: 'communicationMode',
CONFIG: 'CONFIG',
CONFIG_IMPLEMENTATION_MISSING: 'Config module implementation missing',
CONFIG_MODULE_SETRESPONSE_PATH: 'cypress/fixtures/external/setResponseData.json',
CONTENT: 'Content',
CONTEXT: 'Context',
Expand Down Expand Up @@ -328,6 +329,7 @@ module.exports = {
RECORD_LIFECYCLE_HISTORY: 'fcs.recordLifecycleHistory',
SETPERFORMANCETESTHANDLER: 'performance.setPerformanceTestHandler',
SETLIFECYCLESTATE: 'fcs.setLifecycleState',
TRIGGEREVENT: 'fcs.triggerEvent',
FETCH_EVENT_RESPONSE: 'fcs.fetchEventResponse',
PERFORMANCE_THRESHOLD_VALIDATOR: 'performance.fetchPerformanceThreshold',
CREATE_MARKER: 'performance.createMarker',
Expand Down Expand Up @@ -462,6 +464,8 @@ module.exports = {
SECONDARY_THIRD_PARTY_APP_ID: 'secondary3rdPartyAppId',
SECONDARY_APPID_MISSING_ERROR:
'`Unable to find the ${envAppIdKey} value in the env, please add the value in configModule/constants/config.json`',
SET_EVENT_REQUEST: 'Request sent to set event values in platform: ',
SET_EVENT_SUCCESS: 'Event value set successfully in platform',
};
function getSanityReportPath() {
// Check if Cypress is defined, for cypress test context
Expand Down
23 changes: 17 additions & 6 deletions cypress/support/step_definitions/fireboltCalls.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,25 @@ Given(
);

/**
* @function User triggers event with value '{}}'
* @description sending message to platform to make post call to set values.
* @param {String} key - Name of event to be called.
* @function User triggers event with value as '(.+)'
* @description sending message to platform to make post call to set event values.
* @param {String} key - key name of the event data
* @example
* And User triggers event with value as ' DEVICE_ONHDCPCHANGED_EVENTS'
* And User triggers event with value as 'onNetworkChanged events with wifi connected'
*/
Given(/User triggers event with value as '(.+)'/, (key) => {
fireLog.info(CONSTANTS.STEP_DEFINITION_NEEDS_TO_IMPLEMENT).then(() => {
throw new Error(CONSTANTS.STEP_IMPLEMENTATION_MISSING);
cy.fireboltDataParser(key).then((parsedData) => {
const value = parsedData[0].params;
const requestMap = {
method: CONSTANTS.REQUEST_OVERRIDE_CALLS.TRIGGEREVENT,
params: { value: value },
};
cy.log(CONSTANTS.SET_EVENT_REQUEST + JSON.stringify(requestMap)).then(() => {
cy.sendMessagetoPlatforms(requestMap).then((result) => {
if (result) {
console.log(CONSTANTS.SET_EVENT_SUCCESS);
}
});
});
});
});
12 changes: 12 additions & 0 deletions cypress/support/step_definitions/fireboltCalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,15 @@ Note: Key name value is an object and it can contains data as below

### Examples:
* `And I clear 'clear accessibility.onClosedCaptionsSettingsChanged' listeners`

## User triggers event with value as '(.+)'

### Purpose: sending message to platform to make post call to set event values.

### Params:
| Param | Definition |
| --- | --- |
| key | key name of the event data |

### Examples:
* `And User triggers event with value as 'onNetworkChanged events with wifi connected'`
28 changes: 27 additions & 1 deletion defaultModule/requestModules/fcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,30 @@ function fetchEventResponse(parsedParam) {
}
}

module.exports = { setResponse, setTestProvider, setLifecycleState, fetchEventResponse };
/**
* @module fcs
* @function triggerEvent
* @description sending message to platform to make post call to set event values.
* @param {String} key - key name of the event data
* @example
* triggerEvent({method: 'fcs.triggerevent', params: {'value': {
"method": "device.onNetworkChanged",
"result": {
"state": "disconnected",
"type": "ethernet"
}
}}})
*/
function triggerEvent(key) {
fireLog.info(CONSTANTS.CONFIG_IMPLEMENTATION_MISSING).then(() => {
throw new Error(CONSTANTS.CONFIG_IMPLEMENTATION_MISSING);
});
}

module.exports = {
setResponse,
setTestProvider,
setLifecycleState,
fetchEventResponse,
triggerEvent,
};

0 comments on commit c0140ae

Please sign in to comment.