<?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="DeleteCategoryActionGroup">
        <annotations>
            <description>Navigates to the category page and deletes the specified category.</description>
        </annotations>
        <arguments>
            <argument name="categoryEntity" defaultValue="_defaultCategory"/>
        </arguments>

        <amOnPage url="{{AdminCategoryPage.url}}" stepKey="goToCategoryPage"/>
        <waitForPageLoad time="60" stepKey="waitForCategoryPageLoad"/>
        <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(categoryEntity.name)}}" stepKey="clickCategoryLink"/>
        <waitForElementClickable selector="{{AdminCategoryMainActionsSection.DeleteButton}}" stepKey="waitForDeleteButtonClickable" />
        <click selector="{{AdminCategoryMainActionsSection.DeleteButton}}" stepKey="clickDelete"/>
        <waitForElementVisible selector="{{AdminCategoryModalSection.message}}" stepKey="waitForConfirmationModal"/>
        <see selector="{{AdminCategoryModalSection.message}}" userInput="Are you sure you want to delete this category?" stepKey="seeDeleteConfirmationMessage"/>
        <click selector="{{AdminCategoryModalSection.ok}}" stepKey="confirmDelete"/>
        <waitForPageLoad time="60" stepKey="waitForDeleteToFinish"/>
        <see selector="You deleted the category." stepKey="seeDeleteSuccess"/>
        <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandToSeeAllCategories"/>
        <dontSee selector="{{AdminCategorySidebarTreeSection.categoryInTree(categoryEntity.name)}}" stepKey="dontSeeCategoryInTree"/>
    </actionGroup>
</actionGroups>
