<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  */
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
    <!-- Assert the navigation arrows on Storefront Product page -->
    <actionGroup name="AssertProductVideoNavigationArrowsActionGroup">
        <annotations>
            <description>Validates the navigation arrows on the Storefront Product page.</description>
        </annotations>
        <arguments>
            <argument name="videoType" type="string" defaultValue="vimeo"/>
        </arguments>

        <dontSeeElement selector="{{StorefrontProductMediaSection.imagePrevButton}}" stepKey="dontSeePrevButton"/>
        <moveMouseOver selector="{{StorefrontProductInfoMainSection.clickPlayVideo}}" stepKey="hoverOverImage"/>
        <waitForElementVisible selector="{{StorefrontProductMediaSection.imageNextButton}}" stepKey="seeNextButton"/>
        <click selector="{{StorefrontProductMediaSection.imageNextButton}}" stepKey="clickNextButton"/>
        <waitForElementVisible selector="{{StorefrontProductInfoMainSection.productVideo(videoType)}}" stepKey="seeProductVideoDataType"/>

        <dontSeeElement selector="{{StorefrontProductInfoMainSection.clickCloseVideo}}" stepKey="dontSeeCloseVideo"/>

        <click selector="{{StorefrontProductInfoMainSection.clickPlayVideo}}" stepKey="clickToPlayVideo"/>
        <wait time="5" stepKey="waitFiveSecondsToPlayVideo"/>

        <dontSeeElement selector="{{StorefrontProductMediaSection.imagePrevButton}}" stepKey="dontSeePrevButtonSecond"/>
        <dontSeeElement selector="{{StorefrontProductMediaSection.imageNextButton}}" stepKey="dontSeeNextButton"/>

        <seeElement selector="{{StorefrontProductInfoMainSection.clickCloseVideo}}" stepKey="seeCloseVideo"/>
        <click selector="{{StorefrontProductInfoMainSection.clickCloseVideo}}" stepKey="clickToCloseVideo"/>
        <wait time="2" stepKey="waitTwoSecondsToCloseVideo"/>
        <dontSeeElementInDOM selector="{{StorefrontProductMediaSection.galleryNoControlsElement}}" stepKey="videoFocused"/>
        <moveMouseOver selector="{{StorefrontCMSPageSection.mainTitle}}" stepKey="unFocusVideo"/>
        <waitForElement selector="{{StorefrontProductMediaSection.galleryNoControlsElement}}" stepKey="waitForVideoUnFocus"/>

        <moveMouseOver selector="{{StorefrontProductInfoMainSection.clickPlayVideo}}" stepKey="hoverOverImageSecond"/>
        <waitForElementVisible selector="{{StorefrontProductMediaSection.imagePrevButton}}" stepKey="seePrevButton"/>
        <click selector="{{StorefrontProductMediaSection.imagePrevButton}}" stepKey="clickPrevButton"/>
    </actionGroup>
</actionGroups>
