vega-frontend-monorepo/apps/trading/e2e
Bartłomiej Głownia 94e7ad489f
feat(trading): main to develop back merge (#5739)
Co-authored-by: m.ray <16125548+MadalinaRaicu@users.noreply.github.com>
Co-authored-by: Matthew Russell <mattrussell36@gmail.com>
Co-authored-by: Edd <edd@vega.xyz>
2024-02-05 16:06:33 +01:00
..
actions chore(trading): fees e2e tests (#5496) 2023-12-19 12:22:15 +00:00
fixtures chore(trading): update vega-market-sim to use to 0.74.0-preview.2 (#5603) 2024-01-17 12:19:52 +00:00
tests feat(trading): main to develop back merge (#5739) 2024-02-05 16:06:33 +01:00
.env fix(trading): teams snags (#5707) 2024-02-01 10:38:57 +00:00
.env.develop chore(trading): update vega binaries to v0.74.0-preview.6 (#5686) 2024-01-30 13:31:06 +00:00
.env.main chore(trading): update vega (#5563) 2024-01-03 12:00:00 +00:00
config.py chore(trading): add playwright and market sim testing framework (#5199) 2023-11-14 10:05:07 -08:00
conftest.py chore(trading): retry on http error (#5601) 2024-01-10 15:44:01 +00:00
poetry.lock chore(trading): update vega binaries to v0.74.0-preview.6 (#5686) 2024-01-30 13:31:06 +00:00
pyproject.toml chore(trading): update vega-market-sim to use to 0.74.0-preview.2 (#5603) 2024-01-17 12:19:52 +00:00
README.md chore(trading): static vega port trading e2e (#5520) 2023-12-20 15:49:10 +00:00
wallet_config.py feat(trading): activity streaks, reward hoarder bonus and active rewards (#5491) 2024-01-05 11:16:59 +00:00

Trading Market-Sim End-To-End Tests

This direcotry contains end-to-end tests for the trading application using vega-market-sim. This README will guide you through setting up your environment and running the tests.

Prerequisites

Getting Started

  1. Install Poetry: Follow the instructions on the official Poetry website.
  2. Install Docker: Follow the instructions on the official Docker website.
  3. Install Python: Follow the instructions on the official Python website ensure you install a version between 3.9 and 3.11.
  4. Start up a Poetry environment: Execute the commands below to configure the Poetry environment.

Ensure you are in the tests folder before running commands

poetry shell
  1. Install python dependencies

To make sure you are on the latest version of our market-sim branch.

poetry update vega-sim
poetry install
  1. Install Playwright Browsers: Execute the command below to browsers for Playwright.
playwright install chromium
  1. Download necessary binaries: Use the following command within your Python environment. The --force flag ensures the binaries are overwritten, and the --version specifies the desired version. e.g. v0.73.4
python -m vega_sim.tools.load_binaries --force --version $VEGA_VERSION
  1. Pull the desired Docker image
docker pull vegaprotocol/trading:develop
  1. Run tests: Poetry/Python will serve the app from docker

Update the .env file with the correct trading image.

poetry run pytest

Docker images

Pull the desired image:

Testnet

docker pull vegaprotocol/trading:develop

Mainnet

docker pull vegaprotocol/trading:main

Find all available images on Docker Hub.

Create a Docker Image of Your Locally Built Trading App

To build your Docker image, use the following commands:

yarn nx build trading ./docker/prepare-dist.sh
docker build -f docker/node-outside-docker.Dockerfile --build-arg APP=trading --build-arg ENV_NAME=stagnet1 -t vegaprotocol/trading:latest .

Running Tests 🧪

Before running make sure the docker daemon is running.

To run a specific test, use the -k option followed by the name of the test. Run all tests:

poetry run pytest

Run a targeted test:

poetry run pytest -k "test_name" -s --headed

Run from anywhere:

yarn trading:test -- "test_name" -s --headed

Run using your locally served console:

Within one terminal

yarn nx build trading
yarn nx serve trading

Once console is served you can update the .env file to have local_server to true.

Running Tests in Parallel 🔢

To run tests in parallel, use the --numprocesses auto option. The --dist loadfile setting ensures that multiple runners are not assigned to a single test file.

From within the e2e folder:

poetry run pytest -s --numprocesses auto --dist loadfile

From anywhere:

yarn trading:test:all

Things to know

If you "intellisense" isn't working follow these steps:

  1. poetry run which python
    
  2. Then open the command menu in vscode (cmd + shift + p) and type select interpreter , press enter, select enter interpreter path press enter then paste in the output from that above command you should get the right python again