<?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="AdminCreateCustomerWithoutAddressTest">
        <annotations>
            <stories value="Create customer"/>
            <title value="Create customer, without address"/>
            <description value="Login as admin and create a customer without address"/>
            <severity value="CRITICAL"/>
            <testCaseId value="MC-5307"/>
            <group value="mtf_migrated"/>
        </annotations>

        <before>
            <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindexAfterTest">
                <argument name="indices" value="customer_grid"/>
            </actionGroup>
            <actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/>
        </before>
        <after>
            <actionGroup ref="DeleteCustomerByEmailActionGroup" stepKey="deleteCustomer">
                <argument name="email" value="{{CustomerEntityOne.email}}"/>
            </actionGroup>
            <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetGrid"/>
            <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
        </after>

        <!--Open New Customer Page -->
        <actionGroup ref="AdminNavigateNewCustomerActionGroup" stepKey="waitToCustomerPageLoad"/>
        <fillField userInput="{{CustomerEntityOne.firstname}}" selector="{{AdminCustomerAccountInformationSection.firstName}}" stepKey="fillFirstName"/>
        <fillField userInput="{{CustomerEntityOne.lastname}}" selector="{{AdminCustomerAccountInformationSection.lastName}}" stepKey="fillLastName"/>
        <fillField userInput="{{CustomerEntityOne.email}}" selector="{{AdminCustomerAccountInformationSection.email}}" stepKey="fillEmail"/>
        <click selector="{{AdminCustomerMainActionsSection.saveButton}}" stepKey="saveCustomer"/>
        <seeElement selector="{{AdminCustomerMessagesSection.successMessage}}" stepKey="assertSuccessMessage"/>
        <reloadPage stepKey="reloadPage"/>

        <!--Filter the customer From grid-->
        <actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterTheCustomerByEmail">
            <argument name="email" value="{{CustomerEntityOne.email}}"/>
        </actionGroup>
        <waitForPageLoad stepKey="waitForPageToLoad"/>

        <!-- Assert Customer in grid -->
        <see userInput="{{CustomerEntityOne.firstname}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertFirstName"/>
        <see userInput="{{CustomerEntityOne.lastname}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertLastName"/>
        <see userInput="{{CustomerEntityOne.email}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertEmail"/>

        <!--Assert Customer Form -->
        <actionGroup ref="AdminClickFirstRowEditLinkOnCustomerGridActionGroup" stepKey="clickOnEditButton1"/>
        <click selector="{{AdminCustomerAccountInformationSection.accountInformationButton}}" stepKey="clickOnAccountInformation"/>
        <waitForPageLoad stepKey="waitForCustomerInformationPageToLoad"/>
        <seeInField selector="{{AdminCustomerAccountInformationSection.firstName}}" userInput="{{CustomerEntityOne.firstname}}" stepKey="seeCustomerFirstName"/>
        <seeInField selector="{{AdminCustomerAccountInformationSection.lastName}}" userInput="{{CustomerEntityOne.lastname}}" stepKey="seeCustomerLastName"/>
        <seeInField selector="{{AdminCustomerAccountInformationSection.email}}" userInput="{{CustomerEntityOne.email}}" stepKey="seeCustomerEmail"/>
    </test>
</tests>
