<?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="VerifyDiscountAmountActionGroup">
        <annotations>
            <description>Goes to the provided Storefront Product URL. Fills in provided Quantity. Clicks Add to Cart. Goes to Checkout. Validates that the provided Discount Amount is present and correct.</description>
        </annotations>
        <arguments>
            <argument name="productUrl" type="string"/>
            <argument name="quantity" type="string"/>
            <argument name="expectedDiscount" type="string"/>
        </arguments>

        <amOnPage url="{{productUrl}}" stepKey="goToProductPage"/>
        <waitForPageLoad stepKey="waitForProductPageLoad"/>
        <fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="{{quantity}}" stepKey="fillQuantity"/>
        <waitForElementNotVisible selector="{{StorefrontProductActionSection.addToCartDisabled}}" stepKey="waitForAddToCartButtonToRemoveDisabledState"/>
        <waitForElementClickable selector="{{StorefrontProductActionSection.addToCart}}" stepKey="waitForAddToCartButton"/>
        <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
        <waitForPageLoad stepKey="waitForAddToCart"/>
        <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/>
        <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
        <waitForPageLoad stepKey="waitForCartPage"/>
        <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/>
        <waitForText selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="{{expectedDiscount}}" stepKey="seeDiscountTotal"/>
    </actionGroup>
</actionGroups>
