serokell / coffer

Multi-backend password store with multiple frontends
4 stars 2 forks source link

Fix tests in Web API #96

Closed DK318 closed 2 years ago

DK318 commented 2 years ago

Blocked by #37

Clarification and motivation

After rebases mocha tests stopped working. We should reanimate them.

Acceptance criteria

mocha tests are working and passing.

dcastro commented 2 years ago

I was thinking, since the tests need a bit of rework anyway (to make them pass + make them independent from each other + write missing tests), maybe we could take the opportunity to rewrite them in Haskell.

The main reason why they were written in javascript in the first place was so that they would serve as documentation for whoever writes the frontend. However:

  1. This makes maintaining it (a bit) harder.
  2. Enabling the tests in the pipeline will also be a bit more troublesome.
  3. The frontend will (probably) be written in Purescript, so it's not like having the api's tests in javascript helps that much.

I think we could still achieve our goal (documenting the web API) if we re-write the tests in Haskell, without using a servant client and without relying on coffer's data types/encoders/decoders. We could just write json literals in the tests (e.g. with aesonQQ), manually add the headers, etc.

What do you think @DK318 ?

dcastro commented 2 years ago

Plus, the setup/cleanup steps of spinning up 2 web servers before running the tests & killing them when the tests are done would be a lot easier as well.

DK318 commented 2 years ago

Hmm. I think it really would be better if tests were written in Haskell. Personally, I don't know mocha at all :smile:

dcastro commented 2 years ago

Cool, I'll close a few test-related issues and open a new one ^^