<?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="NavigateToDefaultLayoutsSetting">
        <amOnPage url="{{WebConfigurationPage.url}}" stepKey="navigateToWebConfigurationPage"/>
        <waitForPageLoad stepKey="waitForPageLoad"/>
        <conditionalClick stepKey="expandDefaultLayouts" selector="{{WebSection.DefaultLayoutsTab}}" dependentSelector="{{WebSection.CheckIfTabExpand}}" visible="true" />
        <waitForElementVisible selector="{{DefaultLayoutsSection.categoryLayout}}" stepKey="waittForDefaultCategoryLayout" />
    </actionGroup>

    <actionGroup name="NavigateToConfigurationGeneralPage">
        <amOnPage url="{{AdminConfigGeneralPage.url}}" stepKey="navigateToConfigGeneralPage"/>
        <waitForPageLoad stepKey="waitForConfigPageLoad"/>
    </actionGroup>

    <actionGroup name="SelectTopDestinationsCountry">
        <arguments>
            <argument name="countries" type="entity"/>
        </arguments>
        <selectOption selector="{{CountryOptionsSection.topDestinations}}" parameterArray="[{{countries.country}}]" stepKey="selectTopDestinationsCountry"/>
        <click selector="#save" stepKey="saveConfig"/>
        <waitForPageLoad stepKey="waitForSavingConfig"/>
    </actionGroup>

    <actionGroup name="UnSelectTopDestinationsCountry">
        <arguments>
            <argument name="countries" type="entity"/>
        </arguments>
        <unselectOption selector="{{CountryOptionsSection.topDestinations}}" parameterArray="[{{countries.country}}]" stepKey="unSelectTopDestinationsCountry"/>
        <click selector="#save" stepKey="saveConfig"/>
        <waitForPageLoad stepKey="waitForSavingConfig"/>
    </actionGroup>

    <actionGroup name="SelectCountriesWithRequiredRegion">
        <arguments>
            <argument name="countries" type="entity"/>
        </arguments>
        <amOnPage url="{{AdminConfigGeneralPage.url}}" stepKey="navigateToAdminConfigGeneralPage"/>
        <conditionalClick selector="{{StateOptionsSection.stateOptions}}" dependentSelector="{{StateOptionsSection.countriesWithRequiredRegions}}" visible="false" stepKey="expandStateOptionsTab" />
        <waitForAjaxLoad stepKey="waitForAjax"/>
        <scrollTo selector="{{StateOptionsSection.countriesWithRequiredRegions}}" stepKey="scrollToForm"/>
        <selectOption selector="{{StateOptionsSection.countriesWithRequiredRegions}}" parameterArray="[{{countries.country}}]" stepKey="selectCountriesWithRequiredRegion"/>
        <click selector="#save" stepKey="saveConfig"/>
        <waitForPageLoad stepKey="waitForSavingConfig"/>
    </actionGroup>
</actionGroups>
