okTurtles / group-income

A decentralized and private (end-to-end encrypted) financial safety net for you and your friends.
https://groupincome.org
GNU Affero General Public License v3.0
330 stars 43 forks source link

Heisenbug in `group-chat.spec.js` #2256

Closed taoeffect closed 2 hours ago

taoeffect commented 1 month ago

Problem

https://github.com/user-attachments/assets/772eebd1-dacc-44e3-95ee-8a99ed0f2a48

Test failure info:

    1) user3 joins the Dreamers group and general channel again and logout

  15 passing (2m)
  1 pending
  1 failing

  1) Group Chat Basic Features (Create & Join & Leave & Close)
       user3 joins the Dreamers group and general channel again and logout:
     AssertionError: Timed out retrying after 30000ms: expected '<span.c-twrapper>' to contain 'user3-14328999999997904524207'
      at Context.eval (http://127.0.0.1:8000/__cypress/tests?p=test/cypress/support/index.js:2073:65)
  Console Logs:

Solution

Uncomment that out and push a PR to verify the tests are still failing because of that line.

Figure out the problem and fix.

taoeffect commented 1 month ago

Update: This problem is still happening, because giAcceptGroupInvite eventually calls giCheckIfJoinedChatroom via giLogin => cy.giCheckIfJoinedGeneralChatroom(username) => cy.giCheckIfJoinedChatroom(CHATROOM_GENERAL_NAME, username).

And we have this call in user3 joins the ${groupName1} group and ${CHATROOM_GENERAL_NAME} channel again and logout:

    cy.giAcceptGroupInvite(invitationLinkAnyone, {
      username: user3,
      groupName: groupName1,
      existingMemberUsername: user1,
      shouldLogoutAfter: false,
      isLoggedIn: true,
      bypassUI: true
    })

And in giCheckIfJoinedChatroom we have this call:

    if (inviter) {
      cy.get('.c-message:last-child .c-who > span:first-child').should('contain', inviter)
    }

Which seems to be where the problem is happening.

taoeffect commented 1 month ago

This shows a comparison of a passing (left) and failing (right) build, suggesting that either the last two messages (u2 and u3) are reversed, or the u3 message is missing, or... something even crazier is happening.

Screenshot 2024-07-26 at 6 56 45 PM

taoeffect commented 1 month ago

Because this heisenbug is such a persistent problem, I've commented out the test as a temporary measure until someone is able to figure it out:

  cy.getByDT('conversationWrapper').within(($el) => {
    if (inviter) {
      // TODO: fix this heisenbug here: https://github.com/okTurtles/group-income/issues/2256
      // cy.get('.c-message:last-child .c-who > span:first-child').scrollIntoView()
      // cy.get('.c-message:last-child .c-who > span:first-child').should('contain', inviter)
    }
taoeffect commented 1 month ago

It turns out commenting that out in #2280 just leads to a different, related heisenbug!

Screenshot 2024-08-03 at 11 06 55 AM

I attempted a fix, which didn't work, so now I've pushed a commit to #2280 that gives up completely on performing these checks:

  // failed attempt to fix heisenbug: https://github.com/okTurtles/group-income/issues/2256
  // if (inviter) {
  //   cy.get('[data-test="conversationWrapper"] .c-message:last-child .c-who > span:first-child').should('contain', inviter)
  // }
  // const message = selfJoin ? `Joined ${channelName}` : `Added a member to ${channelName}: ${invitee}`
  // cy.get('[data-test="conversationWrapper"] .c-message:last-child .c-notification').should('contain', message)

  // original code follows:
  // cy.getByDT('conversationWrapper').within(($el) => {
  //   if (inviter) {
  //     // TODO: fix heisenbug: https://github.com/okTurtles/group-income/issues/2256
  //     // cy.get('.c-message:last-child .c-who > span:first-child').scrollIntoView()
  //     // cy.get('.c-message:last-child .c-who > span:first-child').should('contain', inviter)
  //   }
  //   const message = selfJoin ? `Joined ${channelName}` : `Added a member to ${channelName}: ${invitee}`
  //   cy.get('.c-message:last-child .c-notification').should('contain', message)
  // })
taoeffect commented 1 month ago

Possibly related heisenbug that appears when all of that code is commented out in this build:

Screenshot 2024-08-05 at 10 48 08 AM

Here's the video for this one:

https://github.com/user-attachments/assets/49b45c88-afb4-4921-8d8d-25051d4dda31

Which I got by repeatedly running the test locally with:

while npx cypress run -c 'baseUrl=http://localhost:8000' --spec "test/cypress/integration/group-chat.spec.js"; do :; done
taoeffect commented 1 month ago

And yet a different one, also in group-chat, this time with video from Cypress Dashboard!

Screenshot 2024-08-05 at 7 03 11 PM

taoeffect commented 2 hours ago

Might've been fixed by @corrideat in #2294