<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  */
-->
<!-- Test XML Example -->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">

    <actionGroup name="AdminCreateStoreViewActionGroup">
        <arguments>
            <argument name="StoreGroup" defaultValue="_defaultStoreGroup"/>
            <argument name="customStore" defaultValue="customStore"/>
        </arguments>
        <amOnPage url="{{AdminSystemStoreViewPage.url}}" stepKey="navigateToNewStoreView"/>
        <waitForPageLoad stepKey="waitForPageLoad1" />
        <comment userInput="Creating Store View" stepKey="storeViewCreationComment" />
        <!--Create Store View-->
        <selectOption selector="{{AdminNewStoreSection.storeGrpDropdown}}" userInput="{{StoreGroup.name}}" stepKey="selectStore" />
        <fillField selector="{{AdminNewStoreSection.storeNameTextField}}" userInput="{{customStore.name}}" stepKey="enterStoreViewName" />
        <fillField selector="{{AdminNewStoreSection.storeCodeTextField}}" userInput="{{customStore.code}}" stepKey="enterStoreViewCode" />
        <selectOption selector="{{AdminNewStoreSection.statusDropdown}}" userInput="Enabled" stepKey="setStatus" />
        <click selector="{{AdminNewStoreViewActionsSection.saveButton}}" stepKey="clickSaveStoreView" />
        <waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForModal" />
        <see selector="{{AdminConfirmationModalSection.title}}" userInput="Warning message" stepKey="seeWarningAboutTakingALongTimeToComplete" />
        <click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmModal" />
        <waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="waitForPageReload"/>
        <see selector="{{AdminMessagesSection.success}}" userInput="You saved the store view." stepKey="seeSavedMessage" />
    </actionGroup>

    <actionGroup name="AdminCreateStoreViewWithoutCheckActionGroup" extends="AdminCreateStoreViewActionGroup">
        <remove keyForRemoval="waitForPageReload"/>
        <remove keyForRemoval="seeSavedMessage"/>
    </actionGroup>

    <!--Save the Store view-->
    <actionGroup name="AdminCreateStoreViewActionSaveGroup">
        <waitForLoadingMaskToDisappear stepKey="waitForGridLoad"/>
        <waitForElementVisible selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="waitForStoreGridToReload2"/>
        <see userInput="You saved the store view." stepKey="seeSavedMessage" />
    </actionGroup>

    <actionGroup name="navigateToAdminContentManagementPage">
        <amOnPage url="{{AdminContentManagementPage.url}}" stepKey="navigateToConfigurationPage"/>
        <waitForPageLoad stepKey="waitForPageLoad1"/>
    </actionGroup>
    <actionGroup name="saveStoreConfiguration">
        <comment userInput="saveStoreConfiguration" stepKey="comment"/>
        <waitForElementVisible selector="{{StoreConfigSection.Save}}" stepKey="waitForSaveButton"/>
        <click selector="{{StoreConfigSection.Save}}" stepKey="clickSaveButton"/>
        <waitForPageLoad stepKey="waitForPageLoad"/>
    </actionGroup>
    <actionGroup name="saveStoreConfigurationAndValidateFieldError">
        <arguments>
            <argument name="inputFieldError" type="string"/>
            <argument name="errorMessageSelector" type="string"/>
            <argument name="errorMessage" type="string"/>
        </arguments>
        <comment userInput="saveStoreConfigurationAndValidateFieldError" stepKey="comment"/>
        <waitForElementVisible selector="{{StoreConfigSection.Save}}" stepKey="waitForSaveButton"/>
        <click selector="{{StoreConfigSection.Save}}" stepKey="clickSaveButton"/>
        <waitForElement selector="{{inputFieldError}}" stepKey="waitForErrorField"/>
        <waitForElementVisible selector="{{errorMessageSelector}}" stepKey="waitForErrorMessage"/>
        <see selector="{{errorMessageSelector}}" userInput="{{errorMessage}}" stepKey="seeErrorMessage"/>
    </actionGroup>
</actionGroups>
