<?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="DismissRemovalConfirmationModalTest">
        <annotations>
            <features value="PageBuilder"/>
            <stories value="Common Tests"/>
            <title value="Delete Content Modal - Dismissing the removal confirmation modal"/>
            <description value="The user should not be prompted after selecting 'Do not show this again'"/>
            <severity value="AVERAGE"/>
            <useCaseId value="MAGETWO-86799"/>
            <testCaseId value="MC-2598"/>
            <group value="pagebuilder"/>
            <group value="pagebuilder-common"/>
            <group value="pagebuilder-heading"/>
            <group value="pr_exclude"/>
            <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 a single header into the first row -->
        <actionGroup ref="expandPageBuilderPanelMenuSection" stepKey="expandPageBuilderPanelMenuSection">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
        </actionGroup>
        <actionGroup ref="dragContentTypeToStage" stepKey="dragHeaderIntoStage">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
        </actionGroup>
        <actionGroup ref="clickOutsideLiveEditHeading" stepKey="clickOutsideLiveEditHeading">
            <argument name="index" value="1"/>
        </actionGroup>
        <!-- Configure our heading -->
        <actionGroup ref="openPageBuilderEditPanel" stepKey="openEditMenuOnStage">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
        </actionGroup>
        <actionGroup ref="selectSlideOutPanelFieldGeneral" stepKey="enterHeadingTypePropertyH5">
            <argument name="property" value="PageBuilderHeadingTypeProperty_H5"/>
        </actionGroup>
        <actionGroup ref="fillSlideOutPanelFieldGeneral" stepKey="enterHeadingTitleProperty">
            <argument name="property" value="PageBuilderHeadingTextProperty"/>
        </actionGroup>
        <actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanelSettings"/>

        <!-- Duplicate heading -->
        <actionGroup ref="duplicateContentType" stepKey="duplicateHeadingOnce">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
        </actionGroup>

        <!-- Remove the first heading, expect a prompt -->
        <actionGroup ref="removeContentTypeFromStageByIndex" stepKey="removeFirstHeader">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
            <argument name="contentTypeNumber" value="1"/>
        </actionGroup>

        <waitForElementVisible time="2" selector="{{PageBuilderStage.modal}}" stepKey="waitForModalVisible"/>
        <seeElementInDOM selector="{{PageBuilderStage.modal}}" stepKey="seeModal"/>
        <seeElementInDOM selector="{{PageBuilderStage.modalOk}}" stepKey="seeModalOk"/>
        <waitForElementVisible selector="{{PageBuilderStage.modalDoNotShowThisAgain}}" stepKey="waitForDoNotShowThisAgain"/>
        <click selector="{{PageBuilderStage.modalDoNotShowThisAgain}}" stepKey="clickDoNotShowThisAgain"/>
        <actionGroup ref="confirmRemovalModal" stepKey="confirmRemoval"/>
        <wait time="2" stepKey="waitForRemovalModal"/>

        <!-- Attempt to remove secondary heading, no modal should appear even though it's configured -->
        <actionGroup ref="removeEmptyContentTypeFromStage" stepKey="removeSecondHeader">
            <argument name="contentType" value="PageBuilderHeadingContentType"/>
        </actionGroup>
        <dontSee selector="{{PageBuilderStage.modal}}" stepKey="dontSeeModalHeader"/>
        <dontSee selector="{{PageBuilderStage.modalOk}}" stepKey="dontSeeModalOkHeader"/>

        <!-- Validate the items are removed -->
        <dontSeeElement selector="{{PageBuilderStage.contentTypeInStage(PageBuilderHeadingContentType.role)}}" stepKey="dontSeeHeaderInStage"/>
    </test>
</tests>
