<?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">
    <actionGroup name="AdminInsertRecentlyViewedWidgetActionGroup">
        <arguments>
            <argument name="attributeSelector1" type="string"  defaultValue="show_attributes"/>
            <argument name="attributeSelector2" type="string" defaultValue="show_buttons"/>
            <argument name="productAttributeSection1" type="string"  defaultValue="1"/>
            <argument name="productAttributeSection2" type="string" defaultValue="4" />
            <argument name="buttonToShowSection2" type="string" defaultValue="3" />
        </arguments>

        <conditionalClick selector="{{CmsNewPagePageActionsSection.contentSectionName}}" dependentSelector="{{CmsNewPagePageActionsSection.showHideEditor}}" visible="false" stepKey="expandContentSectionIfNotVisible"/>
        <waitForPageLoad time="30" stepKey="waitForPageLoadContentSection"/>
        <conditionalClick selector="{{CmsNewPagePageActionsSection.showHideEditor}}" dependentSelector="{{CatalogWidgetSection.insertWidgetButton}}" visible="false" stepKey="clickNextShowHideEditorIfVisible"/>
        <waitForElementVisible selector="{{CatalogWidgetSection.insertWidgetButton}}" stepKey="waitForInsertWidgetElement"/>
        <click selector="{{CatalogWidgetSection.insertWidgetButton}}" stepKey="clickInsertWidget"/>
        <waitForElementVisible selector="{{InsertWidgetSection.widgetTypeDropDown}}" time="30" stepKey="waitForWidgetTypeDropDownVisible"/>
        <!--Select "Widget Type"-->
        <selectOption selector="{{WidgetSection.WidgetType}}" userInput="Recently Viewed Products" stepKey="selectRecentlyViewedProducts"/>
        <waitForPageLoad time="30" stepKey="waitForPageLoadWidgetType"/>
        <!--Select all product attributes-->
        <dragAndDrop selector1="{{AdminRecentlyViewedWidgetSection.attributeSelector(attributeSelector1,productAttributeSection1)}}" selector2="{{AdminRecentlyViewedWidgetSection.attributeSelector(attributeSelector1,productAttributeSection2)}}" stepKey="selectProductSpecifiedOptions"/>
        <!--Select all buttons to show-->
        <dragAndDrop selector1="{{AdminRecentlyViewedWidgetSection.attributeSelector(attributeSelector2,buttonToShowSection2)}}"  selector2="{{AdminRecentlyViewedWidgetSection.attributeSelector(attributeSelector2,buttonToShowSection2)}}" stepKey="selectButtonSpecifiedOptions"/>
        <click selector="{{WidgetSection.InsertWidget}}" stepKey="clickInsertWidgetToSave"/>
        <waitForPageLoad time="30" stepKey="waitForWidgetInsertPageLoad"/>
        <!-- Check that widget is inserted -->
        <waitForElementVisible selector="{{CmsNewPagePageContentSection.content}}" stepKey="checkCMSContent" time="30"/>
        <click selector="{{CmsNewPagePageActionsSection.saveAndContinueEdit}}" stepKey="clickNextSave"/>
        <waitForPageLoad stepKey="waitForPageActionSave" time="30"/>
        <waitForElementVisible selector="*[data-ui-id='messages-message-success']" time="60" stepKey="waitForSaveSuccess"/>
    </actionGroup>
</actionGroups>
