digidem / comapeo-mobile

The next version of Mapeo mobile
GNU General Public License v3.0
5 stars 1 forks source link

Adds first test for the E2E testing framework Maestro #422

Closed cimigree closed 3 months ago

cimigree commented 3 months ago

Related to:

closes this ticket

Description

Instructions

From the Maestro Docs

Install Maestro: curl -Ls "https://get.maestro.mobile.dev" | bash

Start an emulator: in one terminal run npm start in another, npm run tests

In a third terminal run: maestro test e2e

ErikSin commented 3 months ago

We should add a "test" script in the package json that runs the maestro code. The script should build and launch and emulator, and then run the maestro commands to run the tests

On that note, the first test should be the starting screen (currently the user has to navigate to the map screen before the tests can pass). If we are going to automate it in a test script we need to be able to run it without having to manipulate the app at first.

ErikSin commented 3 months ago

I also think it would be worth installing and using the typescript wrapper, what do you think?

ErikSin commented 3 months ago

It also looks like Maestro has a StartDevice command? Im not sure of the inner working, but is it possible to use that to start the device, wait for it to boot up, then start running the rest of the tests?

cimigree commented 3 months ago

I also think it would be worth installing and using the typescript wrapper, what do you think?

I am not super enthusiastic about it tbh. As, 1. it has only been downloaded 246 times and that was a year ago and it hasn't been touched in a year. I worry that it won't be maintained.

  1. It adds a layer of complication to our testing process. Before testing is done, the ts needs to be compiled to yaml, which is adding another layer to get to the automation of the tests we want for CI and in general.
cimigree commented 3 months ago

It also looks like Maestro has a StartDevice command? Im not sure of the inner working, but is it possible to use that to start the device, wait for it to boot up, then start running the rest of the tests?

The command starts a device but it does not build our app, so we would still need to do npm run android (or the equivalent) anyway to build and start our app, but that command also builds and starts an emulator, so it is unnecessary as far as I can tell.

cimigree commented 3 months ago

We should add a "test" script in the package json that runs the maestro code. The script should build and launch and emulator, and then run the maestro commands to run the tests

I have spent a bit more than the requested timeboxed hour to do this and couldn't figure it out. I have asked in the Maestro slack channel and will see what they say. On hold for now. Sorry.

cimigree commented 3 months ago

We should also add an e2e testing doc (in the docs folder) that documents how you run a test, links to maestro documentation, and explains any architectural decisions that were made in regards to maestro

OK this has been attempted.

cimigree commented 3 months ago

On that note, the first test should be the starting screen (currently the user has to navigate to the map screen before the tests can pass). If we are going to automate it in a test script we need to be able to run it without having to manipulate the app at first.

Ok I have done this but I had to remove the gps pill test because you need to do app setup first (device name) before doing the gps pill test and adding that is out of scope for this PR