<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  */
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
    <test name="AdminCreateCreditMemoTotalRefundFullInvoiceVirtualProductCustomStockTest" extends="AdminCreateCreditMemoTotalRefundFullInvoiceVirtualProductDefaultStockTest">
        <annotations>
            <stories value="Virtual Product Custom Stock."/>
            <title value="Create Total Refund Credit Memo after Full Invoice With Virtual Product on Custom Stock."/>
            <description value="Verify admin able to create Credit Memo with total refund after full invoice with virtual product custom stock."/>
            <testCaseId value="https://app.hiptest.com/projects/69435/test-plan/folders/735141/scenarios/1695035"/>
            <severity value="CRITICAL"/>
            <group value="msi"/>
            <group value="multi_mode"/>
        </annotations>

        <before>
            <!--Create additional stock and link additional source to stock.-->
            <createData entity="BasicMsiStockWithMainWebsite1" stepKey="additionalStock" after="additionalSource"/>
            <createData entity="SourceStockLinked1" stepKey="sourceStockLink" after="additionalStock">
                <requiredEntity createDataKey="additionalStock"/>
                <requiredEntity createDataKey="additionalSource"/>
            </createData>
            <remove keyForRemoval="assignMainWebsiteToDefaultStock"/>
        </before>
        <after>
            <!--Assign Default Stock to Default Website.-->
            <actionGroup ref="AssignWebsiteToStockActionGroup" stepKey="assignMainWebsiteToDefaultStock" after="disableSource">
                <argument name="stockName" value="{{_defaultStock.name}}"/>
                <argument name="websiteName" value="{{_defaultWebsite.name}}"/>
            </actionGroup>
            <deleteData createDataKey="additionalStock" after="logoutOfAdmin" stepKey="deleteStock"/>
        </after>

        <!--Assign virtual product to additional source.-->
        <actionGroup ref="AssignSourceToProductActionGroup" stepKey="assignTestSourceToCreatedProduct" after="openProductEditPage">
            <argument name="sourceCode" value="$$additionalSource.source[source_code]$$"/>
        </actionGroup>
        <fillField selector="{{AdminProductSourcesGrid.rowQty('1')}}" userInput="100" stepKey="setCustomSourceQuantity" after="assignTestSourceToCreatedProduct"/>
        <!--Verify product quantity.-->
        <remove keyForRemoval="checkProductSourceQtyAfterCreditMemo"/>
        <remove keyForRemoval="checkSalableQtyAfterCreditMemo"/>
        <see selector="{{AdminProductGridSection.productQtyPerSource('1',$$additionalSource.source[name]$$)}}" userInput="100" stepKey="checkProductSourceQtyAfterCreditMemo" after="findProductBySkuToCheckQtyAfterCreditMemo"/>
        <see selector="{{AdminProductGridSection.productSalableQty('1', $$additionalStock.stock[name]$$)}}" userInput="100" stepKey="checkSalableQtyAfterCreditMemo" after="checkProductSourceQtyAfterCreditMemo"/>
    </test>
</tests>
