<?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="AdminDeleteCartPriceRuleActionGroup">
        <annotations>
            <description>Goes to the Admin Cart Price Rules grid page. Filters the grid for the provided Rule Name. Deletes the Rule via the grid.</description>
        </annotations>
        <arguments>
            <argument name="ruleName" type="entity"/>
        </arguments>

        <amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="goToCartPriceRules"/>
        <waitForPageLoad stepKey="waitForCartPriceRules"/>
        <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="resetFilterBeforeDelete"/>
        <waitForPageLoad stepKey="waitForCartPriceRulesResetFilter"/>
        <fillField selector="{{AdminCartPriceRulesSection.filterByNameInput}}" userInput="{{ruleName.name}}" stepKey="filterByName"/>
        <click selector="{{AdminCartPriceRulesSection.searchButton}}" stepKey="doFilter"/>
        <click selector="{{AdminCartPriceRulesSection.rowByIndex('1')}}" stepKey="goToEditRulePage"/>
        <click selector="{{AdminCartPriceRulesFormSection.delete}}" stepKey="clickDeleteButton"/>
        <waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForConfirmModal"/>
        <click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/>
    </actionGroup>
</actionGroups>
