Jorge-Lopes / KREAd

KREAd is an application that uses and implements composable NFTs on Agoric, the application allows users to customize their own characters by equipping and unequipping items.
Apache License 2.0
0 stars 0 forks source link

Frontend: e2e tests #7

Open Jorge-Lopes opened 6 months ago

Jorge-Lopes commented 6 months ago

Frameworks used

To build the e2e test the following frameworks were used

Guide to execute the e2e test locally:

  1. Checkout to branch jorge/e2e-ci-workflow and change to frontend directory

  2. Run container with latest a3p image

yarn start:docker
  1. Update cypress.env.json with users wallet address
yarn docker:print-user1-key
yarn docker:print-user2-key
  1. Fund user2 account, if IST balance is bellow the necessary
yarn docker:fund-user2
  1. Launch Kread UI
yarn dev
  1. Run synpress test
PRIVATE_KEY="b3209e3771c0d97434ed4f9d6c223a442d1241968fd1f1b0e03e755b92339069"  yarn test:e2e
  1. Run synpress test in debug mode (OPTIONAL)
DEBUG=synpress:* SYNDEBUG=true PRIVATE_KEY="b3209e3771c0d97434ed4f9d6c223a442d1241968fd1f1b0e03e755b92339069"  yarn test:e2e --noExit

CI workflow

A github action was created to automate the execution of the UI e2e test when a commit is pushed. See the configuration file e2e.yml for more detail

Note: the event currently set to trigger the this action is susceptible to be updated in the future.

Test coverage

The testing coverage of the UI e2e test follows the same happy path has the one established on the smoke tests. As the following:

Note: the equip feature was not including because of the issue #10

Problems and solutions

Connect to agoric localhost

The first challenge we faced was to set the Agoric localhost as the selectedChains at the process of setup a wallet. If that was not successfully made, the KREAd app would not be able to work as intended. To solve this issue, a test is executed prior to setting up the wallet , should connect to Agoric local chain, which purpose is to provide the Agoric local chain configuration to the experimentalSuggestChain feature of the Keplr extension.

Incorrect account sequence

While trying to build the test case should unequip Item we were facing a problem where the Unequip button was being pressed and the transaction being approved on the Keplr extension, but the offer result was not being returned and the state of the Items were kept the same.

After trying different approaches, it came clear to use that we would need to wait until the transaction was processed and included in a block before proceding to the next item.

With this in mind, we built two function that allow us to retrieve the current block height getBlockHeight(), and a second function that would force to wait until a predefined number of blocks have been published before resuming the test checkBlockHeight().

anilhelvaci commented 6 months ago

Notes

Command to get the private key of user1

docker exec e2e-agd-1 bash -c "yes | agd keys export --unsafe --unarmored-hex --keyring-backend=test user1"
anilhelvaci commented 5 months ago

Feedback

I can confirm that the tests are running as expected in my machine as well. What I think can be improved in this process;

None of the above is necessary, just a mere improvement.

Jorge-Lopes commented 5 months ago

Feedback

I can confirm that the tests are running as expected in my machine as well. What I think can be improved in this process;

  • Instead of manually getting the user1 and user2 private keys, maybe we can write a script that gets these values and write them to a file. Then consume these values from that file in the test spec.
  • provision-user2 is I believe misleading maybe we can convert it to fund-user2
  • Instead of statically funding user2 and not checking user1 at all, have another script that checks the balances of user1 and user2 then fund them if necessary

None of the above is necessary, just a mere improvement.

Thank you for the feedback. The suggested improvements were implemented and the documentation above was updated accordingly.