<?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="StorefrontProductWithEmptyAttributeTest">
        <annotations>
            <features value="Catalog"/>
            <stories value="Create products"/>
            <title value="Product attribute is not visible on storefront if it is empty"/>
            <description value="Product attribute should not be visible on storefront if it is empty"/>
            <severity value="BLOCKER"/>
            <testCaseId value="MAGETWO-91893"/>
            <group value="product"/>
        </annotations>
        <before>
            <createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
            <createData entity="productAttributeWithDropdownTwoOptions" stepKey="createProductAttribute"/>
        </before>
        <after>
            <actionGroup ref="DeleteProductUsingProductGridActionGroup" stepKey="deleteSimpleProduct">
                <argument name="product" value="SimpleProduct"/>
            </actionGroup>
            <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="clearFilter"/>
            <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
            <deleteData createDataKey="createProductAttribute" stepKey="deleteProductAttribute"/>
            <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>

            <!-- Reindex invalidated indices after product attribute has been created/deleted -->
            <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
        </after>
        <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/>
        <amOnPage url="{{AdminProductAttributeSetGridPage.url}}" stepKey="amOnAttributeSetPage"/>
        <click selector="{{AdminProductAttributeSetGridSection.AttributeSetName('Default')}}" stepKey="chooseDefaultAttributeSet"/>
        <waitForPageLoad stepKey="waitForAttributeSetPageLoad"/>
        <dragAndDrop selector1="{{UnassignedAttributes.ProductAttributeName('testattribute')}}" selector2="{{Group.FolderName('Product Details')}}" stepKey="moveProductAttributeToGroup"/>
        <click selector="{{AttributeSetSection.Save}}" stepKey="saveAttributeSet"/>
        <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear" />
        <seeElement selector=".message-success" stepKey="assertSuccess"/>
        <actionGroup ref="FillAdminSimpleProductFormActionGroup" stepKey="fillProductFieldsInAdmin">
            <argument name="category" value="$$createPreReqCategory$$"/>
            <argument name="simpleProduct" value="SimpleProduct"/>
        </actionGroup>
        <actionGroup ref="ClearCacheActionGroup" stepKey="clearCache"/>
        <amOnPage url="{{StorefrontProductPage.url(SimpleProduct.urlKey)}}" stepKey="goProductPageOnStorefront"/>
        <waitForPageLoad stepKey="waitForProductPageToLoad"/>
        <dontSeeElement selector="//table[@id='product-attribute-specs-table']/tbody/tr/th[contains(text(),'testattribute')]" stepKey="seeAttribute2"/>
    </test>
    </tests>
