diff --git a/cypress/TestCases/FireboltCertification/Accessibility.feature b/cypress/TestCases/FireboltCertification/Accessibility.feature index a8da02f5a..1beb86d8e 100644 --- a/cypress/TestCases/FireboltCertification/Accessibility.feature +++ b/cypress/TestCases/FireboltCertification/Accessibility.feature @@ -1,65 +1,66 @@ Feature: Accessibility - Background: Launch FCA for 'Accessibility' - Given the environment has been set up for 'Accessibility' tests - And 3rd party 'certification' app is launched + Background: Launch FCA for 'Accessibility' + Given the environment has been set up for 'Accessibility' tests + And 3rd party 'certification' app is launched - @Accessibility @coreSDK @sdk @transport - Scenario Outline: Accessibility.closedCaptionsSettings - Positive Scenario: - When '3rd party app' registers for the 'accessibility onClosedCaptionsSettingsChanged' event using the 'Firebolt' API - And '3rd party app' invokes the 'Firebolt' API to 'get closedCaptions settings' - And 1st party app invokes the 'Firebolt' API to '' - Then 'Firebolt' platform responds to '1st party app' for '' - When '3rd party app' invokes the 'Firebolt' API to 'get closedCaptions settings' - Then 'Firebolt' platform responds with '' - And 'Firebolt' platform triggers event '' + @Accessibility @coreSDK @sdk @transport + Scenario Outline: Accessibility.closedCaptionsSettings - Positive Scenario: + Given we test the 'ACCESSIBILITY_CLOSEDCAPTIONS_SETTINGS' getters and setters '' to '' + When '3rd party app' registers for the 'Firebolt' event + When '3rd party app' invokes the 'Firebolt' get API + Given 1st party app invokes the 'Firebolt' API to set '' to '' + And 'Firebolt' platform responds to '1st party app' set API + When '3rd party app' invokes the 'Firebolt' get API + And 'Firebolt' platform responds to '3rd party app' get API + And 'Firebolt' platform triggers '3rd party app' event - Examples: - | Scenario | Key | Method_Content | Event_Content | - | Disable closedcaptions | disable closedCaptions | disabled for closedCaptions settings | onclosedCaptionsSettingsChanged with disabled | - | Enable closedcaptions | enable closedCaptions | enabled for closedCaptions settings | onclosedCaptionsSettingsChanged with enabled | - | Set fontFamily-monospaced_sanserif | set fontFamily to monospaced_sanserif | monospace sanserif for fontfamily in closedcaptions settings | onclosedCaptionsSettingsChanged with monospace sanserif for fontfamily | - | Set fontFamily-cursive | set fontFamily to cursive | cursive for fontfamily in closedcaptions settings | onclosedCaptionsSettingsChanged with cursive for fontfamily | - | Set fontFamily-proportional_serif | set fontFamily to proportional_serif | proportional serif for fontfamily in closedcaptions settings | onclosedCaptionsSettingsChanged with proportional serif for fontfamily | - | Set fontFamily-monospaced_serif | set fontFamily to monospaced_serif | monospaced serif for fontfamily in closedcaptions settings | onclosedCaptionsSettingsChanged with monospaced serif for fontfamily | - | Set fontFamily-proportional_sanserif | set fontFamily to proportional_sanserif | proportional sanserif for fontfamily in closedcaptions settings | onclosedCaptionsSettingsChanged with proportional sanserif for fontfamily | - | Set fontFamily-smallcaps | set fontFamily to smallcaps | smallcaps for fontfamily in closedcaptions settings | onclosedCaptionsSettingsChanged with smallcaps for fontfamily | - | Set fontFamily-casual | set fontFamily to casual | casual for fontfamily in closedcaptions settings | onclosedCaptionsSettingsChanged with casual for fontfamily | - | Set fontSize-1 | set fontSize to 1 | 1 for fontSize in closedcaptions settings | onclosedCaptionsSettingsChanged with 1 for fontSize | - | Set fontSize-0.5 | set fontSize to 0.5 | 0.5 for fontSize in closedcaptions settings | onclosedCaptionsSettingsChanged with 0.5 for fontSize | - | Set fontSize-1.5 | set fontSize to 1.5 | 1.5 for fontSize in closedcaptions settings | onclosedCaptionsSettingsChanged with 1.5 for fontSize | - | Set fontColor-#ff00ff | set fontColor to #ff00ff | #ff00ff for fontColor in closedcaptions settings | onclosedCaptionsSettingsChanged with #ff00ff for fontColor | - | Set fontEdge-raised | set fontEdge to raised | raised for fontEdge in closedcaptions settings | onclosedCaptionsSettingsChanged with raised for fontEdge | - | Set fontEdge-none | set fontEdge to none | none for fontEdge in closedcaptions settings | onclosedCaptionsSettingsChanged with none for fontEdge | - | Set fontEdge-depressed | set fontEdge to depressed | depressed for fontEdge in closedcaptions settings | onclosedCaptionsSettingsChanged with depressed for fontEdge | - | Set fontEdge-uniform | set fontEdge to uniform | uniform for fontEdge in closedcaptions settings | onclosedCaptionsSettingsChanged with uniform for fontEdge | - | Set fontEdge-dropShadow-left | set fontEdge to dropShadow_left | dropShadowLeft for fontEdge in closedcaptions settings | onclosedCaptionsSettingsChanged with dropShadowLeft for fontEdge | - | Set fontEdge-dropShadow-right | set fontEdge to dropShadow_right | dropShadowRight for fontEdge in closedcaptions settings | onclosedCaptionsSettingsChanged with dropShadowRight for fontEdge | - | Set fontEdgeColor-#FFFFFF | set fontEdgeColor to #FFFFFF | #ffffff for fontEdgeColor in closedcaptions settings | onclosedCaptionsSettingsChanged with #ffffff for fontEdgeColor | - | Set backgroundColor-#7f7f7f | set backgroundColor to #7f7f7f | #7f7f7f for backgroundColor in closedcaptions settings | onclosedCaptionsSettingsChanged with #7f7f7f for backgroundColor | - | Set fontOpacity-75 | set fontOpacity to 75 | 75 for fontOpacity in closedcaptions settings | onclosedCaptionsSettingsChanged with 75 for fontOpacity | - | Set backgroundOpacity-75 | set backgroundOpacity to 75 | 75 for backgroundOpacity in closedcaptions settings | onclosedCaptionsSettingsChanged with 75 for backgroundOpacity | - | Set textAlign-left | set textAlign to left | left for textAlign in closedcaptions settings | onclosedCaptionsSettingsChanged with left for textAlign | - | Set textAlign-center | set textAlign to center | center for textAlign in closedcaptions settings | onclosedCaptionsSettingsChanged with center for textAlign | - | Set textAlign-right | set textAlign to right | right for textAlign in closedcaptions settings | onclosedCaptionsSettingsChanged with right for textAlign | - | Set textAlignVertical-top | set textAlignVertical to top | top for textAlignVertical in closedcaptions settings | onclosedCaptionsSettingsChanged with top for textAlignVertical | - | Set textAlignVertical-middle | set textAlignVertical to middle | middle for textAlignVertical in closedcaptions settings | onclosedCaptionsSettingsChanged with middle for textAlignVertical | - | Set textAlignVertical-bottom | set textAlignVertical to bottom | bottom for textAlignVertical in closedcaptions settings | onclosedCaptionsSettingsChanged with bottom for textAlignVertical | - | Set windowColor-white | set windowColor to white | white for windowColor in closedcaptions settings | onclosedCaptionsSettingsChanged with white for windowColor | - | Set windowOpacity-50 | set windowOpacity to 50 | 50 for windowOpacity in closedcaptions settings | onclosedCaptionsSettingsChanged with 50 for windowOpacity | - | Set preferredLanguages | set preferredLanguages to spanish english | spanish for preferredLanguages in closedcaptions settings | onclosedCaptionsSettingsChanged with spanish for preferredLanguages | + Examples: + | Scenario | Method | Value | + | Disable closedcaptions | enabled | false | + | Enable closedcaptions | enabled | true | + | Set fontFamily-monospaced_sanserif | fontFamily | monospaced_sanserif | + | Set fontFamily-cursive | fontFamily | cursive | + | Set fontFamily-proportional_serif | fontFamily | proportional_serif | + | Set fontFamily-monospaced_serif | fontFamily | monospaced_serif | + | Set fontFamily-proportional_sanserif | fontFamily | proportional_sanserif | + | Set fontFamily-smallcaps | fontFamily | smallcaps | + | Set fontFamily-casual | fontFamily | casual | + | Set fontSize-1 | fontSize | 1 | + | Set fontSize-0.5 | fontSize | 0.5 | + | Set fontSize-1.5 | fontSize | 1.5 | + | Set fontColor-#ff00ff | fontColor | #ff00ff | + | Set fontEdge-raised | fontEdge | raised | + | Set fontEdge-none | fontEdge | none | + | Set fontEdge-depressed | fontEdge | depressed | + | Set fontEdge-uniform | fontEdge | uniform | + | Set fontEdge-dropShadow-left | fontEdge | drop_shadow_left | + | Set fontEdge-dropShadow-right | fontEdge | drop_shadow_right | + | Set fontEdgeColor-#FFFFFF | fontEdgeColor | #FFFFFF | + | Set backgroundColor-#7f7f7f | backgroundColor | #7f7f7 | + | Set fontOpacity-75 | fontOpacity | 75 | + | Set backgroundOpacity-75 | backgroundOpacity | 75 | + | Set textAlign-left | textAlign | left | + | Set textAlign-center | textAlign | center | + | Set textAlign-right | textAlign | right | + | Set textAlignVertical-top | textAlignVertical | top | + | Set textAlignVertical-middle | textAlignVertical | middle | + | Set textAlignVertical-bottom | textAlignVertical | bottom | + | Set windowColor-white | windowColor | white | + | Set windowOpacity-50 | windowOpacity | 50 | + | Set preferredLanguages | preferredLanguages | spa,eng | - @Accessibility @coreSDK @sdk @transport - Scenario Outline: Accessibility.closedCaptionsSettings - Positive Scenario: with 'null' params - When '3rd party app' registers for the 'accessibility onClosedCaptionsSettingsChanged' event using the 'Firebolt' API - And '3rd party app' invokes the 'Firebolt' API to 'get closedCaptions settings' - And 1st party app invokes the 'Firebolt' API to '' - Then 'Firebolt' platform responds to '1st party app' for '' - When '3rd party app' invokes the 'Firebolt' API to 'get closedCaptions settings' - Then 'Firebolt' platform responds with '' - And 'Firebolt' platform triggers event '' + @Accessibility @coreSDK @sdk @transport + Scenario Outline: Accessibility.closedCaptionsSettings - Positive Scenario: with 'null' params + When '3rd party app' registers for the 'accessibility onClosedCaptionsSettingsChanged' event using the 'Firebolt' API + And '3rd party app' invokes the 'Firebolt' API to 'get closedCaptions settings' + And 1st party app invokes the 'Firebolt' API to '' + Then 'Firebolt' platform responds to '1st party app' for '' + When '3rd party app' invokes the 'Firebolt' API to 'get closedCaptions settings' + Then 'Firebolt' platform responds with '' + And 'Firebolt' platform triggers event '' - Examples: + Examples: | Scenario | Key | Method_Content | Event_Content | | fontFamily | set fontFamily as null | default value for fontFamily | onclosedCaptionsSettingsChanged with default value for fontfamily | | fontSize | set fontSize as null | default value for fontSize | onclosedCaptionsSettingsChanged with default value for fontSize | @@ -74,84 +75,80 @@ Feature: Accessibility | windowColor | set windowColor as null | default value for windowColor | onclosedCaptionsSettingsChanged with default value for windowColor | | windowOpacity | set windowOpacity as null | default value for windowOpacity | onclosedCaptionsSettingsChanged with default value for windowOpacity | - @Accessibility @coreSDK @sdk @transport - Scenario Outline: Accessibility.voiceGuidanceSettings - Positive Scenario: - When '3rd party app' registers for the 'accessibility onVoiceGuidanceSettingsChanged' event using the 'Firebolt' API - And '3rd party app' invokes the 'Firebolt' API to 'get voiceGuidance settings' - And 1st party app invokes the 'Firebolt' API to '' - Then 'Firebolt' platform responds to '1st party app' for '' - When '3rd party app' invokes the 'Firebolt' API to 'get voiceGuidance settings' - Then 'Firebolt' platform responds with '' - And 'Firebolt' platform triggers event '' + @Accessibility @coreSDK @sdk @transport + Scenario Outline: Accessibility.voiceGuidanceSettings - Positive Scenario: + Given we test the 'ACCESSIBILITY_VOICEGUIDANCE_SETTINGS' getters and setters '' to '' + When '3rd party app' registers for the 'Firebolt' event + When '3rd party app' invokes the 'Firebolt' get API + Given 1st party app invokes the 'Firebolt' API to set '' to '' + And 'Firebolt' platform responds to '1st party app' set API + When '3rd party app' invokes the 'Firebolt' get API + And 'Firebolt' platform responds to '3rd party app' get API + And 'Firebolt' platform triggers '3rd party app' event + Examples: + | Scenario | Method | Value | + | Disable voiceguidance | enabled | false | + | Enable voiceguidance | enabled | true | + | Set speed-1 | speed | 1 | + | Set speed-0.5 | speed | 0.5 | + | Set speed-2 | speed | 2 | - Examples: - | Scenario | Key | Method_Content | Event_Content | - | Disable voiceguidance | disable voiceGuidance | disabled voiceGuidance settings | onvoiceGuidanceSettings with disabled | - | Enable voiceguidance | enable voiceGuidance | enabled voiceGuidance settings | onvoiceGuidanceSettings with enabled | - | Set speed-1 | set speed as 1 | 1 for speed in voiceGuidance settings | onvoiceGuidanceSettings with 1 for speed | - | Set speed-0.5 | set speed as 0.5 | 0.5 for speed in voiceGuidance settings | onvoiceGuidanceSettings with 0.5 for speed | - | Set speed-2 | set speed as 2 | 2 for speed in voiceGuidance settings | onvoiceGuidanceSettings with 2 for speed | + @Accessibility @coreSDK @sdk @transport + Scenario Outline: Accessibility.audioDescriptionSettings - Positive Scenario: + Given we test the 'AUDIODESCRIPTIONS_SETTINGS' getters and setters '' to '' + When '3rd party app' registers for the 'Firebolt' event + When '3rd party app' invokes the 'Firebolt' get API + Given 1st party app invokes the 'Firebolt' API to set '' to '' + And 'Firebolt' platform responds to '1st party app' set API + When '3rd party app' invokes the 'Firebolt' get API + And 'Firebolt' platform responds to '3rd party app' get API + And 'Firebolt' platform triggers '3rd party app' event - @Accessibility @coreSDK @sdk @transport - Scenario Outline: Accessibility.audioDescriptionSettings - Positive Scenario: - When '3rd party app' registers for the 'accessibility onAudioDescriptionSettingsChanged' event using the 'Firebolt' API - And '3rd party app' invokes the 'Firebolt' API to 'get audioDescriptionSettings settings' - And 1st party app invokes the 'Firebolt' API to '' - Then 'Firebolt' platform responds to '1st party app' for '' - When '3rd party app' invokes the 'Firebolt' API to 'get audioDescriptionSettings settings' - Then 'Firebolt' platform responds with '' - And 'Firebolt' platform triggers event '' + Examples: + | Scenario | Method | Value | + | Disable audioDescriptionSettings | enabled | false | + | Enable audioDescriptionSettings | enabled | true | - Examples: - | Scenario | Key | Method_Content | Event_Content | - | Disable audioDescriptionSettings | disable audioDescription | disabled audioDescription settings | onaudioDescriptionSettings with disabled | - | Enable audioDescriptionSettings | enable audioDescription | enabled audioDescription settings | onaudioDescriptionSettings with enabled | + @Accessibility @coreSDK @sdk @transport + Scenario Outline: Accessibility.closedCaptions - Positive Scenario: + Given we test the 'ACCESSIBILITY_CLOSEDCAPTIONS' getters and setters '' to '' + When '3rd party app' registers for the 'Firebolt' event + Given 1st party app invokes the 'Firebolt' API to set '' to '' + And 'Firebolt' platform responds to '1st party app' set API + When '3rd party app' invokes the 'Firebolt' get API + And 'Firebolt' platform responds to '3rd party app' get API + And 'Firebolt' platform triggers '3rd party app' event - @Accessibility @coreSDK @sdk @transport @requiresPlatformImplementation - Scenario: Accessibility.onClosedCaptionsSettingsChanged event - Positive Scenario: Clear listeners - When '3rd party app' registers for the 'accessibility onClosedCaptionsSettingsChanged' event using the 'Firebolt' API - And I clear 'accessibility onClosedCaptionsSettingsChanged event' listeners - And 1st party app invokes the 'Firebolt' API to 'disable closedCaptions' - Then 'Firebolt' platform responds to '1st party app' for 'disable closedCaptions' - And 'Firebolt' platform does not trigger event for 'onclosedCaptionsSettingsChanged' + Examples: + | Scenario | Method | Value | + | Enable closedcaptions | enabled | true | + | Set fontFamily-monospaced_sanserif | fontFamily | monospaced_sanserif | + | Set fontSize-1 | fontSize | 1 | + | Set fontColor-#ffffff | fontColor | #ffffff | + | Set fontEdge-raised | fontEdge | raised | + | Set fontEdgeColor-#7f7f7f | fontEdgeColor | #7F7F7F | + | Set backgroundColor-#000000 | backgroundColor | #000000 | + | Set fontOpacity-100 | fontOpacity | 100 | + | Set backgroundOpacity-100 | backgroundOpacity | 100 | + | Set textAlign-left | textAlign | left | + | Set textAlignVertical-top | textAlignVertical | top | + | Set windowColor-#7f7f7f | windowColor | #7F7F7F | + | Set windowOpacity-40 | windowOpacity | 40 | - @Accessibility @coreSDK @sdk @transport - Scenario Outline: Accessibility.closedCaptions - Positive Scenario: - When '3rd party app' registers for the 'accessibility onClosedCaptionsSettingsChanged' event using the 'Firebolt' API - And 1st party app invokes the 'Firebolt' API to '' - Then 'Firebolt' platform responds to '1st party app' for '' - When '3rd party app' invokes the 'Firebolt' API to 'get closedCaptions' - Then 'Firebolt' platform responds with '' - And 'Firebolt' platform triggers event '' + @Accessibility @coreSDK @sdk @transport + Scenario Outline: Accessibility.voiceGuidance - Positive Scenario: + Given we test the 'ACCESSIBILITY_VOICEGUIDANCE' getters and setters '' to '' + When '3rd party app' registers for the 'Firebolt' event + When '3rd party app' invokes the 'Firebolt' get API + Given 1st party app invokes the 'Firebolt' API to set '' to '' + And 'Firebolt' platform responds to '1st party app' set API + When '3rd party app' invokes the 'Firebolt' get API + And 'Firebolt' platform responds to '3rd party app' get API + And 'Firebolt' platform triggers '3rd party app' event - Examples: - | Scenario | Set_Method_Key | Method_Content | Event_Content | - | Enable closedcaptions | enable closedCaptions | enabled for accessibility closedCaptions | onclosedCaptionsSettingsChanged with enabled | - | Set fontFamily-monospaced_sanserif | set fontFamily to monospaced_sanserif | monospace sanserif for fontfamily in accessibility closedcaptions | onclosedCaptionsSettingsChanged with monospace sanserif for fontfamily | - | Set fontSize-1 | set fontSize to 1 | 1 for fontSize in accessibility closedcaptions | onclosedCaptionsSettingsChanged with 1 for fontSize | - | Set fontColor-#ffffff | set fontColor to #ffffff | #ffffff for fontColor in accessibility closedcaptions | onclosedCaptionsSettingsChanged with #ffffff for fontColor | - | Set fontEdge-raised | set fontEdge to raised | raised for fontEdge in accessibility closedcaptions | onclosedCaptionsSettingsChanged with raised for fontEdge | - | Set fontEdgeColor-#7f7f7f | set fontEdgeColor to #7f7f7f | #7f7f7f for fontEdgeColor in accessibility closedcaptions | onclosedCaptionsSettingsChanged with #7f7f7f for fontEdgeColor | - | Set backgroundColor-#000000 | set backgroundColor to #000000 | #000000 for backgroundColor in accessibility closedcaptions | onclosedCaptionsSettingsChanged with #000000 for backgroundColor | - | Set fontOpacity-100 | set fontOpacity to 100 | 100 for fontOpacity in accessibility closedcaptions | onclosedCaptionsSettingsChanged with 100 for fontOpacity | - | Set backgroundOpacity-100 | set backgroundOpacity to 100 | 100 for backgroundOpacity in accessibility closedcaptions | onclosedCaptionsSettingsChanged with 100 for backgroundOpacity | - | Set textAlign-left | set textAlign to left | left for textAlign in accessibility closedcaptions | onclosedCaptionsSettingsChanged with left for textAlign | - | Set textAlignVertical-top | set textAlignVertical to top | top for textAlignVertical in accessibility closedcaptions | onclosedCaptionsSettingsChanged with top for textAlignVertical | - | Set windowColor-#7f7f7f | set windowColor to #7f7f7f | #7f7f7f for windowColor in accessibility closedcaptions | onclosedCaptionsSettingsChanged with #7f7f7f for windowColor | - | Set windowOpacity-40 | set windowOpacity to 40 | 40 for windowOpacity in accessibility closedcaptions | onclosedCaptionsSettingsChanged with 40 for windowOpacity | - - @Accessibility @coreSDK @sdk @transport - Scenario Outline: Accessibility.voiceGuidance - Positive Scenario: - When '3rd party app' registers for the 'accessibility onVoiceGuidanceSettingsChanged' event using the 'Firebolt' API - And 1st party app invokes the 'Firebolt' API to '' - Then 'Firebolt' platform responds to '1st party app' for '' - When '3rd party app' invokes the 'Firebolt' API to 'get voiceGuidance' - Then 'Firebolt' platform responds with '' - And 'Firebolt' platform triggers event '' - - Examples: - | Scenario | Set_Method_Key | Method_Content | Event_Content | - | Disable voiceguidance | disable voiceGuidance | disabled voiceGuidance | onvoiceGuidanceSettings with disabled | - | Enable voiceguidance | enable voiceGuidance | enabled voiceGuidance | onvoiceGuidanceSettings with enabled | - | Set speed-1 | set speed as 1 | 1 for speed in voiceGuidance | onvoiceGuidanceSettings with 1 for speed | \ No newline at end of file + Examples: + | Scenario | Method | Value | + | Disable voiceguidance | enabled | false | + | Enable voiceguidance | enabled | true | + | Set speed-1 | speed | 1 | \ No newline at end of file diff --git a/cypress/TestCases/FireboltCertification/Manage/ClosedCaptionsManage.feature b/cypress/TestCases/FireboltCertification/Manage/ClosedCaptionsManage.feature index 5c3fe21f1..a7a319164 100644 --- a/cypress/TestCases/FireboltCertification/Manage/ClosedCaptionsManage.feature +++ b/cypress/TestCases/FireboltCertification/Manage/ClosedCaptionsManage.feature @@ -2,51 +2,51 @@ Feature: ClosedCaptions_Manage Background: Launch FCA for 'ClosedCaptions' Given the environment has been set up for 'ClosedCaptions' tests - And 3rd party 'certification' app is launched @ClosedCaptions @manageSDK Scenario Outline: ClosedCaptions. - Positive Scenario: - When 1st party app registers for the '' event using the 'Firebolt' API - And 1st party app invokes the 'Firebolt' API to '' - Then 'Firebolt' platform responds to '1st party app' for '' - When 1st party app invokes the 'Firebolt' API to '' - Then 'Firebolt' platform responds to '1st party app' with '' - And 'Firebolt' platform triggers to '1st party app' event '' + Given we test the 'CLOSED_CAPTIONS_SETTINGS' getters and setters '' to '' + When '1st party app' registers for the 'Firebolt' event + And 1st party app invokes the 'Firebolt' API to set '' to '' + Then 'Firebolt' platform responds to '1st party app' set API + When '1st party app' invokes the 'Firebolt' get API + Then 'Firebolt' platform responds to '1st party app' get API + And 'Firebolt' platform triggers '1st party app' event Examples: - | Scenario | Method | Event | Set_API_Key | API_Key | Method_Validation_Key | Event_Validation_Key | - | Set backgroundColor-#7f7f7f | backgroundColor | closedcaptions onBackgroundColorChanged | set backgroundColor to #7f7f7f | get backgroundColor | #7f7f7f for backgroundColor in closedCaptions | onBackgroundColorChanged for closedcaptions with #7f7f7f | - | Set backgroundOpacity-75 | backgroundOpacity | closedcaptions onBackgroundOpacityChanged | set backgroundOpacity to 75 | get backgroundOpacity | 75 for backgroundOpacity in closedCaptions | onBackgroundOpacityChanged for closedcaptions with 75 | - | Set closedcaptions-false | enabled | closedcaptions onEnabledChanged | disable closedCaptions | get enabled | disabled for closedCaptions | onEnabledChanged for closedcaptions with disable | - | Set closedcaptions-true | enabled | closedcaptions onEnabledChanged | enable closedCaptions | get enabled | enabled for closedCaptions | onEnabledChanged for closedcaptions with enable | - | Set fontColor-#ff00ff | fontColor | closedcaptions onFontColorChanged | set fontColor to #ff00ff | get fontColor | #ff00ff for fontColor in closedCaptions | onFontColorChanged for closedcaptions with #ff00ff | - | Set fontEdge-raised | fontEdge | closedcaptions onFontEdgeChanged | set fontEdge to raised | get fontEdge | raised for fontEdge in closedCaptions | onFontEdgeChanged for closedcaptions with raised | - | Set fontEdge-none | fontEdge | closedcaptions onFontEdgeChanged | set fontEdge to none | get fontEdge | none for fontEdge in closedCaptions | onFontEdgeChanged for closedcaptions with none | - | Set fontEdge-depressed | fontEdge | closedcaptions onFontEdgeChanged | set fontEdge to depressed | get fontEdge | depressed for fontEdge in closedCaptions | onFontEdgeChanged for closedcaptions with depressed | - | Set fontEdge-uniform | fontEdge | closedcaptions onFontEdgeChanged | set fontEdge to uniform | get fontEdge | uniform for fontEdge in closedCaptions | onFontEdgeChanged for closedcaptions with uniform | - | Set fontEdge-drop-shadow-left | fontEdge | closedcaptions onFontEdgeChanged | set fontEdge to dropShadow left | get fontEdge | dropShadow left for fontEdge in closedCaptions | onFontEdgeChanged for closedcaptions with dropShadow left | - | Set fontEdge-drop-shadow-right | fontEdge | closedcaptions onFontEdgeChanged | set fontEdge to dropShadow right | get fontEdge | dropShadow right for fontEdge in closedCaptions | onFontEdgeChanged for closedcaptions with dropShadow right | - | Set fontEdgeColor-#FFFFFF | fontEdgeColor | closedcaptions onFontEdgeColorChanged | set fontEdgeColor to #FFFFFF | get fontEdgeColor | #FFFFFF for fontEdgeColor in closedCaptions | onFontEdgeColorChanged for closedcaptions with #FFFFFF | - | Set fontFamily-cursive | fontFamily | closedcaptions onFontFamilyChanged | set fontFamily to cursive | get fontfamily | cursive for fontFamily in closedCaptions | onFontFamilyChanged for closedcaptions with cursive | - | Set fontFamily-monospaced_sanserif | fontFamily | closedcaptions onFontFamilyChanged | set fontFamily to monospaced sanserif | get fontFamily | monospaced sanserif for fontFamily in closedCaptions | onFontFamilyChanged for closedcaptions with monospaced sanserif | - | Set fontFamily-proportional_serif | fontFamily | closedcaptions onFontFamilyChanged | set fontFamily to proportional serif | get fontFamily | proportional serif for fontFamily in closedCaptions | onFontFamilyChanged for closedcaptions with proportional serif | - | Set fontFamily-monospaced_serif | fontFamily | closedcaptions onFontFamilyChanged | set fontFamily to monospaced serif | get fontFamily | monospaced serif for fontFamily in closedCaptions | onFontFamilyChanged for closedcaptions with monospaced serif | - | Set fontFamily-proportional_sanserif | fontFamily | closedcaptions onFontFamilyChanged | set fontFamily to proportional sanserif | get fontFamily | proportional sanserif for fontFamily in closedCaptions | onFontFamilyChanged for closedcaptions with proportional sanserif | - | Set fontFamily-smallcaps | fontFamily | closedcaptions onFontFamilyChanged | set fontFamily to smallcaps | get fontFamily | smallcaps for fontFamily in closedCaptions | onFontFamilyChanged for closedcaptions with smallcaps | - | Set fontFamily-casual | fontFamily | closedcaptions onFontFamilyChanged | set fontFamily to casual | get fontFamily | casual for fontFamily in closedCaptions | onFontFamilyChanged for closedcaptions with casual | - | Set fontOpacity-75 | fontOpacity | closedcaptions onFontOpacityChanged | set fontOpacity to 75 | get fontOpacity | 75 for fontOpacity in closedCaptions | onFontOpacityChanged for closedcaptions with 75 | - | Set fontSize-0.5 | fontSize | closedcaptions onFontSizeChanged | set fontSize to 0.5 | get fontSize | 0.5 for fontSize in closedCaptions | onFontSizeChanged for closedcaptions with 0.5 | - | Set fontSize-1 | fontSize | closedcaptions onFontSizeChanged | set fontSize to 1 | get fontSize | 1 for fontSize in closedCaptions | onFontSizeChanged for closedcaptions with 1 | - | Set fontSize-1.5 | fontSize | closedcaptions onFontSizeChanged | set fontSize to 1.5 | get fontSize | 1.5 for fontSize in closedCaptions | onFontSizeChanged for closedcaptions with 1.5 | - | Set textAlign-left | textAlign | closedcaptions onTextAlignChanged | set textAlign to left | get textAlign | left for textAlign in closedCaptions | onTextAlignChanged for closedcaptions with left | - | Set textAlign-center | textAlign | closedcaptions onTextAlignChanged | set textAlign to center | get textAlign | center for textAlign in closedCaptions | onTextAlignChanged for closedcaptions with center | - | Set textAlign-right | textAlign | closedcaptions onTextAlignChanged | set textAlign to right | get textAlign | right for textAlign in closedCaptions | onTextAlignChanged for closedcaptions with right | - | Set textAlignVertical-top | textAlignVertical | closedcaptions onTextAlignVerticalChanged | set textAlignVertical to top | get textAlignVertical | top for textAlignVertical in closedCaptions | onTextAlignVerticalChanged for closedcaptions with top | - | Set textAlignVertical-middle | textAlignVertical | closedcaptions onTextAlignVerticalChanged | set textAlignVertical to middle | get textAlignVertical | middle for textAlignVertical in closedCaptions | onTextAlignVerticalChanged for closedcaptions with middle | - | Set textAlignVertical-bottom | textAlignVertical | closedcaptions onTextAlignVerticalChanged | set textAlignVertical to bottom | get textAlignVertical | bottom for textAlignVertical in closedCaptions | onTextAlignVerticalChanged for closedcaptions with bottom | - | Set preferredLanguages | preferredLanguages | closedcaptions onPreferredLanguagesChanged | set preferredLanguages to spanish | get preferredLanguages | spanish for preferredLanguages in closedCaptions | onPreferredLanguagesChanged for closedcaptions with spanish | - | Set windowColor-white | windowColor | closedcaptions onWindowColorChanged | set windowColor to white | get windowColor | white for windowColor in closedCaptions | onWindowColorChanged for closedcaptions with #000000 | - | Set windowOpacity-50 | windowOpacity | closedcaptions onWindowOpacityChanged | set windowOpacity to 50 | get windowOpacity | 50 for windowOpacity in closedCaptions | onWindowOpacityChanged for closedcaptions with 50 | + | Scenario | Method | Value | + | Set backgroundColor-#7f7f7f | backgroundColor | #7f7f7f | + | Set backgroundOpacity-75 | backgroundOpacity | 75 | + | Set closedcaptions-false | enabled | false | + | Set closedcaptions-true | enabled | true | + | Set fontColor-#ff00ff | fontColor | #ff00ff | + | Set fontEdge-raised | fontEdge | raised | + | Set fontEdge-none | fontEdge | none | + | Set fontEdge-depressed | fontEdge | depressed | + | Set fontEdge-uniform | fontEdge | uniform | + | Set fontEdge-drop-shadow-left | fontEdge | drop_shadow_left | + | Set fontEdge-drop-shadow-right | fontEdge | drop_shadow_right | + | Set fontEdgeColor-#FFFFFF | fontEdgeColor | #FFFFFF | + | Set fontFamily-cursive | fontFamily | cursive | + | Set fontFamily-monospaced_sanserif | fontFamily | monospaced_sanserif | + | Set fontFamily-proportional_serif | fontFamily | proportional_serif | + | Set fontFamily-monospaced_serif | fontFamily | monospaced_serif | + | Set fontFamily-proportional_sanserif | fontFamily | proportional_sanserif | + | Set fontFamily-smallcaps | fontFamily | smallcaps | + | Set fontFamily-casual | fontFamily | casual | + | Set fontOpacity-75 | fontOpacity | 75 | + | Set fontSize-0.5 | fontSize | 0.5 | + | Set fontSize-1 | fontSize | 1 | + | Set fontSize-1.5 | fontSize | 1.5 | + | Set textAlign-left | textAlign | left | + | Set textAlign-center | textAlign | center | + | Set textAlign-right | textAlign | right | + | Set textAlignVertical-top | textAlignVertical | top | + | Set textAlignVertical-middle | textAlignVertical | middle | + | Set textAlignVertical-bottom | textAlignVertical | bottom | + | Set preferredLanguages | preferredLanguages | spa,eng | + | Set windowColor-white | windowColor | white | + | Set windowOpacity-50 | windowOpacity | 50 | @ClosedCaptions @manageSDK Scenario Outline: Closedcaptions. - Positive Scenario: with 'null' params @@ -74,41 +74,42 @@ Feature: ClosedCaptions_Manage @ClosedCaptions @manageSDK Scenario Outline: ClosedCaptions. - Negative Scenario: expecting error - When 1st party app invokes the 'Firebolt' API to '' - Then 'Firebolt' platform responds to '1st party app' with '' + Given we test the 'CLOSED_CAPTIONS_SETTINGS' getters and setters '' to '' + When 1st party app invokes the 'Firebolt' API to set '' to invalid '' + And 'Firebolt' platform responds to '1st party app' set API with '' Examples: - | Scenario | Method | API_Key | Method_Validation_key | - | Set enabled-test | setEnabled | enable closedCaptions with test parameter | invalid params for closedcaptions setEnabled | - | Set enabled-123 | setEnabled | enable closedCaptions with integer parameter | invalid params for closedcaptions setEnabled | - | Set fontFamily-123 | setFontFamily | set fontFamily to 123 | invalid params for closedcaptions setFontFamily | - | Set fontFamily-true | setFontFamily | set fontFamily to true | invalid params for closedcaptions setFontFamily | - | Set fontSize-true | setFontSize | set fontSize to true | invalid params for closedcaptions setFontSize | - | Set fontSize-test | setFontSize | set fontSize to test | invalid params for closedcaptions setFontSize | - | Set fontSize-true | setFontSize | set fontSize to true | invalid params for closedcaptions setFontSize | - | Set fontSize-0.25 | setFontSize | set fontSize to 0.25 | custom error for closedcaptions setFontSize | - | Set fontFamily-sans-serif | setFontFamily | set fontFamily to sans serif | custom error for closedcaptions setFontFamily | - | Set fontEdge-123 | setFontEdge | set fontEdge to 123 | invalid params for closedcaptions setFontEdge | - | Set fontEdge-true | setFontEdge | set fontEdge to true | invalid params for closedcaptions setFontEdge | - | Set fontEdge-solid | setFontEdge | set fontEdge to solid | custom error for closedcaptions setFontEdge | - | Set preferredLanguages-true | setPreferredLanguages | set preferredLanguages to true | invalid params for closedcaptions setPreferredLanguages | - | Set preferredLanguages-123 | setPreferredLanguages | set preferredLanguages to 123 | invalid params for closedcaptions setPreferredLanguages | - | Set preferredLanguage-test | setPreferredLanguages | set preferredLanguages to test | invalid params for closedcaptions setPreferredLanguages | - | Set windowColor-123 | setWindowColor | set windowColor to 123 | invalid params for closedcaptions setWindowColor | - | Set windowOpacity-true | setWindowOpacity | set windowOpacity to true | invalid params for closedcaptions setWindowOpacity | - | Set fontEdgeColor-123 | setFontEdgeColor | set fontEdgeColor to 123 | invalid params for closedcaptions setFontEdgeColor | - | Set fontEdgeColor-true | setFontEdgeColor | set fontEdgeColor to true | invalid params for closedcaptions setFontEdgeColor | - | Set backgroundColor-123 | setBackgroundColor | set backgroundColor to 123 | invalid params for closedcaptions setBackgroundColor | - | Set backgroundColor-true | setBackgroundColor | set backgroundColor to true | invalid params for closedcaptions setBackgroundColor | - | Set textAlign-123 | setTextAlign | set textAlign to 123 | invalid params for closedcaptions setTextAlign | - | Set textAlign-true | setTextAlign | set textAlign to true | invalid params for closedcaptions setTextAlign | - | Set textAlignVertical-123 | setTextAlignVertical | set textAlignVertical to 123 | invalid params for closedcaptions setTextAlignVertical | - | Set textAlignVertical-true | setTextAlignVertical | set textAlignVertical to true | invalid params for closedcaptions setTextAlignVertical | - | Set fontColor-123 | setFontColor | set fontColor to 123 | invalid params for closedcaptions setFontColor | - | Set fontColor-true | setFontColor | set fontColor to true | invalid params for closedcaptions setFontColor | - | Set fontOpacity-120 | setFontOpacity | set fontOpacity to 120 | custom error for closedcaptions setFontOpacity | - | Set fontOpacity-test | setFontOpacity | set fontOpacity to test | invalid params for closedcaptions setFontOpacity | - | Set fontOpacity-true | setFontOpacity | set fontOpacity to true | invalid params for closedcaptions setFontOpacity | - | Set backgroundOpacity-120 | setBackgroundOpacity | set backgroundOpacity to 120 | custom error for closedcaptions setBackgroundOpacity | - | Set backgroundOpacity-test | setBackgroundOpacity | set backgroundOpacity to test | invalid params for closedcaptions setBackgroundOpacity | - | Set backgroundOpacity-true | setBackgroundOpacity | set backgroundOpacity to true | invalid params for closedcaptions setBackgroundOpacity | \ No newline at end of file + | Scenario | Method | Value | Error | + | Set enabled-test | enabled | test | INVALID_TYPE_PARAMS | + | Set enabled-123 | enabled | 123 | INVALID_TYPE_PARAMS | + | Set fontFamily-123 | fontFamily | 123 | INVALID_TYPE_PARAMS | + | Set fontFamily-true | fontFamily | true | INVALID_TYPE_PARAMS | + | Set fontSize-true | fontSize | true | INVALID_TYPE_PARAMS | + | Set fontSize-test | fontSize | test | INVALID_TYPE_PARAMS | + | Set fontSize-true | fontSize | true | INVALID_TYPE_PARAMS | + | Set fontSize-0.25 | fontSize | 0.25 | CUSTOM_ERROR | + | Set fontFamily-sans-serif | fontFamily | sans-serif | CUSTOM_ERROR | + | Set fontEdge-123 | fontEdge | 123 | INVALID_TYPE_PARAMS | + | Set fontEdge-true | fontEdge | true | INVALID_TYPE_PARAMS | + | Set fontEdge-solid | fontEdge | solid | CUSTOM_ERROR | + | Set preferredLanguages-true | preferredLanguages | true | INVALID_TYPE_PARAMS | + | Set preferredLanguages-123 | preferredLanguages | 123 | INVALID_TYPE_PARAMS | + | Set preferredLanguages-test | preferredLanguages | test | INVALID_TYPE_PARAMS | + | Set windowColor-123 | windowColor | 123 | INVALID_TYPE_PARAMS | + | Set windowOpacity-true | windowOpacity | true | INVALID_TYPE_PARAMS | + | Set fontEdgeColor-123 | fontEdgeColor | 123 | INVALID_TYPE_PARAMS | + | Set fontEdgeColor-true | fontEdgeColor | true | INVALID_TYPE_PARAMS | + | Set backgroundColor-123 | backgroundColor | 123 | INVALID_TYPE_PARAMS | + | Set backgroundColor-true | backgroundColor | true | INVALID_TYPE_PARAMS | + | Set textAlign-123 | textAlign | 123 | INVALID_TYPE_PARAMS | + | Set textAlign-true | textAlign | true | INVALID_TYPE_PARAMS | + | Set textAlignVertical-123 | textAlignVertical | 123 | INVALID_TYPE_PARAMS | + | Set textAlignVertical-true | textAlignVertical | true | INVALID_TYPE_PARAMS | + | Set fontColor-123 | fontColor | 123 | INVALID_TYPE_PARAMS | + | Set fontColor-true | fontColor | true | INVALID_TYPE_PARAMS | + | Set fontOpacity-120 | fontOpacity | 120 | CUSTOM_ERROR | + | Set fontOpacity-test | fontOpacity | test | INVALID_TYPE_PARAMS | + | Set fontOpacity-true | fontOpacity | true | INVALID_TYPE_PARAMS | + | Set backgroundOpacity-120 | backgroundOpacity | 120 | CUSTOM_ERROR | + | Set backgroundOpacity-test | backgroundOpacity | test | INVALID_TYPE_PARAMS | + | Set backgroundOpacity-true | backgroundOpacity | true | INVALID_TYPE_PARAMS | diff --git a/cypress/fixtures/fireboltCalls/accessibility.js b/cypress/fixtures/fireboltCalls/accessibility.js new file mode 100644 index 000000000..56b70b143 --- /dev/null +++ b/cypress/fixtures/fireboltCalls/accessibility.js @@ -0,0 +1,145 @@ +exports.ACCESSIBILITY_CLOSEDCAPTIONS_SETTINGS = { + method: 'accessibility.closedCaptionsSettings', + params: null, + validationJsonPath: resolveAtRuntime(['result.{{attribute}}', 'result.styles.{{attribute}}']), + setMethod: resolveAtRuntime('manage_closedcaptions.set{{attribute.uppercaseFirstChar}}'), + setParams: resolveAtRuntime('value'), + setValidationJsonPath: 'result', + setContent: null, + event: 'accessibility.onClosedCaptionsSettingsChanged', + eventValidationJsonPath: resolveAtRuntime([ + 'eventResponse.{{attribute}}', + 'eventResponse.styles.{{attribute}}', + ]), + content: { + data: [ + { + type: 'fixture', + validations: [ + { + mode: 'staticContentValidation', + type: resolveAtRuntime('value'), + description: resolveAtRuntime( + 'Validating that accessibility.closedCaptionSettings {{attribute}} is {{value}}' + ), + }, + ], + }, + ], + }, +}; + +exports.ACCESSIBILITY_VOICEGUIDANCE_SETTINGS = { + method: 'accessibility.voiceGuidanceSettings', + params: null, + validationJsonPath: resolveAtRuntime(['result.{{attribute}}']), + setMethod: resolveAtRuntime('manage_voiceguidance.set{{attribute.uppercaseFirstChar}}'), + setParams: resolveAtRuntime('value'), + setValidationJsonPath: 'result', + setContent: null, + event: 'accessibility.onVoiceGuidanceSettingsChanged', + eventValidationJsonPath: resolveAtRuntime(['eventResponse.{{attribute}}']), + content: { + data: [ + { + type: 'fixture', + validations: [ + { + mode: 'staticContentValidation', + type: resolveAtRuntime('value'), + description: resolveAtRuntime( + 'Validating that accessibility.voiceGuidanceSettings {{attribute}} is {{value}}' + ), + }, + ], + }, + ], + }, +}; + +exports.AUDIODESCRIPTIONS_SETTINGS = { + method: 'accessibility.audioDescriptionSettings', + params: null, + validationJsonPath: resolveAtRuntime(['result.{{attribute}}']), + setMethod: resolveAtRuntime('manage_audiodescriptions.set{{attribute.uppercaseFirstChar}}'), + setParams: resolveAtRuntime('value'), + setValidationJsonPath: 'result', + setContent: null, + event: 'accessibility.onAudioDescriptionSettingsChanged', + eventValidationJsonPath: resolveAtRuntime(['eventResponse.{{attribute}}']), + content: { + data: [ + { + type: 'fixture', + validations: [ + { + mode: 'staticContentValidation', + type: resolveAtRuntime('value'), + description: resolveAtRuntime( + 'Validating that accessibility.audioDescriptionSettings {{attribute}} is {{value}}' + ), + }, + ], + }, + ], + }, +}; + +exports.ACCESSIBILITY_CLOSEDCAPTIONS = { + method: 'accessibility.closedCaptions', + params: null, + validationJsonPath: resolveAtRuntime(['result.{{attribute}}', 'result.styles.{{attribute}}']), + setMethod: resolveAtRuntime('manage_closedcaptions.set{{attribute.uppercaseFirstChar}}'), + setParams: resolveAtRuntime('value'), + setValidationJsonPath: 'result', + setContent: null, + event: 'accessibility.onClosedCaptionsSettingsChanged', + eventValidationJsonPath: resolveAtRuntime([ + 'eventResponse.{{attribute}}', + 'eventResponse.styles.{{attribute}}', + ]), + content: { + data: [ + { + type: 'fixture', + validations: [ + { + mode: 'staticContentValidation', + type: resolveAtRuntime('value'), + description: resolveAtRuntime( + 'Validating that accessibility.closedCaptions {{attribute}} is {{value}}' + ), + }, + ], + }, + ], + }, +}; + +exports.ACCESSIBILITY_VOICEGUIDANCE = { + method: 'accessibility.voiceGuidance', + params: null, + validationJsonPath: resolveAtRuntime(['result.{{attribute}}']), + setMethod: resolveAtRuntime('manage_voiceguidance.set{{attribute.uppercaseFirstChar}}'), + setParams: resolveAtRuntime('value'), + setValidationJsonPath: 'result', + setContent: null, + event: 'accessibility.onVoiceGuidanceSettingsChanged', + eventValidationJsonPath: resolveAtRuntime(['eventResponse.{{attribute}}']), + content: { + data: [ + { + type: 'fixture', + validations: [ + { + mode: 'staticContentValidation', + type: resolveAtRuntime('value'), + description: resolveAtRuntime( + 'Validating that accessibility.voiceGuidance {{attribute}} is {{value}}' + ), + }, + ], + }, + ], + }, +}; diff --git a/cypress/fixtures/fireboltCalls/closedcaptions.js b/cypress/fixtures/fireboltCalls/closedcaptions.js new file mode 100644 index 000000000..25f3e0f42 --- /dev/null +++ b/cypress/fixtures/fireboltCalls/closedcaptions.js @@ -0,0 +1,27 @@ +exports.CLOSED_CAPTIONS_SETTINGS = { + method: resolveAtRuntime('manage_closedcaptions.{{attribute}}'), + params: null, + validationJsonPath: 'result', + setMethod: resolveAtRuntime('manage_closedcaptions.set{{attribute.uppercaseFirstChar}}'), + setParams: resolveAtRuntime('value'), + setValidationJsonPath: 'result', + setContent: null, + event: resolveAtRuntime('manage_closedcaptions.on{{attribute.uppercaseFirstChar}}Changed'), + eventValidationJsonPath: 'eventResponse', + content: { + data: [ + { + type: 'fixture', + validations: [ + { + mode: 'staticContentValidation', + type: resolveAtRuntime('value'), + description: resolveAtRuntime( + 'Validating that manage_closedcaptions.on{{event.uppercaseFirstChar}} {{attribute}} is {{value}}' + ), + }, + ], + }, + ], + }, +}; diff --git a/cypress/support/appObjectConfigs.js b/cypress/support/appObjectConfigs.js index 84735d88c..2d8b7eb08 100644 --- a/cypress/support/appObjectConfigs.js +++ b/cypress/support/appObjectConfigs.js @@ -51,8 +51,10 @@ class eventObject { // Function to update the event response in event object. setEventResponseData(response) { if ( - (response.eventSchemaResult && response.eventResponse != null) || - response.hasOwnProperty(CONSTANTS.EVENT_RESPONSE) + (response && response.eventResponse && response.eventResponse[this.eventObjectId] != null) || + (response && + response.eventResponse != null && + !response.eventResponse.hasOwnProperty(this.eventObjectId)) ) { this.eventResponse = response.eventResponse; this.eventSchemaResult = response.eventSchemaResult; diff --git a/cypress/support/constants/constants.js b/cypress/support/constants/constants.js index 1b55f6cba..efa72fd8e 100644 --- a/cypress/support/constants/constants.js +++ b/cypress/support/constants/constants.js @@ -31,6 +31,7 @@ module.exports = { ALPHANUMERIC: 'alphanumeric', API_NAME: 'apiName', API_VERSION: 'apiVersion', + APP: 'App', APP_HISTORY_EMPTY: 'App history is empty', APP_ID: 'appId', APP_LIFECYCLE_HISTORY: 'appLifeCycleHistory', @@ -98,6 +99,7 @@ module.exports = { ERROR_CODE: 'Error code', ERROR_CONTENT_JSON_PATH: 'objects/errorObjects/errorContent.json', ERROR_CONTENT_OBJECTS_PATH: 'cypress/fixtures/objects/errorObjects/errorContent.json', + ERROR_CONTENT_VALIDATIONJSON: 'errorContentValidationJson', ERROR_EXPECTED: 'Expected response.error not to be null', ERROR_EXPECTED_DEFINED: 'Expected response.error to be defined', ERROR_EXPECTED_NULL: 'Expected response.error to be null', @@ -299,8 +301,7 @@ module.exports = { PARAMS: 'Params', PASS: 'PASS', PASSWORD: 'password', - PLATFORM_INVALID_RESPONSE_LOG: - 'Platform returned response in invalid format, which could lead to failures in validations. Response must be an object', + PLATFORM: 'Platform', PLATFORM_NOT_SUPPORT_LOG: 'Platform does not support method', PLATFORM_NOT_TRIGGER_EVENT: 'Platform MUST not trigger event ', PLATFORM_TRIGGER_EVENT: 'Platform MUST trigger event ', @@ -333,6 +334,8 @@ module.exports = { }, PERFORMANCE_METRICS: 'performanceMetrics', RESPONSE: 'Response: ', + RESPONSE_INVALID_RESPONSE_LOG: + 'Platform or App returned response in invalid format, which could lead to failures in validations. Response must be in JSON RPC format', RESPONSE_NOT_FOUND: 'No_Response', RESPONSE_STATUS: { OK: 'OK', diff --git a/cypress/support/cypress-commands/commands.js b/cypress/support/cypress-commands/commands.js index 48feb499c..8e22f3ad7 100644 --- a/cypress/support/cypress-commands/commands.js +++ b/cypress/support/cypress-commands/commands.js @@ -19,6 +19,7 @@ const CONSTANTS = require('../constants/constants'); const { _ } = Cypress; import UTILS, { getEnvVariable } from '../cypress-support/src/utils'; const logger = require('../Logger')('command.js'); +import { apiObject, eventObject } from '../appObjectConfigs'; /** * @module commands @@ -829,3 +830,315 @@ Cypress.Commands.add('clearCache', () => { cy.clearAllSessionStorage(); cy.reload(true); }); + +/** + * @module commands + * @function sendMessageToPlatformOrApp + * @description Function to send message to Platform or App to make an Api call. + * @param {String} target - 'App' or 'Platform' + * @param {String} requestData - Contains the data which required to create request message to make a call. + * @param {String} task - Task/Handler name that decides whether make a api call or event call. + * @example + * cy.sendMessageToPlatformOrApp('App', {method: 'account.id', params: {}, context: {}, action: 'core', expected: 'result', appId: 'test.test'} + * cy.sendMessageToPlatformOrApp('Platform', {method: 'account.id', params: {}, context: {}, action: 'core', expected: 'result'} + * cy.sendMessageToPlatformOrApp('App', {method: 'accessibility.onClosedCaptionsSettingsChanged', params: {}, context: {}, action: 'core', expected: 'result', appId: 'test.test', 'registerEvent'} + */ +Cypress.Commands.add('sendMessageToPlatformOrApp', (target, requestData, task) => { + const { method, params, context, action, expected, appId } = requestData; + const deviceIdentifier = requestData.deviceIdentifier; + task = task ? task : CONSTANTS.TASK.CALLMETHOD; + let isNotSupportedApi = false; + + if (UTILS.isScenarioExempted(method, params)) { + isNotSupportedApi = true; + Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); + } + + cy.then(() => { + if (target === CONSTANTS.APP) { + const additionalParams = { + communicationMode: UTILS.getCommunicationMode(), + action: action, + isNotSupportedApi: isNotSupportedApi, + }; + const methodKey = task == CONSTANTS.TASK.REGISTEREVENT ? CONSTANTS.EVENT : CONSTANTS.METHOD; + const paramKey = task == CONSTANTS.TASK.REGISTEREVENT ? 'params' : 'methodParams'; + + const requestParams = { [methodKey]: method, [paramKey]: params }; + + // Creating intent message using above details to send it to 3rd party app. + const intentMessage = UTILS.createIntentMessage(task, requestParams, additionalParams); + + // Adding additional details to created intent if any platform specific data is present in configModule. + cy.runIntentAddon(task, intentMessage).then((parsedIntent) => { + const requestTopic = UTILS.getTopic(appId, null, deviceIdentifier); + const responseTopic = UTILS.getTopic(appId, CONSTANTS.SUBSCRIBE, deviceIdentifier); + cy.sendMessagetoApp(requestTopic, responseTopic, parsedIntent); + }); + } else if (target === CONSTANTS.PLATFORM) { + const requestMap = { + method: method, + params: params, + action: action, + task: task, + }; + // Assigning event_param env if param has empty object + if (task == CONSTANTS.TASK.REGISTEREVENT && Object.keys(requestMap.params).length === 0) { + // To Do :debug event_param issue by passing isrequired as false for getEnvVariable,need to debug further + requestMap.params = UTILS.getEnvVariable(CONSTANTS.EVENT_PARAM, false); + } + + cy.sendMessagetoPlatforms(requestMap); + } else { + fireLog.assert(false, `Invalid ${target} target, it should be either app or platfrom`); + } + }).then((response) => { + if (response === CONSTANTS.NO_RESPONSE) { + assert(false, CONSTANTS.NO_MATCHED_RESPONSE); + } + + if (Cypress.env(CONSTANTS.IS_RPC_ONLY)) { + fireLog.info( + `${method} response will be retrieved in subsequent steps and validated when the rpc-only methods are invoked. Proceeding to the next step.` + ); + return; + } + if ( + (response && typeof response == CONSTANTS.TYPE_OBJECT) || + (typeof response == CONSTANTS.TYPE_STRING && + (JSON.parse(response).hasOwnProperty(CONSTANTS.RESULT) || + JSON.parse(response).hasOwnProperty(CONSTANTS.ERROR))) + ) { + response = typeof response === CONSTANTS.TYPE_STRING ? JSON.parse(response) : response; + + if ( + response && + response.error && + response.error.message && + CONSTANTS.ERROR_LIST.includes(response.error.message) + ) { + if (UTILS.getEnvVariable(CONSTANTS.CERTIFICATION) == true) { + fireLog.assert(false, `${target} does not support method: ${method}`); + } else { + fireLog.info(`NotSupported: ${target} does not support method: ${method}`).then(() => { + throw new Error(CONSTANTS.STEP_IMPLEMENTATION_MISSING); + }); + } + } + + if (task == CONSTANTS.TASK.REGISTEREVENT) { + if (response && response.result && response.result.hasOwnProperty(CONSTANTS.LISTENING)) { + const eventResponse = { + eventListenerId: response.result.event + '-' + response.id, + eventListenerResponse: response.result, + }; + response.result = eventResponse; + } + if (response && response.error && response.error.message) { + fireLog.assert( + false, + `Event registration failed for event ${method} with error message: ${response.error.message} ` + ); + } + } + + cy.updateResponseForFCS(method, params, response).then((updatedResponse) => { + // Create a deep copy to avoid reference mutation + const dataToBeCensored = _.cloneDeep(response); + + // Call the 'censorData' command to hide sensitive data + cy.censorData(method, dataToBeCensored).then((maskedResult) => { + const appLog = target === CONSTANTS.PLATFORM ? 'Firebolt platform' : `app: ${appId}`; + fireLog.info(`Response from ${appLog}: ${JSON.stringify(maskedResult)}`); + }); + // Creating object with event name, params, and response etc and storing it in a global list for further validation. + const apiOrEventAppObject = + task === CONSTANTS.TASK.REGISTEREVENT + ? new eventObject(method, params, context, updatedResponse, appId, expected) + : new apiObject(method, params, context, updatedResponse, expected, appId); + + const globalList = + task === CONSTANTS.TASK.REGISTEREVENT + ? CONSTANTS.GLOBAL_EVENT_OBJECT_LIST + : CONSTANTS.GLOBAL_API_OBJECT_LIST; + UTILS.getEnvVariable(globalList).push(apiOrEventAppObject); + }); + } else { + fireLog.info( + `${target} returned response in invalid format, which could lead to failures in validations. Response must be in JSON RPC format - ${response}` + ); + } + }); +}); + +/** + * @module commands + * @function sendMessageToPlatformOrApp + * @description Function to send message to Platform or App to make an Api call. + * @param {String} validationType - Determines whether method or event validation is being performed. Ex: 'method' or 'event' + * @param {String} requestData - Contains the data which required to do content validation for the specified method. + * @example + * cy.sendMessageToPlatformOrApp('method', {method: 'account.id', context: {}, contentObject: {}, expectingError: false, appId: 'test.test'} + * cy.sendMessageToPlatformOrApp('event', {method: 'accessibility.onClosedCaptionsSettingsChanged', context: {}, contentObject: {}, expectingError: false, appId: 'test.test', eventExpected: 'triggers'} + */ +Cypress.Commands.add('methodOrEventResponseValidation', (validationType, requestData) => { + const { method, context, contentObject, expectingError, appId, eventExpected } = requestData; + let validationJsonPath = requestData.validationJsonPath; + + // Extracting the api or event object from the global list. + const methodOrEventObject = UTILS.getApiOrEventObjectFromGlobalList( + method, + context, + appId, + validationType + ); + const param = methodOrEventObject.params; + + cy.validateResponseErrorAndSchemaResult(methodOrEventObject, validationType).then(() => { + // If passed method is exception method or expecting a error in response, doing error content validation. + if (UTILS.isScenarioExempted(method, param) || expectingError) { + // If not expecting for an error and it's a exception method, storing "exceptionErrorObject" to errorContent variable to fetch the error content object based on the exception type. + const errorContent = + expectingError === true ? contentObject : CONSTANTS.EXCEPTION_ERROR_OBJECT; + cy.validateErrorObject(method, errorContent, validationType, context, appId, param); + } else { + cy.then(() => { + if (validationType == CONSTANTS.EVENT) { + const eventName = methodOrEventObject.eventObjectId; + let eventResponse; + if (appId === UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID)) { + const requestMap = { + method: CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCH_EVENT_RESPONSE, + params: eventName, + }; + eventResponse = cy.sendMessagetoPlatforms(requestMap); + } else { + const params = { event: eventName }; + // Generating an intent message using the provided information to send it to a third-party app + const intentMessage = UTILS.createIntentMessage( + CONSTANTS.TASK.GETEVENTRESPONSE, + params + ); + const requestTopic = UTILS.getTopic(appId); + const responseTopic = UTILS.getTopic(appId, CONSTANTS.SUBSCRIBE); + eventResponse = cy.sendMessagetoApp(requestTopic, responseTopic, intentMessage); + } + eventResponse.then((response) => { + response = typeof response === CONSTANTS.TYPE_STRING ? JSON.parse(response) : response; + if ( + response && + response.result && + response.result.hasOwnProperty(CONSTANTS.EVENT_RESPONSE) + ) { + response.result = response.result.eventResponse; + } + cy.updateResponseForFCS(method, null, response, true).then((updatedResponse) => { + cy.saveEventResponse( + updatedResponse, + methodOrEventObject, + eventName, + eventExpected === 'triggers' ? true : false + ); + }); + }); + } + }).then(() => { + try { + if (contentObject && contentObject.data) { + contentObject.data.forEach((object) => { + if (object.validations) { + const scenario = object.type; + const methodOrEventResponse = + validationType == CONSTANTS.EVENT + ? methodOrEventObject + : validationType == CONSTANTS.METHOD + ? methodOrEventObject.apiResponse + : null; + + // Looping through validationJsonPath to find the valid path for validation. + if (validationJsonPath && Array.isArray(validationJsonPath)) { + const validationPath = validationJsonPath.find((path) => { + if ( + path + .split('.') + .reduce((acc, part) => acc && acc[part], methodOrEventResponse) !== + undefined + ) { + return path; + } + }); + validationPath + ? (validationJsonPath = validationPath) + : fireLog.assert( + false, + `Could not find the valid validation path from the validationJsonPath list - ${JSON.stringify(validationJsonPath)}` + ); + } + switch (scenario) { + case CONSTANTS.REGEX: + cy.regExValidation( + method, + object.validations[0].type, + validationJsonPath, + methodOrEventResponse + ); + break; + case CONSTANTS.MISC: + cy.miscellaneousValidation(method, object.validations[0], methodOrEventObject); + break; + case CONSTANTS.DECODE: + const decodeType = object.specialCase; + const responseForDecodeValidation = + validationType == CONSTANTS.EVENT + ? methodOrEventResponse.eventResponse + : validationType == CONSTANTS.METHOD + ? methodOrEventResponse.result + : null; + + cy.decodeValidation( + method, + decodeType, + responseForDecodeValidation, + object.validations[0], + null + ); + break; + case CONSTANTS.FIXTURE: + cy.validateContent( + method, + context, + validationJsonPath, + object.validations[0].type, + validationType, + appId + ); + break; + case CONSTANTS.CUSTOM: + cy.customValidation(object, methodOrEventObject); + break; + case CONSTANTS.UNDEFINED: + cy.undefinedValidation(object, methodOrEventObject, validationType); + break; + default: + assert(false, 'Unsupported validation type'); + break; + } + } + }); + } else { + cy.validateContent( + method, + context, + validationJsonPath, + contentObject, + validationType, + appId + ); + } + } catch (error) { + assert(false, `Unable to validate the response: ${error}`); + } + }); + } + }); +}); diff --git a/cypress/support/cypress-support/src/utils.js b/cypress/support/cypress-support/src/utils.js index 5f3b29434..b8647f382 100644 --- a/cypress/support/cypress-support/src/utils.js +++ b/cypress/support/cypress-support/src/utils.js @@ -852,6 +852,11 @@ function parseValue(str) { if (str === 'false') return false; if (!isNaN(str)) return Number(str); + + // If the string contains comma, split it into an array + if (str.includes(',')) { + return str.split(','); + } } return str; @@ -929,6 +934,32 @@ global.resolveAtRuntime = function (input) { }; }; +/** + * @module utils + * @function resolveRecursiveValues + * @description A Function that recursively check each fields and invoke if it is a function within an array or object. + * @param {*} input - value which need to resolved and it may be string/object/array/function + * @example + * resolveRecursiveValues(function()) + */ +function resolveRecursiveValues(input) { + if (Array.isArray(input)) { + return input.map((item) => resolveRecursiveValues(item)); + } else if (typeof input == CONSTANTS.TYPE_OBJECT && input !== null) { + const newObj = {}; + for (const key in input) { + if (Object.hasOwnProperty.call(input, key)) { + newObj[key] = resolveRecursiveValues(input[key]); + } + } + return newObj; + } else if (input && typeof input === CONSTANTS.TYPE_FUNCTION) { + return input(); + } else { + return input; + } +} + module.exports = { replaceJsonStringWithEnvVar, createIntentMessage, @@ -954,4 +985,5 @@ module.exports = { fireLog, parseValue, checkForSecondaryAppId, + resolveRecursiveValues, }; diff --git a/cypress/support/cypress-support/src/utils.md b/cypress/support/cypress-support/src/utils.md index b668e49c1..3c1e1ea31 100644 --- a/cypress/support/cypress-support/src/utils.md +++ b/cypress/support/cypress-support/src/utils.md @@ -305,6 +305,7 @@ request response - `123` - `true` + ## resolveAtRuntime ### Purpose: Return the function which is having logic to resolve the value for the passed input at runtime. @@ -326,3 +327,16 @@ return - `['result.fontSize', 'result.styles.fontSize']` - `"manage_closedcaptions.setFontSize"` - `1.5` + +## resolveRecursiveValues + +### Purpose: A Function that recursively check each fields and invoke if it is a function within an array or object. + +### Params: +| Param | Definition| Type | +| --- | --- | --- | +| input | value which need to resolved | * | + +### Examples: +request +- `resolveRecursiveValues(function())` diff --git a/cypress/support/step_definitions/fireboltCalls.js b/cypress/support/step_definitions/fireboltCalls.js index b9ecc096d..e276f5401 100644 --- a/cypress/support/step_definitions/fireboltCalls.js +++ b/cypress/support/step_definitions/fireboltCalls.js @@ -18,7 +18,7 @@ import { Given } from '@badeball/cypress-cucumber-preprocessor'; const CONSTANTS = require('../constants/constants'); const _ = require('lodash'); -import { apiObject, eventObject } from '../appObjectConfigs'; +import { apiObject } from '../appObjectConfigs'; import UTILS, { fireLog } from '../cypress-support/src/utils'; /** @@ -35,68 +35,15 @@ Given(/1st party app invokes the (?:'(.+)' )?API to '(.+)'$/, async (sdk, key) = // Fetching the data like method, param, context and action etc. cy.fireboltDataParser(key, sdk).then((parsedDataArr) => { parsedDataArr.forEach((parsedData) => { - const method = parsedData.method; - const params = parsedData.params; - const context = parsedData.context; - const action = parsedData.action; - const expected = parsedData.expected; - const appId = Cypress.env(CONSTANTS.FIRST_PARTY_APPID); - const requestMap = { - method: method, - params: params, - action: action, - }; + parsedData.appId = Cypress.env(CONSTANTS.FIRST_PARTY_APPID); fireLog.info( - 'Call from 1st party App, method: ' + method + ' params: ' + JSON.stringify(params) + 'Call from 1st party App, method: ' + + parsedData.method + + ' params: ' + + JSON.stringify(parsedData.params) ); - cy.sendMessagetoPlatforms(requestMap).then((response) => { - if (response && typeof response == CONSTANTS.TYPE_OBJECT) { - // If error and the error message having 'Method not found' or 'Method not Implemented' mark the testcase as undefined. - if ( - response && - response.error && - response.error.message && - CONSTANTS.ERROR_LIST.includes(response.error.message) - ) { - if (UTILS.getEnvVariable(CONSTANTS.CERTIFICATION) == true) { - assert(false, `${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${method}`); - } else { - fireLog - .info(`NotSupported: ${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${method}`) - .then(() => { - throw new Error(CONSTANTS.STEP_IMPLEMENTATION_MISSING); - }); - } - } - - cy.updateResponseForFCS(method, params, response).then((updatedResponse) => { - // Create a deep copy to avoid reference mutation - const dataToBeCensored = _.cloneDeep(response); - - // Call the 'censorData' command to hide sensitive data - cy.censorData(method, dataToBeCensored).then((maskedResult) => { - fireLog.info(`Response from Firebolt platform: ${JSON.stringify(maskedResult)}`); - }); - // If event and params are not supported setting isScenarioExempted as true for further validation. - if (UTILS.isScenarioExempted(method, params)) { - Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); - } - // Creating object with event name, params, and response etc and storing it in a global list for further validation. - const apiAppObject = new apiObject( - method, - params, - context, - updatedResponse, - expected, - appId - ); - UTILS.getEnvVariable(CONSTANTS.GLOBAL_API_OBJECT_LIST).push(apiAppObject); - }); - } else { - fireLog.info(`${CONSTANTS.PLATFORM_INVALID_RESPONSE_LOG} - ${response}`); - } - }); + cy.sendMessageToPlatformOrApp(CONSTANTS.PLATFORM, parsedData); }); }); }); @@ -124,10 +71,8 @@ Given( : appId === CONSTANTS.THIRD_PARTY_APP ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) : UTILS.checkForSecondaryAppId(appId); - let requestTopic, responseTopic; cy.then(() => { - // Failing the test, When device identifier is passed and corresponding value not there in environment variable. if ( deviceIdentifier && !UTILS.getEnvVariable(deviceIdentifier, false) && @@ -149,92 +94,23 @@ Given( cy.launchApp(CONSTANTS.CERTIFICATION, appId, deviceIdentifier); } }).then(() => { - requestTopic = UTILS.getTopic(appId, null, deviceIdentifier); - responseTopic = UTILS.getTopic(appId, CONSTANTS.SUBSCRIBE, deviceIdentifier); - // Fetching the data like method, param, context and action etc. cy.fireboltDataParser(key, sdk).then((parsedDataArr) => { parsedDataArr.forEach((parsedData) => { - const method = parsedData.method; - const param = parsedData.params; - const context = parsedData.context; - const action = parsedData.action; - const expected = parsedData.expected; - let isNotSupportedApi = false; - - if (UTILS.isScenarioExempted(method, param)) { - isNotSupportedApi = true; - } if ( Cypress.env(CONSTANTS.TEST_TYPE) && Cypress.env(CONSTANTS.TEST_TYPE).toLowerCase() == CONSTANTS.MODULE_NAMES.LIFECYCLE ) { cy.fetchLifecycleHistory(appId); } - const communicationMode = UTILS.getCommunicationMode(); - const additionalParams = { - communicationMode: communicationMode, - action: action, - isNotSupportedApi: isNotSupportedApi, - }; - const params = { method: method, methodParams: param }; - - // Creating intent message using above details to send it to 3rd party app. - const intentMessage = UTILS.createIntentMessage( - CONSTANTS.TASK.CALLMETHOD, - params, - additionalParams - ); + parsedData.appId = appId; + parsedData.deviceIdentifier = deviceIdentifier; fireLog.info( - `Call from app: ${appId}, device: ${deviceIdentifier || UTILS.getEnvVariable(CONSTANTS.DEVICE_MAC)} - method: ${method} params: ${JSON.stringify(param)}` + `Call from app: ${appId}, device: ${deviceIdentifier || UTILS.getEnvVariable(CONSTANTS.DEVICE_MAC)} - method: ${parsedData.method} params: ${JSON.stringify(parsedData.params)}` ); - if (Cypress.env('isRpcOnlyValidation')) { - fireLog.info( - `${method} response will be retrieved in subsequent steps and validated when the rpc-only methods are invoked. Proceeding to the next step.` - ); - } - // Adding additional details to created intent if any platform specific data is present in configModule. - cy.runIntentAddon(CONSTANTS.TASK.CALLMETHOD, intentMessage).then((parsedIntent) => { - // Sending message to 3rd party app. - cy.sendMessagetoApp(requestTopic, responseTopic, parsedIntent).then((result) => { - if (!Cypress.env('isRpcOnlyValidation')) { - if (result === CONSTANTS.NO_RESPONSE) { - assert(false, CONSTANTS.NO_MATCHED_RESPONSE); - } - result = JSON.parse(result); - cy.updateResponseForFCS(method, params, result).then((updatedResponse) => { - // Create a deep copy to avoid reference mutation - const dataToBeCensored = _.cloneDeep(result); - - // Call the 'censorData' command to hide sensitive data - cy.censorData(method, dataToBeCensored).then((maskedResult) => { - const responseType = result.error ? CONSTANTS.ERROR : CONSTANTS.RESULT; - fireLog.info( - `Response from app: ${appId}, device: ${deviceIdentifier || UTILS.getEnvVariable(CONSTANTS.DEVICE_MAC)} - ${JSON.stringify(maskedResult[responseType])}` - ); - }); - - // If method and params are not supported setting isScenarioExempted as true for further validation. - if (UTILS.isScenarioExempted(method, param)) { - Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); - } - - // Creating object with method name, params and response etc and storing it in a global list for further validation. - const apiAppObject = new apiObject( - method, - param, - context, - updatedResponse, - expected, - appId - ); - UTILS.getEnvVariable(CONSTANTS.GLOBAL_API_OBJECT_LIST).push(apiAppObject); - }); - } - }); - }); + cy.sendMessageToPlatformOrApp(CONSTANTS.APP, parsedData); }); }); }); @@ -263,73 +139,12 @@ Given(/'(.+)' registers for the '(.+)' event using the '(.+)' API$/, async (appI : appId === CONSTANTS.THIRD_PARTY_APP ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) : UTILS.checkForSecondaryAppId(appId); - const event = parsedData.method; - const param = parsedData.params; - const context = parsedData.context ? parsedData.context : CONSTANTS.NO_CONTEXT; - const action = parsedData.action; - const expected = parsedData.expected; - let isNotSupportedApi = false; - - if (UTILS.isScenarioExempted(event, param)) { - isNotSupportedApi = true; - } - - const communicationMode = UTILS.getCommunicationMode(); - const additionalParams = { - communicationMode: communicationMode, - action: action, - isNotSupportedApi: isNotSupportedApi, - }; - const params = { event: event, params: param }; - - // Creating intent message using above details to send it to 3rd party app. - const intentMessage = UTILS.createIntentMessage( - CONSTANTS.TASK.REGISTEREVENT, - params, - additionalParams - ); + parsedData.appId = appId; fireLog.info( - `Registering for the ${event} event using ${appId} with params : ${JSON.stringify(param)}` + `Registering for the ${parsedData.method} event using ${appId} with params : ${JSON.stringify(parsedData.params)}` ); - - cy.runIntentAddon(CONSTANTS.TASK.REGISTEREVENT, intentMessage).then((parsedIntent) => { - const requestTopic = UTILS.getTopic(appId); - const responseTopic = UTILS.getTopic(appId, CONSTANTS.SUBSCRIBE); - - // Sending message to 3rd party app. - cy.sendMessagetoApp(requestTopic, responseTopic, parsedIntent).then((result) => { - if (result === CONSTANTS.NO_RESPONSE) { - assert(false, CONSTANTS.NO_MATCHED_RESPONSE); - } - result = JSON.parse(result); - fireLog.info(`Response from ${appId}: ${JSON.stringify(result.result)}`); - if (result && result.result && result.result.hasOwnProperty(CONSTANTS.LISTENING)) { - const eventResponse = { - eventListenerId: result.result.event + '-' + result.id, - eventListenerResponse: result.result, - }; - result.result = eventResponse; - } - cy.updateResponseForFCS(event, params, result).then((updatedResponse) => { - // If event and params are not supported setting isScenarioExempted as true for further validation. - if (UTILS.isScenarioExempted(event, param)) { - Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); - } - - // Creating object with event name, params and response etc and storing it in a global list for further validation. - const eventAppObject = new eventObject( - event, - param, - context, - updatedResponse, - appId, - expected - ); - UTILS.getEnvVariable(CONSTANTS.GLOBAL_EVENT_OBJECT_LIST).push(eventAppObject); - }); - }); - }); + cy.sendMessageToPlatformOrApp(CONSTANTS.APP, parsedData, CONSTANTS.TASK.REGISTEREVENT); }); }); }); @@ -347,77 +162,13 @@ Given(/1st party app registers for the '(.+)' event using the '(.+)' API$/, asyn // Fetching the data like method, param, context and action etc. cy.fireboltDataParser(key, sdk).then((parsedDataArr) => { parsedDataArr.forEach((parsedData) => { - const event = parsedData.method; - const params = parsedData.params; - const context = parsedData.context; - const action = parsedData.action; - const expected = parsedData.expected; - const requestMap = { - method: event, - params: params, - action: action, - task: CONSTANTS.TASK.REGISTEREVENT, - }; - const appId = UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID); - // Assigning event_param env if param has empty object - if (Object.keys(requestMap.params).length === 0) { - // To Do :debug event_param issue by passing isrequired as false for getEnvVariable,need to debug further - requestMap.params = UTILS.getEnvVariable(CONSTANTS.EVENT_PARAM, false); - } + parsedData.appId = UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID); fireLog.info( - `Registering for the ${event} event using 1st party App with params : ${JSON.stringify( - params + `Registering for the ${parsedData.method} event using 1st party App with params : ${JSON.stringify( + parsedData.params )}` ); - - // Sending the message to platform to register the event. - cy.sendMessagetoPlatforms(requestMap).then((response) => { - if (response && typeof response == CONSTANTS.TYPE_OBJECT) { - // If error and the error message having 'Method not found' or 'Method not Implemented' mark the testcase as undefined. - if ( - response && - response.error && - response.error.message && - CONSTANTS.ERROR_LIST.includes(response.error.message) - ) { - if (UTILS.getEnvVariable(CONSTANTS.CERTIFICATION) == true) { - assert(false, `${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${event}`); - } else { - fireLog - .assert(`NotSupported: ${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${event}`) - .then(() => { - throw new Error(CONSTANTS.STEP_IMPLEMENTATION_MISSING); - }); - } - } else if (response && response.error && response.error.message) { - assert( - false, - `Event registration failed for event ${event} with error message: ${response.error.message} ` - ); - } - - cy.updateResponseForFCS(event, params, response).then((updatedResponse) => { - fireLog.info('Response from Firebolt platform: ' + JSON.stringify(response)); - // If event and params are not supported setting isScenarioExempted as true for further validation. - if (UTILS.isScenarioExempted(event, params)) { - Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); - } - - // Creating object with event name, params and response etc and storing it in a global list for further validation. - const eventAppObject = new eventObject( - event, - params, - context, - updatedResponse, - appId, - expected - ); - UTILS.getEnvVariable(CONSTANTS.GLOBAL_EVENT_OBJECT_LIST).push(eventAppObject); - }); - } else { - fireLog.info(`${CONSTANTS.PLATFORM_INVALID_RESPONSE_LOG} - ${response}`); - } - }); + cy.sendMessageToPlatformOrApp(CONSTANTS.PLATFORM, parsedData, CONSTANTS.TASK.REGISTEREVENT); }); }); }); @@ -572,555 +323,3 @@ Given(/User triggers event with value as '(.+)'/, (key) => { throw new Error(CONSTANTS.STEP_IMPLEMENTATION_MISSING); }); }); - -/** - * @module fireboltCalls - * @function 1st party app invokes the '(.+)' API (?:'(.+)' )?to set '(.+)' to( invalid)? '(.+)' - * @description Sending a message to platform to set a value - * @param {String} sdk - sdk name. - * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData. - * @param {String} attribute - The attribute to which the value is going to be set (ex. fontFamily). - * @param {String} invalidValue - Determines whether expecting for an error or result. - * @param {String} value - The value used by the set method to set the value (ex. monospaced_sanserif) - * @example - * Given '1st party app' invokes the 'Firebolt' API 'CLOSEDCAPTION_SETTINGS' to set 'enable' to 'true' - * Given '1st party app' invokes the 'Firebolt' API 'CLOSEDCAPTION_SETTINGS' to set 'enable' to invalid 'test' - * Given '1st party app' invokes the 'Firebolt' API to set 'enable' to 'true' - */ -Given( - /1st party app invokes the '(.+)' API (?:'(.+)' )?to set '(.+)' to( invalid)? '(.+)'$/, - async (sdk, fireboltCallKey, attribute, invalidValue, value) => { - if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { - value = UTILS.parseValue(value); - let fireboltCallObject; - let fireboltCallObjectErrorMessage = CONSTANTS.NO_DATA_FOR_THE_KEY + fireboltCallKey; - - // runtime environment variable holds attribute and value - Cypress.env('runtime', { - attribute: attribute, - value: value, - }); - - // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable - if (fireboltCallKey) { - cy.getFireboltData(fireboltCallKey).then((fireboltData) => { - fireboltCallObject = fireboltData; - cy.wrap(UTILS.getEnvVariable('runtime')).then((object) => { - object.fireboltCall = fireboltData; - Cypress.env('runtime', object); - }); - }); - } else { - fireboltCallObject = UTILS.getEnvVariable('runtime').fireboltCall; - fireboltCallObjectErrorMessage = - 'Unable to find the firebolt object in the runtime environment variable'; - } - - cy.then(() => { - // Failing the test when fireboltCall object not there - if (!fireboltCallObject) { - fireLog.fail(fireboltCallObjectErrorMessage); - } else { - let setMethod = - typeof fireboltCallObject.setMethod === CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.setMethod() - : fireboltCallObject.setMethod; - let setParams; - - // Extracting the parameter from the fireboltCall object - if (typeof fireboltCallObject.setParams === CONSTANTS.TYPE_FUNCTION) { - setParams = { value: fireboltCallObject.setParams() }; - } else if (typeof fireboltCallObject.setParams === CONSTANTS.TYPE_OBJECT) { - setParams = fireboltCallObject.setParams; - - // Iterating through the object and invoking it if it is a function - for (const key in setParams) { - if (typeof setParams[key] === CONSTANTS.TYPE_FUNCTION) { - setParams[key] = setParams[key](); - } - } - } else { - setParams = { value: fireboltCallObject.setParams }; - } - - const context = {}; - const expected = invalidValue ? 'error' : 'result'; - const appId = Cypress.env(CONSTANTS.FIRST_PARTY_APPID); - let action = CONSTANTS.ACTION_CORE.toLowerCase(); - - // Splitting the method name if it contains an underscore and using the first part to determine the action that decides sdk. - if (setMethod && setMethod.includes('_')) { - action = setMethod.split('_')[0]; - setMethod = setMethod.split('_')[1]; - } - - // If method and params are not supported setting isScenarioExempted as true for further validation. - if (UTILS.isScenarioExempted(setMethod, setParams)) { - Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); - } - const requestMap = { - method: setMethod, - params: setParams, - action: action, - }; - - cy.log( - 'Call from 1st party App, method: ' + - setMethod + - ' params: ' + - JSON.stringify(setParams) - ); - cy.sendMessagetoPlatforms(requestMap).then((response) => { - if (response && typeof response == CONSTANTS.TYPE_OBJECT) { - // If error and the error message having 'Method not found' or 'Method not Implemented' mark the testcase as undefined. - if ( - response && - response.error && - response.error.message && - CONSTANTS.ERROR_LIST.includes(response.error.message) - ) { - if (UTILS.getEnvVariable(CONSTANTS.CERTIFICATION) == true) { - assert(false, `${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${setMethod}`); - } else { - cy.log(`NotSupported: ${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${setMethod}`).then( - () => { - throw new Error(CONSTANTS.STEP_IMPLEMENTATION_MISSING); - } - ); - } - } - - cy.updateResponseForFCS(setMethod, setParams, response).then((updatedResponse) => { - // Create a deep copy to avoid reference mutation - const dataToBeCensored = _.cloneDeep(response); - - // Call the 'censorData' command to hide sensitive data - cy.censorData(setMethod, dataToBeCensored).then((maskedResult) => { - cy.log(`Response from Firebolt platform: ${JSON.stringify(maskedResult)}`); - }); - - // Creating object with method name, params, and response etc and storing it in a global list for further validation. - const apiAppObject = new apiObject( - setMethod, - setParams, - context, - updatedResponse, - expected, - appId - ); - UTILS.getEnvVariable(CONSTANTS.GLOBAL_API_OBJECT_LIST).push(apiAppObject); - }); - } else { - cy.log(`${CONSTANTS.PLATFORM_INVALID_RESPONSE_LOG} - ${response}`); - } - }); - } - }); - } else { - fireLog.fail(`${sdk} SDK not Supported`); - } - } -); - -/** - * @module fireboltCalls - * @function '(.+)' invokes the '(.+)' get API(?: '(.+)') - * @description Sending a message to platform or app to get a value - * @param {String} appId - app identifier. - * @param {String} sdk - sdk name. - * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData. - * @example - * Given '1st party app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS' - * Given '3rd party app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS' - * Given '3rd party app' invokes the 'Firebolt' get API - * Given 'test_app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS' - */ -Given(/'(.+)' invokes the '(.+)' get API(?: '(.+)')?$/, async (appId, sdk, fireboltCallKey) => { - if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { - let fireboltCallObject; - let fireboltCallObjectErrorMessage = CONSTANTS.NO_DATA_FOR_THE_KEY + fireboltCallKey; - - // Creating runtime environment variable - if (!UTILS.getEnvVariable(CONSTANTS.RUNTIME, false)) { - Cypress.env(CONSTANTS.RUNTIME, {}); - } - - // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable - if (fireboltCallKey) { - cy.getFireboltData(fireboltCallKey).then((fireboltData) => { - fireboltCallObject = fireboltData; - cy.wrap(UTILS.getEnvVariable(CONSTANTS.RUNTIME)).then((object) => { - object.fireboltCall = fireboltData; - Cypress.env(CONSTANTS.RUNTIME, object); - }); - }); - } else { - fireboltCallObject = UTILS.getEnvVariable(CONSTANTS.RUNTIME).fireboltCall; - fireboltCallObjectErrorMessage = - 'Unable to find the firebolt object in the runtime environment variable'; - } - - cy.then(() => { - // Failing the test when fireboltCall object not there - if (!fireboltCallObject) { - fireLog.assert(false, fireboltCallObjectErrorMessage); - } else { - let method = - typeof fireboltCallObject.method === CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.method() - : fireboltCallObject.method; - const param = - fireboltCallObject.params && typeof fireboltCallObject.params === CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.params() - : fireboltCallObject.params; - - const context = {}; - const expected = CONSTANTS.RESULT; - appId = - appId === CONSTANTS.THIRD_PARTY_APP - ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) - : appId === CONSTANTS.FIRST_PARTY_APP - ? UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID) - : appId; - let action = CONSTANTS.ACTION_CORE.toLowerCase(); - - // Splitting the method name if it contains an underscore and using the first part to determine the action that decides sdk. - if (method && method.includes('_')) { - action = method.split('_')[0]; - method = method.split('_')[1]; - } - - // If method and param are not supported setting isScenarioExempted as true for further validation. - if (UTILS.isScenarioExempted(method, param)) { - Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); - } - - if (appId == UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID)) { - const requestMap = { - method: method, - params: param, - action: action, - }; - - cy.log( - 'Call from 1st party App, method: ' + method + ' params: ' + JSON.stringify(param) - ); - cy.sendMessagetoPlatforms(requestMap).then((response) => { - if (response && typeof response == CONSTANTS.TYPE_OBJECT) { - // If error and the error message having 'Method not found' or 'Method not Implemented' mark the testcase as undefined. - if ( - response && - response.error && - response.error.message && - CONSTANTS.ERROR_LIST.includes(response.error.message) - ) { - if (UTILS.getEnvVariable(CONSTANTS.CERTIFICATION) == true) { - assert(false, `${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${method}`); - } else { - cy.log(`NotSupported: ${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${method}`).then( - () => { - throw new Error(CONSTANTS.STEP_IMPLEMENTATION_MISSING); - } - ); - } - } - - cy.updateResponseForFCS(method, param, response).then((updatedResponse) => { - // Create a deep copy to avoid reference mutation - const dataToBeCensored = _.cloneDeep(response); - - // Call the 'censorData' command to hide sensitive data - cy.censorData(method, dataToBeCensored).then((maskedResult) => { - cy.log(`Response from Firebolt platform: ${JSON.stringify(maskedResult)}`); - }); - - // Creating object with method name, param, and response etc and storing it in a global list for further validation. - const apiAppObject = new apiObject( - method, - param, - context, - updatedResponse, - expected, - appId - ); - UTILS.getEnvVariable(CONSTANTS.GLOBAL_API_OBJECT_LIST).push(apiAppObject); - }); - } else { - cy.log(`${CONSTANTS.PLATFORM_INVALID_RESPONSE_LOG} - ${response}`); - } - }); - } else { - let isNotSupportedApi = false; - - if (UTILS.isScenarioExempted(method, param)) { - isNotSupportedApi = true; - } - if ( - Cypress.env(CONSTANTS.TEST_TYPE) && - Cypress.env(CONSTANTS.TEST_TYPE).toLowerCase() == CONSTANTS.MODULE_NAMES.LIFECYCLE - ) { - cy.fetchLifecycleHistory(appId); - } - const communicationMode = UTILS.getCommunicationMode(); - const additionalParams = { - communicationMode: communicationMode, - action: action, - isNotSupportedApi: isNotSupportedApi, - }; - const params = { method: method, methodParams: param }; - - // Creating intent message using above details to send it to 3rd party app. - const intentMessage = UTILS.createIntentMessage( - CONSTANTS.TASK.CALLMETHOD, - params, - additionalParams - ); - - fireLog.info(`Call from ${appId}, method: ${method} params: ${JSON.stringify(param)}`); - if (Cypress.env(CONSTANTS.IS_RPC_ONLY)) { - fireLog.info( - `${method} response will be retrieved in subsequent steps and validated when the rpc-only methods are invoked. Proceeding to the next step.` - ); - } - - // Adding additional details to created intent if any platform specific data is present in configModule. - cy.runIntentAddon(CONSTANTS.TASK.CALLMETHOD, intentMessage).then((parsedIntent) => { - const requestTopic = UTILS.getTopic(appId); - const responseTopic = UTILS.getTopic(appId, CONSTANTS.SUBSCRIBE); - - // Sending message to 3rd party app. - cy.sendMessagetoApp(requestTopic, responseTopic, parsedIntent).then((result) => { - if (!Cypress.env(CONSTANTS.IS_RPC_ONLY)) { - if (result === CONSTANTS.NO_RESPONSE) { - assert(false, CONSTANTS.NO_MATCHED_RESPONSE); - } - - result = JSON.parse(result); - - // Create a deep copy to avoid reference mutation - const dataToBeCensored = _.cloneDeep(result.report.apiResponse); - - // Call the 'censorData' command to hide sensitive data - cy.censorData(method, dataToBeCensored).then((maskedResult) => { - fireLog.info(`Response from ${appId}: ${JSON.stringify(maskedResult)}`); - }); - - // Creating object with method name, param and response etc and storing it in a global list for further validation. - const apiAppObject = new apiObject( - method, - param, - context, - result.report, - expected, - appId - ); - UTILS.getEnvVariable(CONSTANTS.GLOBAL_API_OBJECT_LIST).push(apiAppObject); - } - }); - }); - } - } - }); - } else { - fireLog.assert(false, `${sdk} SDK not Supported`); - } -}); - -/** - * @module fireboltCalls - * @function '(.+)' registers for the '(.*?)'(?: '(.*?)')? event - * @description Sending a message to platform or app to register a event - * @param {String} appId - app identtifier. - * @param {String} sdk - sdk name. - * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData. - * @example - * And '1st party app' registers for the 'Firebolt' 'CLOSEDCAPTION_SETTINGS' event - * And '3rd party app' registers for the 'Firebolt' 'CLOSEDCAPTION_SETTINGS' event - * And '1st party app' registers for the 'Firebolt' event - */ -Given( - /'(.+)' registers for the '(.*?)'(?: '(.*?)')? event$/, - async (appId, sdk, fireboltCallKey) => { - if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { - let fireboltCallObject; - let fireboltCallObjectErrorMessage = CONSTANTS.NO_DATA_FOR_THE_KEY + fireboltCallKey; - - // Creating runtime environment variable - if (!UTILS.getEnvVariable('runtime', false)) { - Cypress.env('runtime', {}); - } - - // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable - // TODO: appending the firebolt object will take care in optimization ticket - if (fireboltCallKey) { - cy.getFireboltData(fireboltCallKey).then((fireboltData) => { - fireboltCallObject = fireboltData; - cy.wrap(UTILS.getEnvVariable('runtime')).then((object) => { - object.fireboltCall = fireboltData; - Cypress.env('runtime', object); - }); - }); - } else { - fireboltCallObject = UTILS.getEnvVariable('runtime').fireboltCall; - fireboltCallObjectErrorMessage = - 'Unable to find the firebolt object in the runtime environment variable'; - } - - cy.then(() => { - // Failing the test when fireboltCall object not there - if (!fireboltCallObject) { - fireLog.assert(false, fireboltCallObjectErrorMessage); - } else { - let event = - typeof fireboltCallObject.event === CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.event() - : fireboltCallObject.event; - const eventParams = {}; - const context = {}; - appId = - appId === CONSTANTS.THIRD_PARTY_APP - ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) - : appId === CONSTANTS.FIRST_PARTY_APP - ? Cypress.env(CONSTANTS.FIRST_PARTY_APPID) - : appId; - let action = CONSTANTS.ACTION_CORE.toLowerCase(); - - // Splitting the method name if it contains an underscore and using the first part to determine the action that decides sdk. - if (event && event.includes('_')) { - action = setMethod.split('_')[0]; - event = event.split('_')[1]; - } - - // If event and params are not supported setting isScenarioExempted as true for further validation. - if (UTILS.isScenarioExempted(event, eventParams)) { - Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); - } - if (appId == UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID)) { - const requestMap = { - method: event, - params: eventParams, - action: action, - task: CONSTANTS.TASK.REGISTEREVENT, - }; - - // Assigning event_param env if param has empty object - if (Object.keys(requestMap.params).length === 0) { - // To Do :debug event_param issue by passing isrequired as false for getEnvVariable,need to debug further - requestMap.params = UTILS.getEnvVariable(CONSTANTS.EVENT_PARAM, false); - } - fireLog.info( - `Registering for the ${event} event using 1st party App with params : ${JSON.stringify( - eventParams - )}` - ); - // Sending the message to platform to register the event. - cy.sendMessagetoPlatforms(requestMap).then((response) => { - if (response && typeof response == CONSTANTS.TYPE_OBJECT) { - // If error and the error message having 'Method not found' or 'Method not Implemented' mark the testcase as undefined. - if ( - response && - response.error && - response.error.message && - CONSTANTS.ERROR_LIST.includes(response.error.message) - ) { - if (UTILS.getEnvVariable(CONSTANTS.CERTIFICATION) == true) { - assert(false, `${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${event}`); - } else { - fireLog - .assert(`NotSupported: ${CONSTANTS.PLATFORM_NOT_SUPPORT_LOG}: ${event}`) - .then(() => { - throw new Error(CONSTANTS.STEP_IMPLEMENTATION_MISSING); - }); - } - } else if (response && response.error && response.error.message) { - assert( - false, - `Event registration failed for event ${event} with error message: ${response.error.message} ` - ); - } - - cy.updateResponseForFCS(event, eventParams, response).then((updatedResponse) => { - fireLog.info('Response from Firebolt platform: ' + JSON.stringify(response)); - // If event and params are not supported setting isScenarioExempted as true for further validation. - if (UTILS.isScenarioExempted(event, eventParams)) { - Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); - } - - // Creating object with event name, params and response etc and storing it in a global list for further validation. - const eventAppObject = new eventObject( - event, - eventParams, - context, - updatedResponse, - appId - ); - UTILS.getEnvVariable(CONSTANTS.GLOBAL_EVENT_OBJECT_LIST).push(eventAppObject); - }); - } else { - fireLog.info(`${CONSTANTS.PLATFORM_INVALID_RESPONSE_LOG} - ${response}`); - } - }); - } else { - let isNotSupportedApi = false; - - if (UTILS.isScenarioExempted(event, eventParams)) { - isNotSupportedApi = true; - } - - const communicationMode = UTILS.getCommunicationMode(); - const additionalParams = { - communicationMode: communicationMode, - action: action, - isNotSupportedApi: isNotSupportedApi, - }; - const params = { event: event, params: eventParams }; - - // Creating intent message using above details to send it to 3rd party app. - const intentMessage = UTILS.createIntentMessage( - CONSTANTS.TASK.REGISTEREVENT, - params, - additionalParams - ); - - fireLog.info( - `Registering for the ${event} event using ${appId} with params : ${JSON.stringify(eventParams)}` - ); - - cy.runIntentAddon(CONSTANTS.TASK.REGISTEREVENT, intentMessage).then((parsedIntent) => { - const requestTopic = UTILS.getTopic(appId); - const responseTopic = UTILS.getTopic(appId, CONSTANTS.SUBSCRIBE); - - // Sending message to 3rd party app. - cy.sendMessagetoApp(requestTopic, responseTopic, parsedIntent).then((result) => { - if (result === CONSTANTS.NO_RESPONSE) { - assert(false, CONSTANTS.NO_MATCHED_RESPONSE); - } - result = JSON.parse(result); - fireLog.info( - `Response from ${appId}: ${JSON.stringify(result.report.eventListenerResponse)}` - ); - - // If event and params are not supported setting isScenarioExempted as true for further validation. - if (UTILS.isScenarioExempted(event, eventParams)) { - Cypress.env(CONSTANTS.IS_SCENARIO_EXEMPTED, true); - } - - // Creating object with event name, params and response etc and storing it in a global list for further validation. - const eventAppObject = new eventObject( - event, - eventParams, - context, - result.report, - appId - ); - UTILS.getEnvVariable(CONSTANTS.GLOBAL_EVENT_OBJECT_LIST).push(eventAppObject); - }); - }); - } - } - }); - } else { - fireLog.assert(false, `${sdk} SDK not Supported`); - } - } -); diff --git a/cypress/support/step_definitions/fireboltCalls.md b/cypress/support/step_definitions/fireboltCalls.md index ddbe6d51c..b0193b815 100644 --- a/cypress/support/step_definitions/fireboltCalls.md +++ b/cypress/support/step_definitions/fireboltCalls.md @@ -15,7 +15,7 @@ * `Given 1st party app invokes the API to 'get device id'` -## '(.+)' invokes the '(.+)' API to '(.+) +## '(.+)' invokes the '(.+)' API to '(.+)'(?: on '(.+)' device)? ### Purpose: send message to 3rd party app to make api call. @@ -86,55 +86,3 @@ Note: Key name value is an object and it can contains data as below ### Examples: * `And I clear 'clear accessibility.onClosedCaptionsSettingsChanged' listeners` - - -## 1st party app invokes the '(.+)' API (?:'(.+)' )?to set '(.+)' to( invalid)? '(.+)' - -### Purpose: Sending a message to platform to set a value - -### Params: -| Param | Definition | -| --- | --- | -| sdk | sdk name | -| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData | -| attribute | The attribute we are setting (ex. fontFamily) | -| invalidValue | Determines whether expecting for an error or result | -| value | The value used by the set method to set the value (ex. monospaced_sanserif) | - -### Examples: -* `Given '1st party app' invokes the 'Firebolt' API 'CLOSEDCAPTION_SETTINGS' to set 'enable' to 'true'` -* `Given '1st party app' invokes the 'Firebolt' API 'CLOSEDCAPTION_SETTINGS' to set 'enable' to invalid 'test'` -* `Given '1st party app' invokes the 'Firebolt' API to set 'enable' to 'true'` - -## '(.+)' registers for the '(.*?)'(?: '(.*?)')? event - -### Purpose: Sending a message to platform or app to register a event - -### Params: -| Param | Definition | -| --- | --- | -| appId |app identtifier | -| sdk | sdk name | -| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData | - -### Examples: - * `And '1st party app' registers for the 'Firebolt' 'CLOSEDCAPTION_SETTINGS' event` - * `And '3rd party app' registers for the 'Firebolt' 'CLOSEDCAPTION_SETTINGS' event` - * `And '1st party app' registers for the 'Firebolt' event` - -## '(.+)' invokes the '(.+)' get API(?: '(.+)') - -### Purpose: Sending a message to platform or 3rd party app to get a value - -### Params: -| Param | Definition | -| --- | --- | -| appId | app identifier. | -| sdk | sdk name | -| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData | - -### Examples: -* `And '1st party app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS'` -* `And '3rd party app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS'` -* `And '3rd party app' invokes the 'Firebolt' get API` -* `And 'test_app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS'` \ No newline at end of file diff --git a/cypress/support/step_definitions/getterSetterCalls.js b/cypress/support/step_definitions/getterSetterCalls.js index acc0db98a..44b35ed37 100644 --- a/cypress/support/step_definitions/getterSetterCalls.js +++ b/cypress/support/step_definitions/getterSetterCalls.js @@ -16,25 +16,509 @@ * SPDX-License-Identifier: Apache-2.0 */ import { Given } from '@badeball/cypress-cucumber-preprocessor'; +import UTILS, { fireLog } from '../cypress-support/src/utils'; const CONSTANTS = require('../constants/constants'); /** - * @module settersGetterCalls + * @module getterSetterCalls * @function Given we test the '(.+)' getters and setters * @description Define and cache the fireboltCall object to use for getters and setters scenario by saving the object in env variable. * @param {String} key - key name of the fireboltCall setter/getter data. * @example * Given we test the 'CLOSED_CAPTIONS' getters and setters + * Given we test the 'CLOSED_CAPTIONS' getters and setters 'enabled' to 'true' */ -Given(/we test the '(.+)' getters and setters$/, async (key) => { - // Clear any current env.runtime variables - Cypress.env(CONSTANTS.RUNTIME, {}); - - // Look for the firebolt call key in firebolt data - cy.getFireboltData(key).then((parsedData) => { - // getFireboltData handles the case where the key is not found - // Save the object as env.runtime.fireboltCall - const runtime = { fireboltCall: parsedData }; - Cypress.env(CONSTANTS.RUNTIME, runtime); - }); +Given( + /we test the '(.+)' getters and setters(?: '(.+)' to '(.+)')?$/, + async (key, attribute, value) => { + // Clear any current env.runtime variables + Cypress.env(CONSTANTS.RUNTIME, {}); + + // Look for the firebolt call key in firebolt data + cy.getFireboltData(key).then((parsedData) => { + // getFireboltData handles the case where the key is not found + // Save the object as env.runtime.fireboltCall + const runtime = { fireboltCall: parsedData }; + if (attribute && value) { + value = UTILS.parseValue(value); + runtime.attribute = attribute; + runtime.value = value; + } + Cypress.env(CONSTANTS.RUNTIME, runtime); + }); + } +); + +/** + * @module getterSetterCalls + * @function Given 1st party app invokes the '(.+)' API (?:'(.+)' )?to set '(.+)' to( invalid)? '(.+)' + * @description Sending a message to platform to set a value + * @param {String} sdk - sdk name. + * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData. + * @param {String} attribute - The attribute to which the value is going to be set (ex. fontFamily). + * @param {String} invalidValue - Determines whether expecting for an error or result. + * @param {String} value - The value used by the set method to set the value (ex. monospaced_sanserif) + * @example + * Given 1st party app invokes the 'Firebolt' API 'CLOSEDCAPTION_SETTINGS' to set 'enable' to 'true' + * Given 1st party app invokes the 'Firebolt' API 'CLOSEDCAPTION_SETTINGS' to set 'enable' to invalid 'test' + * Given 1st party app invokes the 'Firebolt' API to set 'enable' to 'true' + */ +Given( + /1st party app invokes the '(.+)' API (?:'(.+)' )?to set '(.+)' to( invalid)? '(.+)'$/, + async (sdk, fireboltCallKey, attribute, invalidValue, value) => { + if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { + value = UTILS.parseValue(value); + let fireboltCallObject; + let fireboltCallObjectErrorMessage = CONSTANTS.NO_DATA_FOR_THE_KEY + fireboltCallKey; + + if (!UTILS.getEnvVariable(CONSTANTS.RUNTIME, false)) { + Cypress.env(CONSTANTS.RUNTIME, {}); + } + + // Store attribute and value in the runtime environment variable + let object = UTILS.getEnvVariable(CONSTANTS.RUNTIME); + object = Object.assign(object, { + attribute: attribute, + value: value, + }); + Cypress.env(CONSTANTS.RUNTIME, object); + + // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable. + if (fireboltCallKey) { + cy.getFireboltData(fireboltCallKey).then((fireboltData) => { + fireboltCallObject = fireboltData; + cy.wrap(UTILS.getEnvVariable(CONSTANTS.RUNTIME)).then((object) => { + object.fireboltCall = fireboltData; + Cypress.env(CONSTANTS.RUNTIME, object); + }); + }); + } else { + fireboltCallObject = UTILS.getEnvVariable(CONSTANTS.RUNTIME).fireboltCall; + fireboltCallObjectErrorMessage = + 'Unable to find the firebolt object in the runtime environment variable'; + } + + cy.then(() => { + // Failing the test when fireboltCall object not there + if (!fireboltCallObject) { + fireLog.assert(false, fireboltCallObjectErrorMessage); + } else { + let setMethod = UTILS.resolveRecursiveValues(fireboltCallObject.setMethod); + let setParams; + + // Extracting the parameter from the fireboltCall object + if ( + fireboltCallObject.setParams && + typeof fireboltCallObject.setParams === CONSTANTS.TYPE_OBJECT + ) { + setParams = fireboltCallObject.setParams; + + // Iterating through the object and invoke if it is a function + for (const key in setParams) { + if (typeof setParams[key] === CONSTANTS.TYPE_FUNCTION) { + setParams[key] = setParams[key](); + } + } + } else { + setParams = { value: UTILS.resolveRecursiveValues(fireboltCallObject.setParams) }; + } + + const context = {}; + const expected = invalidValue ? CONSTANTS.ERROR : CONSTANTS.RESULT; + let action = CONSTANTS.ACTION_CORE.toLowerCase(); + + // Splitting the method name if it contains an underscore and using the first part to determine the action that decides sdk. + if (setMethod && setMethod.includes('_')) { + action = setMethod.split('_')[0]; + setMethod = setMethod.split('_')[1]; + } + + const additionalParams = { + method: setMethod, + params: setParams, + context: context, + action: action, + expected: expected, + appId: Cypress.env(CONSTANTS.FIRST_PARTY_APPID), + }; + + fireLog.info( + 'Call from 1st party App, method: ' + + setMethod + + ' params: ' + + JSON.stringify(setParams) + ); + cy.sendMessageToPlatformOrApp(CONSTANTS.PLATFORM, additionalParams); + } + }); + } else { + fireLog.assert(false, `${sdk} SDK not Supported`); + } + } +); + +/** + * @module getterSetterCalls + * @function Given '(.+)' invokes the '(.+)' get API(?: '(.+)') + * @description Sending a message to platform or app to get a value + * @param {String} appId - app identifier. + * @param {String} sdk - sdk name. + * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData. + * @example + * Given '1st party app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS' + * Given '3rd party app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS' + * Given '3rd party app' invokes the 'Firebolt' get API + * Given 'test_app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS' + */ +Given(/'(.+)' invokes the '(.+)' get API(?: '(.+)')?$/, async (appId, sdk, fireboltCallKey) => { + if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { + let fireboltCallObject; + let fireboltCallObjectErrorMessage = CONSTANTS.NO_DATA_FOR_THE_KEY + fireboltCallKey; + + // Creating runtime environment variable, if not present + if (!UTILS.getEnvVariable(CONSTANTS.RUNTIME, false)) { + Cypress.env(CONSTANTS.RUNTIME, {}); + } + + // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable + if (fireboltCallKey) { + // Fetching fireboltCall object from fireboltCalls data + cy.getFireboltData(fireboltCallKey).then((fireboltData) => { + fireboltCallObject = fireboltData; + cy.wrap(UTILS.getEnvVariable(CONSTANTS.RUNTIME)).then((object) => { + object.fireboltCall = fireboltData; + Cypress.env(CONSTANTS.RUNTIME, object); + }); + }); + } else { + // Reading fireboltCall object from the environment variable + fireboltCallObject = UTILS.getEnvVariable(CONSTANTS.RUNTIME).fireboltCall; + fireboltCallObjectErrorMessage = + 'Unable to find the firebolt object in the runtime environment variable'; + } + + cy.then(() => { + // Failing the test when fireboltCall object not there + if (!fireboltCallObject) { + fireLog.assert(false, fireboltCallObjectErrorMessage); + } else { + let method = UTILS.resolveRecursiveValues(fireboltCallObject.method); + const param = UTILS.resolveRecursiveValues(fireboltCallObject.params); + const context = {}; + const expected = CONSTANTS.RESULT; + appId = + appId === CONSTANTS.THIRD_PARTY_APP + ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) + : appId === CONSTANTS.FIRST_PARTY_APP + ? UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID) + : appId; + let action = CONSTANTS.ACTION_CORE.toLowerCase(); + + // Splitting the method name if it contains an underscore and using the first part to determine the action that decides sdk. + if (method && method.includes('_')) { + action = method.split('_')[0]; + method = method.split('_')[1]; + } + + const additionalParams = { + method: method, + params: param, + context: context, + action: action, + expected: expected, + appId: appId, + }; + + if (appId == UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID)) { + fireLog.info( + 'Call from 1st party App, method: ' + method + ' params: ' + JSON.stringify(param) + ); + cy.sendMessageToPlatformOrApp(CONSTANTS.PLATFORM, additionalParams); + } else { + if ( + Cypress.env(CONSTANTS.TEST_TYPE) && + Cypress.env(CONSTANTS.TEST_TYPE).toLowerCase() == CONSTANTS.MODULE_NAMES.LIFECYCLE + ) { + cy.fetchLifecycleHistory(appId); + } + fireLog.info(`Call from ${appId}, method: ${method} params: ${JSON.stringify(param)}`); + cy.sendMessageToPlatformOrApp(CONSTANTS.APP, additionalParams); + } + } + }); + } else { + fireLog.assert(false, `${sdk} SDK not Supported`); + } }); + +/** + * @module getterSetterCalls + * @function Given '(.+)' registers for the '(.*?)'(?: '(.*?)')? event + * @description Sending a message to platform or app to register an event + * @param {String} appId - app identifier. + * @param {String} sdk - sdk name. + * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData. + * @example + * And '1st party app' registers for the 'Firebolt' 'CLOSEDCAPTION_SETTINGS' event + * And '3rd party app' registers for the 'Firebolt' 'CLOSEDCAPTION_SETTINGS' event + * And '1st party app' registers for the 'Firebolt' event + */ +Given( + /'(.+)' registers for the '(.*?)'(?: '(.*?)')? event$/, + async (appId, sdk, fireboltCallKey) => { + if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { + let fireboltCallObject; + let fireboltCallObjectErrorMessage = CONSTANTS.NO_DATA_FOR_THE_KEY + fireboltCallKey; + + // Creating runtime environment variable + if (!UTILS.getEnvVariable(CONSTANTS.RUNTIME, false)) { + Cypress.env(CONSTANTS.RUNTIME, {}); + } + + // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable + if (fireboltCallKey) { + // Fetching fireboltCall object from fireboltCalls data + cy.getFireboltData(fireboltCallKey).then((fireboltData) => { + fireboltCallObject = fireboltData; + cy.wrap(UTILS.getEnvVariable(CONSTANTS.RUNTIME)).then((object) => { + object.fireboltCall = fireboltData; + Cypress.env(CONSTANTS.RUNTIME, object); + }); + }); + } else { + // Reading fireboltCall object from the environment variable + fireboltCallObject = UTILS.getEnvVariable(CONSTANTS.RUNTIME).fireboltCall; + fireboltCallObjectErrorMessage = + 'Unable to find the firebolt object in the runtime environment variable'; + } + + cy.then(() => { + // Failing the test when fireboltCall object not there + if (!fireboltCallObject) { + fireLog.assert(false, fireboltCallObjectErrorMessage); + } else { + let event = UTILS.resolveRecursiveValues(fireboltCallObject.event); + const eventParams = {}; + const context = {}; + appId = + appId === CONSTANTS.THIRD_PARTY_APP + ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) + : appId === CONSTANTS.FIRST_PARTY_APP + ? Cypress.env(CONSTANTS.FIRST_PARTY_APPID) + : appId; + let action = CONSTANTS.ACTION_CORE.toLowerCase(); + + // Splitting the method name if it contains an underscore and using the first part to determine the action that decides sdk. + if (event && event.includes('_')) { + action = event.split('_')[0]; + event = event.split('_')[1]; + } + + const additionalParams = { + method: event, + params: eventParams, + context: context, + action: action, + expected: CONSTANTS.RESULT, + appId: appId, + }; + if (appId == UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID)) { + fireLog.info( + `Registering for the ${event} event using 1st party App with params : ${JSON.stringify( + eventParams + )}` + ); + cy.sendMessageToPlatformOrApp( + CONSTANTS.PLATFORM, + additionalParams, + CONSTANTS.TASK.REGISTEREVENT + ); + } else { + fireLog.info( + `Registering for the ${event} event using ${appId} with params : ${JSON.stringify(eventParams)}` + ); + cy.sendMessageToPlatformOrApp( + CONSTANTS.APP, + additionalParams, + CONSTANTS.TASK.REGISTEREVENT + ); + } + } + }); + } else { + fireLog.assert(false, `${sdk} SDK not Supported`); + } + } +); + +/** + * @module getterSetterCalls + * @function Given '(.+)' platform responds to '([^']*)'(?: '([^']*)')? (get|set) API(?: with '(.+)')? + * @description Performing a validation against the source of truth for the given API response + * @param {String} sdk - name of the sdk. + * @param {String} appId - app identifier. + * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData Json. + * @param {String} methodType - Determines the type of method being validated Ex: set or get + * @param {String} errorContent - Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' + * @example + * And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' get API + * And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API + * And 'Firebolt' platform responds to '3rd party app' 'CLOSEDCAPTION_SETTINGS' get API + * And 'Firebolt' platform responds to '1st party app' set API + * And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API with 'INVALID_TYPE_PARAMS' + */ +Given( + /'(.+)' platform responds to '([^']*)'(?: '([^']*)')? (get|set) API(?: with '(.+)')?$/, + async (sdk, appId, fireboltCallKey, methodType, errorContent) => { + if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { + let fireboltCallObject; + // Reading the appId from the environment variable + appId = !appId + ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) + : appId === CONSTANTS.THIRD_PARTY_APP + ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) + : appId === CONSTANTS.FIRST_PARTY_APP + ? UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID) + : appId; + const context = {}; + const expectingError = errorContent ? true : false; + + // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable + if (fireboltCallKey) { + cy.getFireboltData(fireboltCallKey).then((fireboltData) => { + fireboltCallObject = fireboltData; + }); + } else { + fireboltCallObject = UTILS.getEnvVariable(CONSTANTS.RUNTIME).fireboltCall; + } + + cy.then(() => { + let method = + methodType === CONSTANTS.SET + ? UTILS.resolveRecursiveValues(fireboltCallObject.setMethod) + : UTILS.resolveRecursiveValues(fireboltCallObject.method); + + let validationJsonPath = + methodType === CONSTANTS.SET + ? UTILS.resolveRecursiveValues(fireboltCallObject.setValidationJsonPath) + : UTILS.resolveRecursiveValues(fireboltCallObject.validationJsonPath); + + let contentObject = + methodType === CONSTANTS.SET + ? UTILS.resolveRecursiveValues(fireboltCallObject.setContent) + : UTILS.resolveRecursiveValues(fireboltCallObject.content); + + method = method.includes('_') ? method.split('_')[1] : method; + contentObject = contentObject ? contentObject : CONSTANTS.NULL_RESPONSE; + validationJsonPath = validationJsonPath ? validationJsonPath : CONSTANTS.RESULT; + + if (expectingError) { + contentObject = UTILS.getEnvVariable(CONSTANTS.ERROR_CONTENT_VALIDATIONJSON)[ + errorContent + ]; + } + const additionalParams = { + method: method, + context: context, + validationJsonPath: validationJsonPath, + contentObject: contentObject, + expectingError: expectingError, + appId: appId, + }; + if (!Cypress.env(CONSTANTS.SKIPCONTENTVALIDATION)) { + cy.methodOrEventResponseValidation(CONSTANTS.METHOD, additionalParams); + } else { + cy.log( + `${CONSTANTS.SKIPCONTENTVALIDATION} flag is enabled, Skipping the Content validation` + ); + } + }); + } else { + assert(false, `${sdk} SDK not Supported`); + } + } +); + +/** + * @module getterSetterCalls + * @function Given '(.+)' platform (triggers|does not trigger) '(.*?)'(?: '(.*?)')? event(?: with '(.+)')? + * @description Performing a event validation against the source of truth + * @param {String} sdk - name of the sdk. + * @param {String} eventExpected - Determines whether the event is expected or not. + * @param {String} appId - app identifier. + * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData Json. + * @param {String} errorContent - Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' + * @example + * And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event + * And 'Firebolt' platform triggers '1st party app' event + * And 'Firebolt' platform triggers '3rd party app' 'CLOSEDCAPTION_SETTINGS' event + * And 'Firebolt' platform does not trigger '3rd party app' 'CLOSEDCAPTION_SETTINGS' event + * And 'Firebolt' platform triggers '1st party app' event + * And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event with 'INVALID_TYPE_PARAMS' + */ +Given( + /'(.+)' platform (triggers|does not trigger) '(.*?)'(?: '(.*?)')? event(?: with '(.+)')?$/, + async (sdk, eventExpected, appId, fireboltCallKey, errorContent) => { + if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { + let fireboltCallObject; + // Reading the appId from the environment variable + appId = !appId + ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) + : appId === CONSTANTS.THIRD_PARTY_APP + ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) + : appId === CONSTANTS.FIRST_PARTY_APP + ? UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID) + : appId; + const context = {}; + const expectingError = errorContent ? true : false; + + // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable + if (fireboltCallKey) { + cy.getFireboltData(fireboltCallKey).then((fireboltData) => { + fireboltCallObject = fireboltData; + }); + } else { + fireboltCallObject = UTILS.getEnvVariable(CONSTANTS.RUNTIME).fireboltCall; + } + + cy.then(() => { + let event = UTILS.resolveRecursiveValues(fireboltCallObject.event); + let eventValidationJsonPath = UTILS.resolveRecursiveValues( + fireboltCallObject.eventValidationJsonPath + ); + let contentObject = UTILS.resolveRecursiveValues(fireboltCallObject.content); + + // Extract the event name + event = event.includes('_') ? event.split('_')[1] : event; + contentObject = contentObject ? contentObject : CONSTANTS.NULL_RESPONSE; + eventValidationJsonPath = eventValidationJsonPath + ? eventValidationJsonPath + : CONSTANTS.EVENT_RESPONSE; + + if (expectingError) { + contentObject = UTILS.getEnvVariable(CONSTANTS.ERROR_CONTENT_VALIDATIONJSON)[ + errorContent + ]; + } + const additionalParams = { + method: event, + context: context, + validationJsonPath: eventValidationJsonPath, + contentObject: contentObject, + expectingError: expectingError, + appId: appId, + eventExpected: eventExpected, + }; + if (!Cypress.env(CONSTANTS.SKIPCONTENTVALIDATION)) { + cy.methodOrEventResponseValidation(CONSTANTS.EVENT, additionalParams); + } else { + cy.log( + `${CONSTANTS.SKIPCONTENTVALIDATION} flag is enabled, Skipping the Content validation` + ); + } + }); + } else { + assert(false, `${sdk} SDK not Supported`); + } + } +); diff --git a/cypress/support/step_definitions/getterSetterCalls.md b/cypress/support/step_definitions/getterSetterCalls.md new file mode 100644 index 000000000..2559b774b --- /dev/null +++ b/cypress/support/step_definitions/getterSetterCalls.md @@ -0,0 +1,132 @@ +# GetterSetterCallsGlue + +## Given 1st party app invokes the '(.+)' API (?:'(.+)' )?to set '(.+)' to( invalid)? '(.+)' + +### Purpose: Sending a message to platform to set a value + +### Params: +| Param | Definition | +| --- | --- | +| sdk | sdk name | +| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData | +| attribute | The attribute we are setting (ex. fontFamily) | +| invalidValue | Determines whether an error or result is expected. | +| value | The value used by the set method to set the value (ex. monospaced_sanserif) | + +### Examples: +* `Given 1st party app invokes the 'Firebolt' API 'CLOSEDCAPTION_SETTINGS' to set 'enable' to 'true'` +* `Given 1st party app invokes the 'Firebolt' API 'CLOSEDCAPTION_SETTINGS' to set 'enable' to invalid 'test'` +* `Given 1st party app invokes the 'Firebolt' API to set 'enable' to 'true'` + +## Given '(.+)' registers for the '(.*?)'(?: '(.*?)')? event + +### Purpose: Sending a message to platform or app to register a event + +### Params: +| Param | Definition | +| --- | --- | +| appId |app identifier | +| sdk | sdk name | +| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData | + +### Examples: + * `And '1st party app' registers for the 'Firebolt' 'CLOSEDCAPTION_SETTINGS' event` + * `And '3rd party app' registers for the 'Firebolt' 'CLOSEDCAPTION_SETTINGS' event` + * `And '1st party app' registers for the 'Firebolt' event` + +## Given '(.+)' invokes the '(.+)' get API(?: '(.+)') + +### Purpose: Sending a message to platform or 3rd party app to get a value + +### Params: +| Param | Definition | +| --- | --- | +| appId | app identifier. | +| sdk | sdk name | +| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData | + +### Examples: +* `And '1st party app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS'` +* `And '3rd party app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS'` +* `And '3rd party app' invokes the 'Firebolt' get API` +* `And 'test_app' invokes the 'Firebolt' get API 'CLOSEDCAPTION_SETTINGS'` + +## Given '(.+)' platform responds to '([^']*)'(?: '([^']*)')? (get|set) API(?: with '(.+)')? +### Purpose: Performing a validation against the source of truth for the given API response + +### Params: +| Param | Definition | +| --- | --- | +| sdk | name of the sdk | +| appId | app identifier | +| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData Json | +| methodType | Determines which method doing content validation Ex: set or get | +| errorContent | Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' | + +### Examples: + * `And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' get API` + * `And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API` + * `And 'Firebolt' platform responds to '3rd party app' 'CLOSEDCAPTION_SETTINGS' get API` + * `And 'Firebolt' platform responds to '1st party app' set API` + * `And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API with 'INVALID_TYPE_PARAMS'` + +## Given '(.+)' platform (triggers|does not trigger) '(.*?)'(?: '(.*?)')? event(?: with '(.+)')? + +### Purpose: Performing a event validation against the source of truth + +### Params: +| Param | Definition | +| --- | --- | +| sdk | sdk name | +| eventExpected | Determines whether the event is expected or not. | +| appId |app identifier | +| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData | +| errorContent | Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' | + +### Examples: + * `And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event` + * `And 'Firebolt' platform triggers '1st party app' event` + * `And 'Firebolt' platform triggers '3rd party app' 'CLOSEDCAPTION_SETTINGS' event` + * `And 'Firebolt' platform does not trigger '3rd party app' 'CLOSEDCAPTION_SETTINGS' event` + * `And 'Firebolt' platform triggers '1st party app' event` + * `And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event with 'INVALID_TYPE_PARAMS'` + +## Given '(.+)' platform responds to '([^']*)'(?: '([^']*)')? (get|set) API(?: with '(.+)')? +### Purpose: Performing a validation against the source of truth for the given API response + +### Params: +| Param | Definition | +| --- | --- | +| sdk | name of the sdk | +| appId | app identifier | +| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData Json | +| methodType | Determines which method doing content validation Ex: set or get | +| errorContent | Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' | + +### Examples: + * `And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' get API` + * `And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API` + * `And 'Firebolt' platform responds to '3rd party app' 'CLOSEDCAPTION_SETTINGS' get API` + * `And 'Firebolt' platform responds to '1st party app' set API` + * `And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API with 'INVALID_TYPE_PARAMS'` + +## '(.+)' platform (triggers|does not trigger) '(.*?)'(?: '(.*?)')? event(?: with '(.+)')? + +### Purpose: Performing a event validation against the source of truth + +### Params: +| Param | Definition | +| --- | --- | +| sdk | sdk name | +| eventExpected | Determines whether the event is expected or not. | +| appId |app identifier | +| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData | +| errorContent | Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' | + +### Examples: + * `And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event` + * `And 'Firebolt' platform triggers '1st party app' event` + * `And 'Firebolt' platform triggers '3rd party app' 'CLOSEDCAPTION_SETTINGS' event` + * `And 'Firebolt' platform does not trigger '3rd party app' 'CLOSEDCAPTION_SETTINGS' event` + * `And 'Firebolt' platform triggers '1st party app' event` + * `And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event with 'INVALID_TYPE_PARAMS'` diff --git a/cypress/support/step_definitions/validations.js b/cypress/support/step_definitions/validations.js index 557d91ba5..877149668 100644 --- a/cypress/support/step_definitions/validations.js +++ b/cypress/support/step_definitions/validations.js @@ -70,177 +70,22 @@ Given( ? UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID) : UTILS.checkForSecondaryAppId(appId); - // Fetching the object from the global list. - const methodOrEventObject = UTILS.getApiOrEventObjectFromGlobalList( - methodOrEvent, - context, - appId, - validationType - ); - const param = methodOrEventObject.params; - // Function to do error null check, schema validation check and event listerner response checks - cy.validateResponseErrorAndSchemaResult(methodOrEventObject, validationType).then(() => { - // If response of the method is not supported, checks in the not supported list for that method name, if it is present then pass else mark it as fail - if ( - !Cypress.env(CONSTANTS.SKIPCONTENTVALIDATION) && - (UTILS.isScenarioExempted(methodOrEvent, param) || expectingError) - ) { - let errorExpected; - - // If the expected error is false, we set "exceptionErrorObject" to the errorExpected variable, which will be used to retrieve the error content object based on the exception method type. - expectingError === true - ? (errorExpected = contentObject) - : (errorExpected = CONSTANTS.EXCEPTION_ERROR_OBJECT); - - cy.validateErrorObject( - methodOrEvent, - errorExpected, - validationType, - context, - appId, - param - ).then(() => { - return true; - }); - } else if (!Cypress.env(CONSTANTS.SKIPCONTENTVALIDATION)) { - // If validationType is an event then send a message to the app to retrieve an event response based on the app ID. - if (validationType == CONSTANTS.EVENT) { - const eventName = methodOrEventObject.eventObjectId; - if (appId === UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID)) { - const requestMap = { - method: CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCH_EVENT_RESPONSE, - params: eventName, - }; - - cy.sendMessagetoPlatforms(requestMap).then((result) => { - cy.updateResponseForFCS(methodOrEvent, null, result, true).then( - (updatedResponse) => { - cy.saveEventResponse( - updatedResponse, - methodOrEventObject, - eventName, - eventExpected === 'triggers' ? true : false - ); - } - ); - }); - } else { - const params = { event: eventName }; - // Generating an intent message using the provided information to send it to a third-party app - const intentMessage = UTILS.createIntentMessage( - CONSTANTS.TASK.GETEVENTRESPONSE, - params - ); - const requestTopic = UTILS.getTopic(appId); - const responseTopic = UTILS.getTopic(appId, CONSTANTS.SUBSCRIBE); - cy.sendMessagetoApp(requestTopic, responseTopic, intentMessage).then( - (response) => { - response = JSON.parse(response); - if ( - response && - response.result && - response.result.hasOwnProperty(CONSTANTS.EVENT_RESPONSE) - ) { - response.result = response.result.eventResponse; - } - cy.updateResponseForFCS(methodOrEvent, null, response, true).then( - (updatedResponse) => { - cy.saveEventResponse( - updatedResponse, - methodOrEventObject, - eventName, - eventExpected === 'triggers' ? true : false - ); - } - ); - } - ); - } - } - - try { - if (contentObject && contentObject.data) { - contentObject.data.forEach((object) => { - if (object.validations) { - const scenario = object.type; - const methodOrEventResponse = - validationType == CONSTANTS.EVENT - ? methodOrEventObject.eventResponse - : validationType == CONSTANTS.METHOD - ? methodOrEventObject.apiResponse - : null; - switch (scenario) { - case CONSTANTS.REGEX: - cy.regExValidation( - methodOrEvent, - object.validations[0].type, - validationJsonPath, - methodOrEventResponse - ); - break; - case CONSTANTS.MISC: - cy.miscellaneousValidation( - methodOrEvent, - object.validations[0], - methodOrEventObject - ); - break; - case CONSTANTS.DECODE: - const decodeType = object.specialCase; - const responseForDecodeValidation = - validationType == CONSTANTS.EVENT - ? methodOrEventResponse - : validationType == CONSTANTS.METHOD - ? methodOrEventResponse.result - : null; - - cy.decodeValidation( - methodOrEvent, - decodeType, - responseForDecodeValidation, - object.validations[0], - null - ); - break; - case CONSTANTS.FIXTURE: - cy.validateContent( - methodOrEvent, - context, - validationJsonPath, - object.validations[0].type, - validationType, - appId - ); - break; - case CONSTANTS.CUSTOM: - cy.customValidation(object, methodOrEventObject); - break; - case CONSTANTS.UNDEFINED: - cy.undefinedValidation(object, methodOrEventObject, validationType); - break; - default: - assert(false, 'Unsupported validation type'); - break; - } - } - }); - } else { - cy.validateContent( - methodOrEvent, - context, - validationJsonPath, - contentObject, - validationType, - appId - ); - } - } catch (error) { - assert(false, `Unable to validate the response: ${error}`); - } - } else { - cy.log('Content validation is skipped'); - } - }); + const additionalParams = { + method: methodOrEvent, + context: context, + validationJsonPath: validationJsonPath, + contentObject: contentObject, + expectingError: expectingError, + appId: appId, + eventExpected: eventExpected, + }; + if (!Cypress.env(CONSTANTS.SKIPCONTENTVALIDATION)) { + cy.methodOrEventResponseValidation(validationType, additionalParams); + } else { + cy.log( + `${CONSTANTS.SKIPCONTENTVALIDATION} flag is enabled, Skipping the Content validation` + ); + } }); }); } else { @@ -432,454 +277,3 @@ Given( }); } ); - -/** - * @module validations - * @function And '(.+)' platform responds to '([^']*)'(?: '([^']*)')? (get|set) API(?: with '(.+)')? - * @description Performing a validation against the source of truth for the given API response - * @param {String} sdk - name of the sdk. - * @param {String} appId - The object was retrieved by using the appId. - * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData Json. - * @param {String} methodType - Determines which method doing content validation Ex: set or get - * @param {String} errorContent - Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' - * @example - * And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' get API - * And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API - * And 'Firebolt' platform responds to '3rd party app' 'CLOSEDCAPTION_SETTINGS' get API - * And 'Firebolt' platform responds to '1st party app' set API - * And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API with 'INVALID_TYPE_PARAMS' - */ -Given( - /'(.+)' platform responds to '([^']*)'(?: '([^']*)')? (get|set) API(?: with '(.+)')?$/, - async (sdk, appId, fireboltCallKey, methodType, errorContent) => { - if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { - let fireboltCallObject; - // Reading the appId from the environment variable - appId = !appId - ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) - : appId === CONSTANTS.THIRD_PARTY_APP - ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) - : appId === CONSTANTS.FIRST_PARTY_APP - ? UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID) - : appId; - const context = {}; - const expectingError = errorContent ? true : false; - - // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable - if (fireboltCallKey) { - cy.getFireboltData(fireboltCallKey).then((fireboltData) => { - fireboltCallObject = fireboltData; - }); - } else { - fireboltCallObject = UTILS.getEnvVariable('runtime').fireboltCall; - } - - cy.then(() => { - let method = - methodType === CONSTANTS.SET - ? typeof fireboltCallObject.setMethod == CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.setMethod() - : fireboltCallObject.setMethod - : typeof fireboltCallObject.method == CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.method() - : fireboltCallObject.method; - let validationJsonPath = - methodType === CONSTANTS.SET - ? typeof fireboltCallObject.setValidationJsonPath == CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.setValidationJsonPath() - : fireboltCallObject.setValidationJsonPath - : typeof fireboltCallObject.validationJsonPath == CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.validationJsonPath() - : fireboltCallObject.validationJsonPath; - let contentObject = - methodType === CONSTANTS.SET - ? resolveContentObject(fireboltCallObject.setContent) - : resolveContentObject(fireboltCallObject.content); - - method = method.includes('_') ? method.split('_')[1] : method; - contentObject = contentObject ? contentObject : CONSTANTS.NULL_RESPONSE; - validationJsonPath = validationJsonPath ? validationJsonPath : CONSTANTS.RESULT; - - // Fetching the object from the global list. - const apiObject = UTILS.getApiOrEventObjectFromGlobalList(method, context, appId); - const param = apiObject.params; - - // Function to do error null check, schema validation check and event listerner response checks - cy.validateResponseErrorAndSchemaResult(apiObject, CONSTANTS.METHOD).then(() => { - // If response of the method is not supported, checks in the not supported list for that method name, if it is present then pass else mark it as fail - if ( - !Cypress.env(CONSTANTS.SKIPCONTENTVALIDATION) && - (UTILS.isScenarioExempted(method, param) || expectingError) - ) { - let errorExpected; - - // If the expected error is false, we set "exceptionErrorObject" to the errorExpected variable, which will be used to retrieve the error content object based on the exception method type. - expectingError === true - ? (errorExpected = UTILS.getEnvVariable('errorContentValidationJson')[errorContent]) - : (errorExpected = CONSTANTS.EXCEPTION_ERROR_OBJECT); - - cy.validateErrorObject( - method, - errorExpected, - CONSTANTS.METHOD, - context, - appId, - param - ).then(() => { - return true; - }); - } else if (!Cypress.env(CONSTANTS.SKIPCONTENTVALIDATION)) { - try { - if (contentObject && contentObject.data) { - contentObject.data.forEach((object) => { - if (object.validations) { - const scenario = object.type; - const methodResponse = apiObject?.response ? apiObject.response : null; - - // Looping through validationJsonPath to find the valid path for validation. - if (validationJsonPath && Array.isArray(validationJsonPath)) { - const validationPath = validationJsonPath.find((path) => { - if ( - path - .split('.') - .reduce((acc, part) => acc && acc[part], methodResponse) !== undefined - ) { - return path; - } - }); - validationPath - ? (validationJsonPath = validationPath) - : fireLog.assert( - false, - 'Could not find the valid validation path from the validationJsonPath list' - ); - } - - switch (scenario) { - case CONSTANTS.REGEX: - cy.regExValidation( - method, - object.validations[0].type, - validationJsonPath, - methodResponse - ); - break; - case CONSTANTS.MISC: - cy.miscellaneousValidation(method, object.validations[0], apiObject); - break; - case CONSTANTS.DECODE: - const decodeType = object.specialCase; - const responseForDecodeValidation = methodResponse?.result - ? methodResponse.result - : null; - - cy.decodeValidation( - method, - decodeType, - responseForDecodeValidation, - object.validations[0], - null - ); - break; - case CONSTANTS.FIXTURE: - cy.validateContent( - method, - context, - validationJsonPath, - object.validations[0].type, - CONSTANTS.METHOD, - appId - ); - break; - case CONSTANTS.CUSTOM: - cy.customValidation(object, apiObject); - break; - case CONSTANTS.UNDEFINED: - cy.undefinedValidation(object, apiObject, CONSTANTS.METHOD); - break; - default: - assert(false, 'Unsupported validation type'); - break; - } - } - }); - } else { - cy.validateContent( - method, - context, - validationJsonPath, - contentObject, - CONSTANTS.METHOD, - appId - ); - } - } catch (error) { - assert(false, `Unable to validate the response: ${error}`); - } - } else { - cy.log('Content validation is skipped'); - } - }); - }); - } else { - assert(false, `${sdk} SDK not Supported`); - } - - // A Function that recursively check each fields and invokes if it's a function within an array or object. - function resolveContentObject(input) { - if (Array.isArray(input)) { - return input.map((item) => resolveContentObject(item)); - } else if (typeof input == CONSTANTS.TYPE_OBJECT && input !== null) { - for (const key in input) { - if (Object.hasOwnProperty.call(input, key)) { - input[key] = resolveContentObject(input[key]); - } - } - return input; - } else if (input && typeof input === CONSTANTS.TYPE_FUNCTION) { - return input(); - } else { - return input; - } - } - } -); - -/** - * @module validations - * @function And '(.+)' platform (triggers|does not trigger) '(.*?)'(?: '(.*?)')? event(?: with '(.+)')? - * @description Performing a event validation against the source of truth - * @param {String} sdk - name of the sdk. - * @param {String} eventExpected - eventExpected will used to decide expecting for an event or not. - * @param {String} appId - The object was retrieved by using the appId. - * @param {String} fireboltCallKey - key name passed to look for firebolt call object in fireboltCallData Json. - * @param {String} errorContent - Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' - * @example - * And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event - * And 'Firebolt' platform triggers '1st party app' event - * And 'Firebolt' platform triggers '3rd party app' 'CLOSEDCAPTION_SETTINGS' event - * And 'Firebolt' platform does not trigger '3rd party app' 'CLOSEDCAPTION_SETTINGS' event - * And 'Firebolt' platform triggers '1st party app' event - * And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event with 'INVALID_TYPE_PARAMS' - */ -Given( - /'(.+)' platform (triggers|does not trigger) '(.*?)'(?: '(.*?)')? event(?: with '(.+)')?$/, - async (sdk, eventExpected, appId, fireboltCallKey, errorContent) => { - if (CONSTANTS.SUPPORTED_SDK.includes(sdk)) { - let fireboltCallObject; - // Reading the appId from the environment variable - appId = !appId - ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) - : appId === CONSTANTS.THIRD_PARTY_APP - ? UTILS.getEnvVariable(CONSTANTS.THIRD_PARTY_APP_ID) - : appId === CONSTANTS.FIRST_PARTY_APP - ? UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID) - : appId; - const context = {}; - const expectingError = errorContent ? true : false; - - // When fireboltCall object key passed fetching the object from the fireboltCalls data else reading it from environment variable - if (fireboltCallKey) { - cy.getFireboltData(fireboltCallKey).then((fireboltData) => { - fireboltCallObject = fireboltData; - }); - } else { - fireboltCallObject = UTILS.getEnvVariable('runtime').fireboltCall; - } - - cy.then(() => { - let event = - typeof fireboltCallObject.event == CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.event() - : fireboltCallObject.event; - let eventValidationJsonPath = - typeof fireboltCallObject.eventValidationJsonPath == CONSTANTS.TYPE_FUNCTION - ? fireboltCallObject.eventValidationJsonPath() - : fireboltCallObject.eventValidationJsonPath; - let contentObject = resolveContentObject(fireboltCallObject.content); - - event = event.includes('_') ? event.split('_')[1] : event; - contentObject = contentObject ? contentObject : CONSTANTS.NULL_RESPONSE; - eventValidationJsonPath = eventValidationJsonPath - ? eventValidationJsonPath - : CONSTANTS.EVENT_RESPONSE; - - // Fetching the object from the global list. - const eventObject = UTILS.getApiOrEventObjectFromGlobalList( - event, - context, - appId, - CONSTANTS.EVENT - ); - const param = eventObject.params; - - // If response of the event is not supported, checks in the not supported list for that event name, if it is present then pass else mark it as fail - if ( - !Cypress.env(CONSTANTS.SKIPCONTENTVALIDATION) && - (UTILS.isScenarioExempted(event, param) || expectingError) - ) { - let errorExpected; - - // If the expected error is false, we set "exceptionErrorObject" to the errorExpected variable, which will be used to retrieve the error content object based on the exception event type. - expectingError === true - ? (errorExpected = UTILS.getEnvVariable('errorContentValidationJson')[errorContent]) - : (errorExpected = CONSTANTS.EXCEPTION_ERROR_OBJECT); - - cy.validateErrorObject(event, errorExpected, CONSTANTS.EVENT, context, appId, param).then( - () => { - return true; - } - ); - } else if (!Cypress.env(CONSTANTS.SKIPCONTENTVALIDATION)) { - // If validationType is an event then send a message to the app to retrieve an event response based on the app ID. - const eventName = eventObject.eventObjectId; - if (appId === UTILS.getEnvVariable(CONSTANTS.FIRST_PARTY_APPID)) { - const requestMap = { - method: CONSTANTS.REQUEST_OVERRIDE_CALLS.FETCH_EVENT_RESPONSE, - params: eventName, - }; - - cy.sendMessagetoPlatforms(requestMap).then((result) => { - cy.updateResponseForFCS(event, null, result).then((updatedResponse) => { - cy.saveEventResponse( - updatedResponse, - eventObject, - eventName, - eventExpected === 'triggers' ? true : false - ); - }); - }); - } else { - const params = { event: eventName }; - // Generating an intent message using the provided information to send it to a third-party app - const intentMessage = UTILS.createIntentMessage( - CONSTANTS.TASK.GETEVENTRESPONSE, - params - ); - const requestTopic = UTILS.getTopic(appId); - const responseTopic = UTILS.getTopic(appId, CONSTANTS.SUBSCRIBE); - cy.sendMessagetoApp(requestTopic, responseTopic, intentMessage).then((response) => { - response = JSON.parse(response); - response = response.report; - cy.saveEventResponse( - response, - eventObject, - eventName, - eventExpected === 'triggers' ? true : false - ); - }); - } - - try { - if (contentObject && contentObject.data) { - contentObject.data.forEach((object) => { - if (object.validations) { - const scenario = object.type; - const eventResponse = eventObject?.eventResponse - ? eventObject.eventResponse - : null; - - // Looping through eventValidationJsonPath to find the valid path for validation. - if (eventValidationJsonPath && Array.isArray(eventValidationJsonPath)) { - const validationPath = eventValidationJsonPath.find((path) => { - if ( - path.split('.').reduce((acc, part) => acc && acc[part], eventResponse) !== - undefined - ) { - return path; - } - }); - validationPath - ? (eventValidationJsonPath = validationPath) - : fireLog.assert( - false, - 'Could not find the valid validation path from the eventValidationJsonPath list' - ); - } - - switch (scenario) { - case CONSTANTS.REGEX: - cy.regExValidation( - event, - object.validations[0].type, - eventValidationJsonPath, - eventResponse - ); - break; - case CONSTANTS.MISC: - cy.miscellaneousValidation(event, object.validations[0], eventObject); - break; - case CONSTANTS.DECODE: - const decodeType = object.specialCase; - const responseForDecodeValidation = eventResponse; - - cy.decodeValidation( - event, - decodeType, - responseForDecodeValidation, - object.validations[0], - null - ); - break; - case CONSTANTS.FIXTURE: - cy.validateContent( - event, - context, - eventValidationJsonPath, - object.validations[0].type, - CONSTANTS.EVENT, - appId - ); - break; - case CONSTANTS.CUSTOM: - cy.customValidation(object, eventObject); - break; - case CONSTANTS.UNDEFINED: - cy.undefinedValidation(object, eventObject, CONSTANTS.EVENT); - break; - default: - assert(false, 'Unsupported validation type'); - break; - } - } - }); - } else { - cy.validateContent( - event, - context, - eventValidationJsonPath, - contentObject, - CONSTANTS.EVENT, - appId - ); - } - } catch (error) { - assert(false, `Unable to validate the response: ${error}`); - } - } else { - cy.log('Content validation is skipped'); - } - }); - } else { - assert(false, `${sdk} SDK not Supported`); - } - - // A Function that recursively check each fields and invokes if it's a function within an array or object. - function resolveContentObject(input) { - if (Array.isArray(input)) { - return input.map((item) => resolveContentObject(item)); - } else if (typeof input == CONSTANTS.TYPE_OBJECT && input !== null) { - for (const key in input) { - if (Object.hasOwnProperty.call(input, key)) { - input[key] = resolveContentObject(input[key]); - } - } - return input; - } else if (input && typeof input === CONSTANTS.TYPE_FUNCTION) { - return input(); - } else { - return input; - } - } - } -); diff --git a/cypress/support/step_definitions/validations.md b/cypress/support/step_definitions/validations.md index 6cad013a3..ad0ebf12f 100644 --- a/cypress/support/step_definitions/validations.md +++ b/cypress/support/step_definitions/validations.md @@ -412,43 +412,3 @@ While validating, if a key is present in both fcs-validation jsons (eg: cypress/ } ] } - -## '(.+)' platform responds to '([^']*)'(?: '([^']*)')? (get|set) API(?: with '(.+)')? -### Purpose: Performing a validation against the source of truth for the given API response - -### Params: -| Param | Definition | -| --- | --- | -| sdk | name of the sdk | -| appId | The object was retrieved by using the appId | -| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData Json | -| methodType | Determines which method doing content validation Ex: set or get | -| errorContent | Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' | - -### Examples: - * `And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' get API` - * `And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API` - * `And 'Firebolt' platform responds to '3rd party app' 'CLOSEDCAPTION_SETTINGS' get API` - * `And 'Firebolt' platform responds to '1st party app' set API` - * `And 'Firebolt' platform responds to '1st party app' 'CLOSEDCAPTION_SETTINGS' set API with 'INVALID_TYPE_PARAMS'` - -## '(.+)' platform (triggers|does not trigger) '(.*?)'(?: '(.*?)')? event(?: with '(.+)')? - -### Purpose: Performing a event validation against the source of truth - -### Params: -| Param | Definition | -| --- | --- | -| sdk | sdk name | -| eventExpected | eventExpected will used to decide expecting for an event or not. | -| appId |app identtifier | -| fireboltCallKey | key name passed to look for firebolt call object in fireboltCallData | -| errorContent | Doing error content validation when error content object key passed. Ex: 'INVALID_TYPE_PARAMS' | - -### Examples: - * `And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event` - * `And 'Firebolt' platform triggers '1st party app' event` - * `And 'Firebolt' platform triggers '3rd party app' 'CLOSEDCAPTION_SETTINGS' event` - * `And 'Firebolt' platform does not trigger '3rd party app' 'CLOSEDCAPTION_SETTINGS' event` - * `And 'Firebolt' platform triggers '1st party app' event` - * `And 'Firebolt' platform triggers '1st party app' 'CLOSEDCAPTION_SETTINGS' event with 'INVALID_TYPE_PARAMS'` diff --git a/cypress/support/validations/schemaValidation.js b/cypress/support/validations/schemaValidation.js index 01dabbbd3..ee16dabd5 100644 --- a/cypress/support/validations/schemaValidation.js +++ b/cypress/support/validations/schemaValidation.js @@ -68,14 +68,14 @@ Cypress.Commands.add( if (response.hasOwnProperty(CONSTANTS.RESULT)) { if ( response && - response.result && + response.result != undefined && response.result.hasOwnProperty(CONSTANTS.EVENT_LISTENER_RESPONSE) ) { formattedResponse = Object.assign(formattedResponse, response.result); formattedResponse.eventListenerSchemaResult = formattedSchemaValidationResult; } else if ( response && - response.result && + response.result != undefined && !response.result.hasOwnProperty(CONSTANTS.EVENT_LISTENER_RESPONSE) ) { formattedResponse.eventResponse = response.result; @@ -85,7 +85,7 @@ Cypress.Commands.add( } else if (response.hasOwnProperty(CONSTANTS.ERROR)) { if ( response && - response.result && + response.result != undefined && response.result.hasOwnProperty(CONSTANTS.EVENT_LISTENER_RESPONSE) ) { formattedResponse = Object.assign(formattedResponse, response.error);