Feat/game list on socket reconnect
Issue number
Relevant issue number
- Resolves #1012
Please check the following
- [ ] Do the tests still pass? (see Run the Tests)
- [ ] Is the code formatted properly? (see Linting (Formatting))
- For New Features:
- [ ] Have tests been added to cover any new features or fixes?
- [ ] Has the documentation been updated accordingly?
Please describe additional details for testing this change
Changes Made: Updated src/plugins/sockets/connectivityEvents.js to handle the case when the route is ROUTE_NAME_HOME. If the user is on the homepage when the socket reconnects, the gameListStore.requestGameList() method is called to retrieve the most recent list of available games. Imported and instantiated the gameListStore in connectivityEvents.js to make this functionality available.
Nice work! This looks good
As far as the failing test it looks like the test will need a little bit of a re-work as well, considering we're looking for a outdated gameList that is (now) refreshed and hiding closed games upon reconnection of the socket
If you have any questions you can reach out in the #code channel on our Discord
Nice work! This looks good
As far as the failing test it looks like the test will need a little bit of a re-work as well, considering we're looking for a outdated gameList that is (now) refreshed and hiding closed games upon reconnection of the socket
If you have any questions you can reach out in the #code channel on our Discord
Thanks for reviewing. Can you please elaborate what I can do now?
Nice work! This looks good As far as the failing test it looks like the test will need a little bit of a re-work as well, considering we're looking for a outdated gameList that is (now) refreshed and hiding closed games upon reconnection of the socket If you have any questions you can reach out in the #code channel on our Discord
Thanks for reviewing. Can you please elaborate what I can do now?
When we wrote this test we checked that it was not possible to join a outdated game when the socket refreshed, after your code, the list refreshes on socket reconnect and the outdated games are no longer shown and can't be selected to join. I think it might be sufficient to make sure that there is no games in the list now. @itsalaidbacklife, thoughts?
@Mang0codes I think it's sufficient to change the failing assertion to make sure there are no games in the list
@Mang0codes I think it's sufficient to change the failing assertion to make sure there are no games in the list
Did you mean like this?? Before it was:
cy.get('[data-cy=game-list-item]').should('have.length', 1);
Yea I think that would work, making sure we check length = 0
@Haviles04 Can you please review the changes. I think I'm still missing something
In the failing test case, I think we can likely remove lines 299-302 and replace them with a copy of line 307
@Mang0codes are you still interested in working on this?
@Mang0codes are you still interested in working on this?
I don't have much experience with writing tests... You can assign this to someone else
@Haviles04 could you please review this?
This LGTM to me, can we add a test? If you need help with it you can reach out to me on Discord :)
@Mang0codes a basic idea for a test here would be:
- sign up and go to the home page
- disconnect the player's socket
- sign up as an 'opponent'
- create a game as an opponent
- reconnect the player socket
- Assert that the newly created game shows up.
The test could be called it('refreshes the game list when the socket reconnects') and it could live in tests/e2e/specs/out-of-game/home.spec.js.
The trick for disconnecting the player socket is the following snippet
cy.window()
.its('cuttle.authStore')
.then((store) => store.disconnectSocket());
(which you can see used frequently in reconnecting.spec.js). The rest should be a matter of combinging exisiting custom commands. Reach out here or on discord if you have any questions and we'll be happy to help
@itsalaidbacklife Thanks! I’m glad it’s working, I was actually about to commit the tests for it today, but saw you’d already written them 😅