<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  */
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
    <test name="XOnRemovalConfirmationModalTest">
        <annotations>
            <features value="PageBuilder"/>
            <stories value="Common Tests"/>
            <title value="Delete Content Modal - Click X On Removal Confirmation Modal"/>
            <description value="The user should be able to click on the 'X' button in removal confirmation modal and not have content removed."/>
            <severity value="AVERAGE"/>
            <useCaseId value="MAGETWO-87059"/>
            <testCaseId value="MC-2789"/>
            <group value="pagebuilder"/>
            <group value="pagebuilder-common"/>
            <group value="pagebuilder-heading"/>
            <group value="cloud"/>
        </annotations>
        <before>
            <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
            <actionGroup ref="navigateToAPageWithPageBuilder" stepKey="navigateToAPageWithPageBuilder"/>
            <actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage"/>
            <actionGroup ref="dragContentTypeToStage" stepKey="dragRowToRootContainer">
                <argument name="contentType" value="PageBuilderRowContentType"/>
                <argument name="containerTargetType" value="PageBuilderRootContainerContentType"/>
            </actionGroup>
        </before>
        <after>
            <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
        </after>
        <!-- Add Heading -->
        <comment userInput="Add Heading" stepKey="commentAddHeading"/>
        <actionGroup ref="expandPageBuilderPanelMenuSection" stepKey="expandPageBuilderPanelMenuSection">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
        </actionGroup>
        <actionGroup ref="dragContentTypeToStage" stepKey="dragContentTypeToStage">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
        </actionGroup>
        <actionGroup ref="clickOutsideLiveEditHeading" stepKey="clickOutsideLiveEditHeading">
            <argument name="index" value="1"/>
        </actionGroup>
        <!-- Configure Heading -->
        <comment userInput="Configure Heading" stepKey="commentEditHeading"/>
        <actionGroup ref="openPageBuilderEditPanel" stepKey="openEditMenuOnStage">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
        </actionGroup>
        <actionGroup ref="selectSlideOutPanelFieldGeneral" stepKey="enterHeadingType">
            <argument name="property" value="PageBuilderHeadingTypeProperty_H2"/>
        </actionGroup>
        <actionGroup ref="fillSlideOutPanelFieldGeneral" stepKey="enterHeadingTitle">
            <argument name="property" value="PageBuilderHeadingTextProperty"/>
        </actionGroup>
        <actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings"/>
        <waitForElementVisible selector="{{HeadingOnStage.baseByTagName(PageBuilderHeadingTypeProperty_H2.value, '1')}}" stepKey="validateHeading1"/>
        <!-- Click Remove Then X In Modal -->
        <comment userInput="Click Remove Then X In Modal" stepKey="commentX"/>
        <actionGroup ref="removeEmptyContentTypeFromStage" stepKey="removeHeading">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
        </actionGroup>
        <waitForPageLoad stepKey="waitForPageLoad"/>
        <waitForElementVisible time="10" selector="{{PageBuilderStage.modal}}" stepKey="waitForModalVisible"/>
        <waitForElementVisible time="10" selector="{{PageBuilderStage.modalX}}" stepKey="waitForXButton"/>
        <click selector="{{PageBuilderStage.modalX}}" stepKey="clickXButton"/>
        <waitForPageLoad stepKey="waitForPageLoad2"/>
        <waitForElementNotVisible time="10" selector="{{PageBuilderStage.modal}}" stepKey="waitForModalGone"/>
        <!-- Verify Heading Still Exists -->
        <comment userInput="Verify Heading Still Exists" stepKey="validateHeading"/>
        <waitForElementVisible selector="{{HeadingOnStage.baseByTagName(PageBuilderHeadingTypeProperty_H2.value, '1')}}" stepKey="validateHeading2"/>
    </test>
</tests>
