Skip to content

M2Coach/MFTF-MailHog-Wrapper

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
etc
 
 
 
 
 
 
 
 

MFTF to MailHog wrapper

CircleCI

What is it about?

  • Magento Functional Testing Framework is complete Acceptance Testing solution delivered OOTB with Magento 2.
  • MailHog is a tool installed along the web project, used to test e-mail sending during development of application.

Why you should use it?

Does your project look professional, if you deliver to your client a web store which welcomes Customers after registration with e-mail of Subject: Welcome to {{StoreName}} and contents beginning with Hello {{FirstName}} {{LastName}},. I think it's not. That's why I want to help you with avoiding such embarassing moments.

The best way is to test what e-mails are sent to the customers, just like the live website does. But we should not reinvent the wheel! There are tons of solutions that help you to verify how e-mails are sent, without using real SMTP account. One of them is MailHog, which behaves (for application) just like regular SMTP server, except the fact, that messages are not sent over the Internet.

Demo

Installation

  • Get the package

    $ composer require m2coach/mftf-mailhog-wrapper
  • Configure MailHog URL in /dev/tests/acceptance/.env

    MAILHOG_BASE_URL=http://mailhog:8025/
    

Usage

Action Groups provided

  • Verify if Inbox is empty:

    <actionGroup ref="OpenInboxActionGroup" stepKey="openInbox"/>
    <actionGroup ref="AssertNoMessagesActionGroup" stepKey="assertNoMessages"/>
  • Open Message by it's Index (nth row)

    <actionGroup ref="OpenInboxActionGroup" stepKey="openInbox"/>
    <actionGroup ref="OpenNthMessageActionGroup" stepKey="openNthMessage">
        <argument name="row" value="2"/>
    </actionGroup>
  • Open Message by it's Subject and Index

     <actionGroup ref="OpenInboxActionGroup" stepKey="openInbox"/>
     <actionGroup ref="OpenNthMessageBySubjectActionGroup" stepKey="openNthMessage">
         <argument name="row" value="1"/>
         <argument name="subject" value="Welcome to"/>
     </actionGroup>
  • Open Message by it's Recipient and Index

     <actionGroup ref="OpenInboxActionGroup" stepKey="openInbox"/>
     <actionGroup ref="OpenNthMessageByRecipientActionGroup" stepKey="openNthMessage">
         <argument name="row" value="1"/>
         <argument name="recipient" value="awesome@feature.com"/>
     </actionGroup>
  • Open Message by it's Recipient, Subject and Index

     <actionGroup ref="OpenInboxActionGroup" stepKey="openInbox"/>
     <actionGroup ref="OpenNthMessageByRecipientAndSubjectActionGroup" stepKey="openNthMessage">
         <argument name="row" value="1"/>
         <argument name="recipient" value="awesome@feature.com"/>
         <argument name="subject" value="Welcome to"/>
     </actionGroup>
  • Verify e-mail subject

     <actionGroup ref="AssertSubjectActionGroup" stepKey="assertSubject">
         <argument name="expectedSubject" value="Welcome to Main Website Store"/>
     </actionGroup>
  • Verify e-mail sender

     <actionGroup ref="AssertSenderActionGroup" stepKey="assertSender">
         <argument name="expectedSender" value="learn@mftf.test"/>
     </actionGroup>
  • Verify e-mail recipient

     <actionGroup ref="AssertRecipientActionGroup" stepKey="assertRecipient">
         <argument name="expectedRecipient" value="subscribe@mftf.test"/>
     </actionGroup>
  • Delete All Messages

    <actionGroup ref="DeleteAllMessagesActionGroup" stepKey="deleteAllMessages"/>
  • Delete currently opened Message

    <actionGroup ref="DeleteCurrentMessageActionGroup" stepKey="deleteSingleMessage"/>

Selectors provided

  • Inbox Grid (InboxGridSection)

    • Inbox Container (InboxContainer)
    • Message row (MessageRow)
    • Message row by it's index (NthMessageRow(#))
    • Message row by recipient and it's index (NthMessageRowByRecipient(Subject, #))
    • Message row by recipient, subject and it's index (NthMessageRowByRecipientAndSubject(Recipient, Subject, #))
    • Message row by subject and it's index (NthMessageRowBySubject(Subject, #))
    • Delete All Messages button (DeleteAllButton)
    • Delete All Messages confirmation button (DeleteAllConfirmationButton)
  • Single Message (MessageSection)

    • Sender (Sender)
    • Recipient (Recipient)
    • Subject (Subject)
    • Contents (Content)
    • Delete Message button (DeleteMessageButton)

License

Copyright © 2019, Łukasz Bajsarowicz M2.coach

Releases under MIT license, see LICENSE for details.

About

With MFTF to MailHog wrapper you get the possibility of testing not only the Magento application layer, but also the e-mails that are sent from Magento.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages