<?xml version="1.0" encoding="UTF-8"?>
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
    <actionGroup name="FillGuestCustomerShippingDetailsActionGroup">
        <annotations>
            <description>Fills in the provided Customer/Address (Including Region) details on the Storefront Checkout page under the 'Shipping Address' section. Selects the provided Shipping Method. Clicks on Next. Validates that the URL is present and correct.</description>
        </annotations>
        <arguments>
            <argument name="customerVar" defaultValue="SimpleGermanyCustomer"/>
            <argument name="customerAddressVar" defaultValue="Germany_Address"/>
            <!--First available shipping method will be selected if value is not passed for shippingMethod-->
            <argument name="shippingMethod" defaultValue="" type="string"/>
        </arguments>

        <!-- Wait for element CheckoutShippingSection.email to appear -->
        <helper class="StripeIntegration\Tax\Test\Mftf\Helper\StripeHelper" method="waitForEmailField" stepKey="waitForEmailFieldToAppear">
            <argument name="selector">{{CheckoutShippingSection.email}}</argument>
        </helper>

        <fillField selector="{{CheckoutShippingSection.email}}" userInput="{{customerVar.email}}" stepKey="enterEmail"/>

        <waitForElementVisible selector="{{CheckoutShippingSection.firstName}}" stepKey="waitForFirstNameFieldVisible" time="60"/>
        <fillField selector="{{CheckoutShippingSection.firstName}}" userInput="{{customerVar.firstname}}" stepKey="enterFirstName"/>
        <fillField selector="{{CheckoutShippingSection.lastName}}" userInput="{{customerVar.lastname}}" stepKey="enterLastName"/>
        <fillField selector="{{CheckoutShippingSection.street}}" userInput="{{customerAddressVar.street[0]}}" stepKey="enterStreet"/>
        <selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{customerAddressVar.country}}" stepKey="enterCountry"/>
        <fillField selector="{{CheckoutShippingSection.city}}" userInput="{{customerAddressVar.city}}" stepKey="enterCity"/>
        <selectOption selector="{{CheckoutShippingSection.region}}" userInput="{{customerAddressVar.state}}" stepKey="selectRegion"/>
        <fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/>
        <fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
        <wait time="2" stepKey="waitForShippingLoadingMaskToAppear" />
        <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
        <waitForElement selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName('shippingMethod')}}" stepKey="waitForShippingMethod"/>
        <click selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName('shippingMethod')}}" stepKey="selectShippingMethod"/>
        <waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>

        <click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>

        <dontSeeJsError stepKey="assertNoJsErrors"/>

        <waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
        <seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
    </actionGroup>
</actionGroups>
