<?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="LoginAsCustomerOnCheckoutPageActionGroup">
        <annotations>
            <description>Fills in the provided Customer (Email and Password) details in the 'Sign In' modal on the Storefront Checkout page.</description>
        </annotations>
        <arguments>
            <argument name="customer" type="entity"/>
        </arguments>

        <waitForPageLoad stepKey="waitForCheckoutShippingSectionToLoad"/>
        <fillField selector="{{CheckoutShippingSection.email}}" userInput="{{customer.email}}" stepKey="fillEmailField"/>
        <waitForPageLoad stepKey="waitForLoadingMaskToDisappear"/>
        <waitForElementVisible selector="{{CheckoutShippingSection.password}}" stepKey="waitForElementVisible"/>
        <fillField selector="{{CheckoutShippingSection.password}}" userInput="{{customer.password}}" stepKey="fillPasswordField"/>
        <waitForPageLoad stepKey="waitForLoadingMaskToDisappear2"/>
        <waitForElementVisible selector="{{CheckoutShippingSection.loginButton}}" stepKey="waitForLoginButtonVisible"/>
        <doubleClick selector="{{CheckoutShippingSection.loginButton}}" stepKey="clickLoginBtn"/>
        <waitForPageLoad stepKey="waitForLoadingMaskToDisappear3"/>
        <waitForPageLoad stepKey="waitToBeLoggedIn"/>
        <waitForElementNotVisible selector="{{CheckoutShippingSection.email}}" stepKey="waitForEmailInvisible" time ="60"/>
    </actionGroup>
</actionGroups>
