How to easily test scheduled triggers

When you use Scheduled automation flows, some of them probably perform tests, based on the current date.

An example: every day you send emails to customers who did not pay their invoices within 14 days and who did not receive a reminding email yet.

In the Lab, you don’t want to wait those 14 days to test the application. You could test by manipulating the data, for instance the invoice dates. This is not very elegant, though, because you change data. This might influence other flows or data.

A better way is to manipulate the Current date.
An example:

  • You have test-invoices dated today.

  • If you tell the testing Flow part that the Current date is not today, but 15 days in the future. You can test the flow for the invoices that would be overdue on that date without manipulating the data.

Setup

Create the reminding flow

  1. The Input is a Date and time.
  2. Create a Look-up: all invoices older than 14 days, have not been paid that did not get the 1st reminder.
  3. Create a Repeat. For every invoice it sends an email and it stores the moment the email was sent in the invoice.
    Reminding flow overview

Create the Automation flow

  1. Make it a Recurring one: Daily at a Specific time.

  2. Insert the Flow part.
    Automation flow overview

  3. Use the Current date and time as Input for the flow.
    Input

Now the application is set up.

Prepare the testing facility

You need a User flow for the admin.

Within that flow you create a Page in which you can enter the Date and time you want the flow(s) to think what the Current date and time currently is.

There is a Button that triggers the Flow part(s) which is/are used in the Automation flow.

The Input for the Flow part will be the date and time you specified.

Create the admin User flow
Admin user flow

  1. On the start Page, create Form fields for the values you want to use for your tests. For this example you create a Form field of the type Date and time.
    Start page

  2. Create a Submit button to trigger the Flow part.

  3. Input the Flow part with the Date and time you entered on the Page. Notice this is exactly the same Flow part used in the Automation flow.
    Input

  4. Create a Done Page that tells you that the Flow part was executed and connect it to the start Page.
    Done page

Tip: This example saves the Date and time that the email was sent. Don’t use the Current date and time for this, but the Date and time of the Input of the Flow part. Now you can see when you ran the test.

Examples

Below are examples of different invoices overdue to show how powerful this concept is.

  1. Before the test (today is 07-05-2021).
    Reminder test overview

  2. After the test. Input was Now (07-05-2021). There is one invoice overdue.
    Reminder test overview

  3. After the test. Input was 17-05-2021 (now + 14 days). Now there are two invoices overdue. The first one had sent a reminder already.
    Reminder test overview

  4. After the test. Input was 18-05-2021 (now + 15 days). Now all invoices are overdue. Two invoices had sent a reminder already.
    Reminder test overview

  5. After another test. Input was 18-05-2021 (now + 15 days). One invoice was paid, so there is no reminder for that one.
    Reminder test overview