<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  *
  * This file is part of the Klarna KP module
  *
  * (c) Klarna Bank AB (publ)
  *
  * For the full copyright and license information, please view the NOTICE
  * and LICENSE files that were distributed with this source code.
  */
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
    <actionGroup name="CreateAndSubmitCreditMemoActionGroup">
        <arguments>
            <argument name="itemQtyToRefund" type="string" defaultValue="1"/>
            <argument name="shippingCredit" type="string" defaultValue="5"/>
        </arguments>

        <click selector="{{AdminInvoiceDetailsMainActionsSection.creditMemo}}" stepKey="clickCreditMemoButton"/>
        <waitForPageLoad stepKey="waitForCreditMemoPageLoad"/>

        <fillField selector="{{AdminCreditMemoTotalSection.refundShipping}}" userInput="{{shippingCredit}}" stepKey="fillShipping"/>

        <fillField selector="{{AdminInvoiceCreditMemoSection.itemQuantity}}" userInput="{{itemQtyToRefund}}" stepKey="fillItemQty"/>
        <waitForElement selector="{{AdminInvoiceCreditMemoSection.updateTotals}}" stepKey="waitForUpdateButton"/>
        <click selector="{{AdminInvoiceCreditMemoSection.updateTotals}}" stepKey="clickUpdateButton"/>

        <waitForElementVisible selector="{{AdminInvoiceCreditMemoSection.refund}}" stepKey="waitRefundButtonEnabled"/>
        <click selector="{{AdminInvoiceCreditMemoSection.refund}}" stepKey="clickRefundButton"/>

        <waitForPageLoad stepKey="waitForOrderPageLoadAfterRefund"/>
    </actionGroup>
</actionGroups>
