In this episode, we walk through the entire process of accepting a team invitation, both from a testing and a user experience perspective. First, we start by writing tests to make sure our invitation flow is secure and works as expected. We cover checking that unsigned invite acceptance attempts are blocked, and then move on to the successful flow where invites can be accepted if everything's valid.
You'll see how we validate that an invite token works, that the invite gets deleted after it's accepted, and that the user is properly attached to the team with the right role. We also make sure that the user's current team is set to the one they just got invited to, so everything's smooth for them once they accept.
After covering all that logic with tests, we hop into the browser to try it all out for real. We do a manual end-to-end test using the UI, inviting a user, grabbing the email link, and going through the login/acceptance process. Along the way, we run into a minor issue caused by manually adding users to the database (without setting their current team), and we show how to fix that edge case.
By the end of the episode, you've got a robust invite acceptance flow that deletes used invites, adds users to teams, gives them the correct role, and even switches their current team automatically. Plus, you've seen how to catch and fix some sneaky bugs that might come up in testing vs. real life!