<?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="AdminDeleteStockWithTwoAssignedSourcesActionGroup">
        <annotations>
            <description>Admin deletes stock with 2 assigned sources</description>
        </annotations>
        <arguments>
            <argument name="stockName" defaultValue="Test Stock 1" type="string"/>
            <argument name="websiteName" defaultValue="Main Website" type="string"/>
            <argument name="sourceName1"/>
            <argument name="sourceName2"/>
        </arguments>
        <amOnPage url="{{AdminStockPage.url}}" stepKey="navigateToManageStockPage"/>
        <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
        <fillField selector="{{AdminManageStockGridBody.searchStockText}}" userInput="{{stockName}}" stepKey="enterStockName" />
        <click selector="{{AdminManageStockGridBody.clickSearchStock}}" stepKey="clickSearchStockButton" />
        <waitForPageLoad stepKey="waitForStoreGroupPageLoad" />
        <click selector="{{AdminManageStockGridBody.editStock(stockName)}}" stepKey="clickEditStockButton" />
        <waitForPageLoad stepKey="waitForStoreGroupPageLoad1" />
        <unselectOption userInput="{{websiteName}}" selector="{{AdminEditStockGeneralSection.websites}}" stepKey="unselectWebsite"/>
        <conditionalClick selector="{{AdminEditStockSourcesSection.deleteSpecificAssignedSources(sourceName1)}}" dependentSelector="{{AdminEditStockSourcesSection.deleteSpecificAssignedSources(sourceName1)}}" visible="true" stepKey="clickDeleteAssignedSources1" />
        <conditionalClick selector="{{AdminEditStockSourcesSection.deleteSpecificAssignedSources(sourceName2)}}" dependentSelector="{{AdminEditStockSourcesSection.deleteSpecificAssignedSources(sourceName2)}}" visible="true" stepKey="clickDeleteAssignedSources2" />
        <click selector="{{AdminEditStockGeneralSection.saveAndContinueDropdown}}" stepKey="clickSaveAndContinueDropdown" />
        <click selector="{{AdminEditStockGeneralSection.saveAndCloseButton}}" stepKey="clickSaveAndClose" />
        <waitForPageLoad stepKey="waitForStoreGroupPageLoadPostEditingTheSources" />
        <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/>
        <seeElement selector="{{AdminManageStockGridBody.stockSavedSuccessfulMessage}}" stepKey="verifyTheStockSavedSuccessfully"/>
        <fillField selector="{{AdminManageStockGridBody.searchStockText}}" userInput="{{stockName}}" stepKey="enterStockNameForDelete" />
        <click selector="{{AdminManageStockGridBody.clickSearchStock}}" stepKey="clickSearchStockButtonForDelete" />
        <waitForPageLoad stepKey="waitForStoreGroupPageLoadForDelete" />
        <click selector="{{AdminManageStockGridBody.editStock(stockName)}}" stepKey="clickEditStockButtonForDelete" />
        <waitForPageLoad stepKey="waitForStoreGroupPageLoad1ForDelete" />
        <click selector="{{AdminEditStockSourcesSection.deleteStock}}" stepKey="deleteTheStock" />
        <waitForPageLoad stepKey="waitForPopupToDelete" />
        <click selector="{{AdminEditStockSourcesSection.editStockPopUpOK}}" stepKey="acceptPopupToDelete"/>
        <waitForPageLoad stepKey="waitForStoreGroupPageLoadPostDeletingTheStock" />
        <seeElement selector="{{AdminManageStockGridBody.stockDeleteSuccessfulMessage}}" stepKey="verifyTheStockDeletedSuccessfully"/>
    </actionGroup>
</actionGroups>
