<?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="ChangeShippingTaxClassActionGroup">
        <annotations>
            <description>Goes to the 'Configuration' page for 'Tax'. Sets the 'Tax Class for Shipping' configuration setting to 'Taxable Goods'. Clicks on Save. Validates that the Success Message is present and correct.</description>
        </annotations>

        <!--Select Configuration menu from Store-->
        <click selector="{{AdminMenuSection.stores}}" stepKey="clickOnSTORES"/>
        <waitForPageLoad stepKey="waitForConfiguration"/>
        <click selector="{{AdminMenuSection.configuration}}" stepKey="clickOnConfigurations"/>
        <waitForPageLoad stepKey="waitForSales"/>

        <!--Double click the same to fix flaky issue with redirection to Dashboard-->
        <click selector="{{AdminMenuSection.stores}}" stepKey="clickOnSTORES1"/>
        <waitForPageLoad stepKey="waitForConfiguration1"/>
        <click selector="{{AdminMenuSection.configuration}}" stepKey="clickOnConfigurations1"/>
        <waitForPageLoad stepKey="waitForSales1" time="5"/>

        <!--Change default tax class for Shipping on Taxable Goods-->
        <click selector="{{ConfigurationListSection.sales}}" stepKey="clickOnSales"/>
        <waitForPageLoad stepKey="waitForPaymentMethods"/>
        <click selector="{{AdminConfigureTaxSection.salesTax}}" stepKey="clickOnTax"/>
        <waitForPageLoad stepKey="waitForTax"/>
        <seeInCurrentUrl url="{{AdminTaxConfigurationPage.url}}" stepKey="adminTaxConfiguration"/>
        <seeElement selector="{{AdminConfigureTaxSection.taxClasses}}" stepKey="taxClassSectionC"/>
        <click selector="{{AdminConfigureTaxSection.taxClasses}}" stepKey="openTaxClassSection"/>
        <click selector="{{AdminConfigureTaxSection.taxShippingClassSystem}}" stepKey="uncheckSystemValue"/>
        <selectOption selector="{{AdminConfigureTaxSection.taxClassShipping}}" userInput="Taxable Goods" stepKey="setTaxClassForShipping"/>

        <!-- Save the settings -->
        <scrollToTopOfPage stepKey="scrollToTop"/>
        <click stepKey="saveTaxOptions" selector="{{AdminCategoryMainActionsSection.SaveButton}}"/>
        <waitForPageLoad stepKey="waitForTaxSaved"/>
        <see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the configuration."/>
    </actionGroup>
</actionGroups>
