<?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="AdminMediaGalleryDeleteImage">
        <arguments>
            <argument name="name" type="string"/>
        </arguments>
        <seeElement selector="{{AdminAdobeStockSection.mediaGalleryImage(name)}}" stepKey="seeImageToDelete"/>
        <click selector="{{AdminAdobeStockSection.mediaGalleryImage(name)}}" stepKey="clickImageToDelete"/>
        <!-- Click image again, incase image was already selected and above step unselected the image by clicking it -->
        <conditionalClick
            visible="false"
            dependentSelector="{{AdminAdobeStockSection.mediaGalleryDeleteButton}}"
            selector="{{AdminAdobeStockSection.mediaGalleryImage(name)}}"
            stepKey="clickImageToDeleteAgain"/>
        <waitForElementVisible selector="{{AdminAdobeStockSection.mediaGalleryDeleteButton}}" stepKey="waitForDeleteButton"/>
        <click selector="{{AdminAdobeStockSection.mediaGalleryDeleteButton}}" stepKey="clickDeleteButton"/>
        <waitForElementClickable selector="{{AdminAdobeStockImagePreviewSection.confirm}}" stepKey="waitForConfirmationModal"/>
        <click selector="{{AdminAdobeStockImagePreviewSection.confirm}}" stepKey="clickConfirmButton"/>
        <waitForPageLoad stepKey="waitForMaskDisappeared"/>
        <dontSeeElement selector="{{AdminAdobeStockSection.mediaGalleryImage(name)}}" stepKey="assertImageIsDeleted"/>
    </actionGroup>
</actionGroups>
