This repository has been archived on 2022-03-31. You can view files and clone it, but cannot push or open issues or pull requests.
cic-ussd-e2e/README.md

71 lines
2.1 KiB
Markdown
Raw Permalink Normal View History

2022-03-24 17:40:15 +01:00
# cic-ussd-e2e
2022-03-24 17:38:49 +01:00
Bunch of test scripts to automate traversing USSD menu's with little human interaction and as close replication to actual USSD usage including AT style reqests and waiting times.
2022-03-24 17:38:49 +01:00
2022-03-24 17:40:15 +01:00
## Setup
2022-03-24 17:38:49 +01:00
**Pre-requisites**
2 accounts each with:
- Initial pin set
- Some SRF Balance
**Environment**
- Node.js
- Install dependencies with `$ npm i`
- Set global config in `config.js`
## Scenarios
| Test | Type | Description |
| -------------- | --------- | ---------------------------------------------- |
| initial_menu | Statless | Main menu > Help > Exit |
| display_sarafu | Stateless | Main menu > My Sarafu > Exit |
| reset_pin | Stateful | Main menu > Account options > Reset pin > Exit |
### Stateful scenarios
These tests live individually in their own folder. They require some ENV variables to be set before running them.
### Stateless scenarios
These are included under the `stateless` folder and can be run in any order and have multple tests under the same folder since they only check correctness of menu responses.
2022-03-24 17:38:49 +01:00
2022-03-24 17:40:15 +01:00
## Running tests
2022-03-24 17:38:49 +01:00
```bash
# Set env variables for stateful scenarios, refer to individual test folders
$ npx tap --bail scenarios/SCENARIO_NAME
2022-03-24 17:38:49 +01:00
```
Examples:
- `CURRENT_PIN=4444 NEW_PIN=3333 npx tap --bail scenarios/stateless`
### Limitations
2022-03-24 17:38:49 +01:00
- These scripts cannot reset USSD sessions upon failure. You will need to manually set your account USSD menu to the main menu
- Cannot verify sms status, confirm with cic-notify for delivery
2022-03-24 17:38:49 +01:00
2022-03-24 17:40:15 +01:00
### Writing your own scenario
2022-03-24 17:38:49 +01:00
- Each scenario should exit since this test suite doesn't pass around past session info
- Control wait between menus with the `wait(time in ms)` function
- Follow any spec
2022-03-24 17:40:15 +01:00
- For any menu traversal, remember to append a `*` before the next input, this correctly mocks AT webhooks e.g.
- Dyanmic inputs for stateful scenarios must come from an env var that can be set again on next run
- Include a `tap-parallel-not-ok` file in any new folder
2022-03-24 17:38:49 +01:00
```bash
# Initial Main menu, no input
""
# Input 1
"1"
# Input 2
"1*2"
# Input 99
"1*2*99"
```