<?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="AdminDeleteWidgetActionGroup">
        <annotations>
            <description>Goes to the Admin Widget grid page. Deletes the provided Widget. Validates that the Success Message is present and correct.</description>
        </annotations>
        <arguments>
            <argument name="widget"/>
        </arguments>

        <amOnPage url="{{AdminWidgetsPage.url}}" stepKey="amOnAdmin"/>
        <waitForPageLoad stepKey="waitWidgetsLoad"/>
        <conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearExistingFilters"/>
        <fillField selector="{{AdminWidgetsSection.widgetTitleSearch}}" userInput="{{widget.name}}" stepKey="fillTitle"/>
        <click selector="{{AdminWidgetsSection.searchButton}}" stepKey="clickContinue"/>
        <click selector="{{AdminWidgetsSection.searchResult}}" stepKey="clickSearchResult"/>
        <waitForPageLoad stepKey="waitForResultLoad"/>
        <click selector="{{AdminMainActionsSection.delete}}" stepKey="clickDelete"/>
        <waitForAjaxLoad stepKey="waitForAjaxLoad"/>
        <click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/>
        <waitForPageLoad stepKey="waitForDeleteLoad"/>
        <see selector="{{AdminMessagesSection.success}}" userInput="The widget instance has been deleted" stepKey="seeSuccess"/>
    </actionGroup>
</actionGroups>
