<?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="AssertStorefrontCheckoutCartEstimateShippingAndTaxAddressActionGroup">
        <annotations>
            <description>Check address data in Estimate Shipping And Tax section of shopping cart on storefront</description>
        </annotations>
        <arguments>
            <argument name="country" type="string" defaultValue="{{US_Address_TX.country}}"/>
            <argument name="state" type="string" defaultValue="{{US_Address_TX.state}}"/>
            <argument name="postcode" type="string" defaultValue="{{US_Address_TX.postcode}}"/>
        </arguments>

        <waitForElementVisible selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="waitForSubtotalVisible"/>
        <conditionalClick selector="{{CheckoutCartSummarySection.estimateShippingAndTax}}" dependentSelector="{{CheckoutCartSummarySection.country}}" visible="false" stepKey="expandEstimateShippingAndTaxIfNeeded" />
        <seeOptionIsSelected selector="{{CheckoutCartSummarySection.country}}" userInput="{{country}}" stepKey="checkCountry"/>
        <seeOptionIsSelected selector="{{CheckoutCartSummarySection.stateProvince}}" userInput="{{state}}" stepKey="checkState" />
        <grabValueFrom selector="{{CheckoutCartSummarySection.postcode}}" stepKey="grabPostCodeText"/>
        <assertEquals  message="Address postcode is invalid" stepKey="checkPostcode">
            <expectedResult type="string">{{postcode}}</expectedResult>
            <actualResult type="variable">grabPostCodeText</actualResult>
        </assertEquals>
    </actionGroup>
</actionGroups>
