cuttle icon indicating copy to clipboard operation
cuttle copied to clipboard

Feat/game list on socket reconnect

Open Mang0codes opened this issue 1 year ago • 9 comments

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.

Mang0codes avatar Oct 04 '24 08:10 Mang0codes

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

Haviles04 avatar Oct 05 '24 13:10 Haviles04

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?

Mang0codes avatar Oct 05 '24 13:10 Mang0codes

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?

Haviles04 avatar Oct 05 '24 20:10 Haviles04

@Mang0codes I think it's sufficient to change the failing assertion to make sure there are no games in the list

Haviles04 avatar Oct 16 '24 22:10 Haviles04

@Mang0codes I think it's sufficient to change the failing assertion to make sure there are no games in the list

Screenshot 2024-10-18 213540 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

Mang0codes avatar Oct 18 '24 16:10 Mang0codes

@Haviles04 Can you please review the changes. I think I'm still missing something

Mang0codes avatar Oct 19 '24 14:10 Mang0codes

In the failing test case, I think we can likely remove lines 299-302 and replace them with a copy of line 307

Haviles04 avatar Oct 28 '24 20:10 Haviles04

@Mang0codes are you still interested in working on this?

Haviles04 avatar Nov 26 '24 22:11 Haviles04

@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

Mang0codes avatar Nov 27 '24 15:11 Mang0codes

@Haviles04 could you please review this?

Mang0codes avatar Jul 01 '25 15:07 Mang0codes

This LGTM to me, can we add a test? If you need help with it you can reach out to me on Discord :)

Haviles04 avatar Jul 01 '25 19:07 Haviles04

@Mang0codes a basic idea for a test here would be:

  1. sign up and go to the home page
  2. disconnect the player's socket
  3. sign up as an 'opponent'
  4. create a game as an opponent
  5. reconnect the player socket
  6. 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 avatar Jul 07 '25 12:07 itsalaidbacklife

@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 😅

Mang0codes avatar Jul 18 '25 14:07 Mang0codes