<?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">
    <!--Create an Account. Check Sign Up for Newsletter checkbox -->
    <actionGroup name="StorefrontCreateNewAccountNewsletterChecked" extends="SignUpNewUserFromStorefrontActionGroup">
        <annotations>
            <description>EXTENDS: SignUpNewUserFromStorefrontActionGroup. Clicks on 'Sign Up for Newsletter'. Validates that the Subscription Confirmation message is present and correct.</description>
        </annotations>

        <click selector="{{StorefrontCustomerCreateFormSection.signUpForNewsletter}}" stepKey="selectSignUpForNewsletterCheckbox" after="fillLastName"/>
        <see stepKey="seeDescriptionNewsletter" userInput='You are subscribed to "General Subscription".' selector="{{CustomerMyAccountPage.DescriptionNewsletter}}"/>
    </actionGroup>

    <!--Create an Account. Uncheck Sign Up for Newsletter checkbox -->
    <actionGroup name="StorefrontCreateNewAccountNewsletterUnchecked" extends="SignUpNewUserFromStorefrontActionGroup">
        <annotations>
            <description>EXTENDS: SignUpNewUserFromStorefrontActionGroup. Validates that the you are NOT subscribed message is present and correct.</description>
        </annotations>
        <arguments>
            <argument name="Customer"/>
            <argument name="Store"/>
        </arguments>

        <amOnPage stepKey="amOnStorefrontPage" url="{{Store.code}}"/>
        <see stepKey="seeDescriptionNewsletter" userInput="You aren't subscribed to our newsletter." selector="{{CustomerMyAccountPage.DescriptionNewsletter}}"/>
        <see stepKey="seeThankYouMessage" userInput="Thank you for registering with NewStore."/>
    </actionGroup>

    <!--Check Subscribed Newsletter via StoreFront-->
    <actionGroup name="CheckSubscribedNewsletterActionGroup">
        <annotations>
            <description>Goes to the Storefront Newsletter Management page. Validates that the 'Subscription' checkbox is checked.</description>
        </annotations>

        <amOnPage url="{{StorefrontNewsletterManagePage.url}}" stepKey="goToNewsletterManage"/>
        <seeCheckboxIsChecked selector="{{StorefrontNewsletterManageSection.subscriptionCheckbox}}" stepKey="checkSubscribedNewsletter"/>
    </actionGroup>
</actionGroups>
