Skip to main content

Flows & Scripts

info
  • Flows should be used to keep our code DRY.
  • They should not include any Jira ticket numbers and should be called from within tests.
  • How flows can be configured.

Flow Template

Please see our template for a flow file here.

The runFlow command

Runs your flow from a specified file:

- runFlow: <relative-path-to-your-flow>.yaml

Please see examples here from the Maestro documentation.

For our current shared flows look in e2e/flows. Any universally shareable flows should live in this file. Our common flows are listed below.

Common Maestro Flows to Use

Launch

  • e2e/flows/launch.yaml
  • Used for almost all tests to authenticate users, run respective setup actions, and launch the app.
  • There are tests that include this flow multiple times throughout, for example e2e/tests/group-betting/short-pot-settings-active-pot.yaml. You see can that this test passes different SETUP environment variables each time launch.yaml is called to perform different actions.
  • By calling the launch flow, and in turn a setup action, it allows us to utilise all available functions and hooks from those features, and our app in general, to perform actions.

Placing a racing bet

  • e2e/flows/betting/place-racing-bet.yaml
    • This will navigate to the test meeting and place a bet of your choosing.
    • Note: This flow needs environment variables to be set for it to work. Please read the comments within the file for more information.
    • It will finish on the Betslip screen.
  • e2e/tests/racing/place-bet.yaml
    • This adds to the place-racing-bet.yaml flow by asserting that the bet was placed successfully.
    • This test is used in our e2e/tests/racing test suite and has been called multiple times using a range of environment variables for different bet types.
    • If you need to place a new bet type in a test, please create a new test, and call this flow with new environment variables. You may even need to update this flow as well to support your new bet type, alongside the initialise-output-constants.js bet types in that file too.

Placing a sports bet

Bottom Tab Bar

  • We have flows set up for navigating throughout the app using the Bottom Tab Bar.
  • e2e/flows/navigation/bottom-tab-bar

Betslip

  • We have e2e/flows/navigation/betslip/open.yaml and e2e/flows/navigation/betslip/close.yaml flows for the Betslip that are used as their names suggest.

Test race meeting

  • e2e/flows/navigation/racing/test-meeting.yaml
  • This simply taps on the test meeting that was set in e2e/fixtures/constants/initialise-output-constants.js.
  • e2e/flows/deeplink.yaml
  • Allows us to deeplink to any location listed in app/modules/deeplinking/deeplinking-route-mapping.ts.
  • Note: The bottom tab bar will not update its selected screen when using deeplinking.

Login

  • e2e/flows/login.yaml
  • Used explicitly when we want to login through the app's UI.

Login with last launch user

  • This is used to simply login with the last user launch user. For example, in the middle of a Punter Assist test.

Input amount into betslip

  • e2e/flows/betslip/input-amount-with-minimal-amount.yaml
  • used to input a specific amount into the Betslip keyboard.
  • e2e/flows/navigation/group-mode/navigate-to-group.yaml

Common Maestro Scripts to Use

Get user balance

  • e2e/utils/helpers/get-user-balance.js
  • This script fetches the user's balance and assigns it to the output object. An example of this script can be seen below:
  • NOTE: this flow should be moved out of 'group-betting' and made a common flow.
  • If your user balance is '$980.00', this flow will respond that output.constants.user.balance is equal to 980.
- runFlow:
file: flows/group-betting/get-user-balance.yaml
env:
ACCOUNT_TAG: LONG_POT_TOPUP_ADMIN
- assertTrue: ${<your-balance-to-assert-against> === output.constants.user.balance}

Asserting Elements Across Different Brands

  • e2e/utils/helpers/set-brand-expectation.js
  • This script is used to assert elements across different brands. This script was created to avoid needing ternaries (and nested ternaries for 3 brands) to assert elements. reducing the amount of lines needed to test things across multiple brands. See example below:

Don't

- assertTrue: ${BRAND === 'neds' ? 'Access to Neds Toolbox promos, bonuses and boosts' : 'Access to Ladbrokes Locker promos, bonuses and boosts'}

Can Do

- runFlow:
when:
true: ${BRAND == 'neds'}
commands:
- assertVisible: "Access to Neds Toolbox promos, bonuses and boosts"
- runFlow:
when:
true: ${BRAND == 'ladbrokes'}
commands:
- assertVisible: 'Access to Ladbrokes Locker promos, bonuses and boosts'
- runScript:
file: ../../../utils/helpers/set-brand-expectation.js
env:
NEDS: 'Access to Neds Toolbox promos, bonuses and boosts'
LADBROKES: 'Access to Ladbrokes Locker promos, bonuses and boosts'

Date and time

  • e2e/fixtures/constants/current-date.js
  • Used for date and time purposes. We should ideally add all new date properties to the output.date object for simplicity and explicity.