Mentions légales du service

Skip to content

feat: add e2e for mute

HUBERT Baptiste requested to merge feat/add-ci into main

Run the tests

You have two options to run the tests. Each of these options requires Docker installed on your machine.

First option :

Run Mute and the Signaling Server as Docker containers and run the tests locally. Open a terminal at the root of the project, then type this command :

docker-compose up -d

This will launch both Mute and the Signaling Server container. Mute will be available at http://localhost:4200 and the Signaling Serve will be available at ws://localhost:8010.

Then, in your terminal, navigate to the src/e2e folder.

Type these commands :

npm ci

To run a test, you need to be in the src/e2e/ folder. The generic command to launch a test looks like this :

npm run test BrowserToUse1 BrowserToUse2 scenario-you-want-to-run false

Where BrowserToUse1 and BrowserToUse2 are browsers that you have on your machine, locally.
The scenario-you-want-to-run means to be replaced by one of these scenario :

  • fullscenario : Runs the whole E2E scenario
  • online : Two users meet up on the same document and modify its content
  • offline : Two previously met users are disconnected from the signaling server but can still both modify the document
  • offline-to-online

Second option :

Run everything as a docker container
Open a terminal and go at the root of the repository folder and type this command

sh src/e2e/scripts/build-and-run-ci-container.sh ci-scenario-name ci-scenario-name-container

This will build the main container that will contain the TestCafe instance and the Mute and Signaling Server container. ci-scenario-name and ci-scenario-name-container are names that you can set yourself as you please The image size is nearly ~ 1.5 GB

When the container has been built and is running, type this command :

docker exec -w /app/mute ci-scenario-name-container /bin/sh start-mute-sigver-containers.sh

This command will start the Mute and the Signaling Server container in ci-scenario-name-container.

Once this is done, you can run any test you want, by typing this command :

docker exec -w /app/ci ci-scenario-name-container npm run test chromium firefox scenario-you-want-to-run true

As we are running in a container, we run the test using chromium and firefox browser. The scenario-you-want-to-run means to be replaced by one of these scenario :

  • fullscenario : Runs the whole E2E scenario
  • online : Two users meet up on the same document and modify its content
  • offline : Two previously met users are disconnected from the signaling server but can still both modify the document
  • offline-to-online

The last true parameter is simply an indication to TestCafe that we are running in a docker container (which will be interpreted in the code as running the browsers in headless mode)

Warnings

Known problems that can occur wether running the tests locally or in a Docker container :
Locally - When running the offline scenario, the signaling server container is killed. You will have to launch it again manually on your machine if you want to test the other scenarios.
Locally and in a Docker container - When running the offline-to-online scenario, the test can fail at the end step (the merge of the text). This behavior is normal if we are using a chromium based browser with Firefox.
Locally and in a Docker container - When running a test, sometimes, TestCafe can freeze, not doing the next step. This behavior isn't normal (and will be studied) but it can still happen. Stopping the test manually and launching it again resolves the situation.
In a Docker container - Running multiple scenario one after another might induce bugs as tests might fail. It is recommended to run only one scenario in the container, then kill the container and relaunch it, starting mute and sigver again.

Other informations

We are using TestCafe as a solution to write our E2E tests.

Side note

  • If you are trying to run the test locally on a Windows system (or a system without sh support), you will need to have the sh command installed.
    (when you have git installed, you can add C:\Program Files\Git\bin to your environment variables)

Merge request reports