`npm test` to confirm we did not break anything
test site: https://cashtab-local-dev.netlify.app
Added debug log on the test site so you can see the msgs that come in. List a token. Observe that the OrderBook updates itself and the wsMsg is in the dev console.
This is quite a complicated piece of logic to test in react testing library. We could accomplish it with sinon and spies. However the tested behavior (for now) is very simple. If it gets more complex, perhaps OrderBook should be exported and tested by `ecash-agora`; may need regtest integration to get a "good" websocket test.
Here is what I did
1. Navigate to test site
2. Hard refresh to make sure you are on this version (ctrl + shift + r in brave/chrome)
3. Go to a token page
4. Buy or list that token, notice in the dev console that the offers are refreshed. Confirm the offers are refreshed by checking the offer your action changed.
5. Manually enter another tokenId in the nav bar. Check the dev console to confirm we are closing the ws for this tokenId and loading one for a new tokenId. Also getting offers for the new tokenId.
6. Navigate to the Agora screen. In the dev console, note that the whitelisted OrderBooks get a websocket.
7. Buy some XECX or Star Crystal. In the dev console see the orderbooks refresh. Confirm the offer you bought has been updated.
8. Toggle to Manage Offers. Confirm websockets are presesnt.
9. Load all offers. In the dev console, see that all offers are loaded with websocket disabled.
It's quite a test plan and a bit manual. But testing websocket actions without actually firing transactions quickly becomes an exercise in testing the testing libraries. imo the solution is to not make the websocket more complicated in Cashtab. If we need more optimized orderbook websockets (updating indivdual offers as they are partially accepted, removing individual offers as they are canceled) -- then this component should get its own tested library. That way we could use regtest on it with ABC monorepo CI, like we do with ecash-lib and ecash-agora.