Loading
Current section: HTTP Mocking 5 exercises
Problem

GitHub Sign-In Callback

Loading exercise

Transcript

00:00 With the way that we have our mock set up already, when you go to sign in with GitHub, that will actually sign you in as Cody, because Cody already has an association in the database, a connection with a GitHub user that we have mocked as like our mock login for this GitHub. So if you want to test the thing manually

00:18 that we're going to test here in a moment, then you'll have to come over here to the signup page. Let's pop open our network tab. We'll change this to, yeah, someone else. Any change to that code will do, so that's in your AppUtilsProviders.github.server file under the handle mock action.

00:37 So you change this code, and that will change the user that we're gonna be signing in as for our GitHub action. So where GitHub is sending it back over with the code. Okay, so we clear all this out, and then we come down here, sign up with GitHub, and the API that you're going to be testing

00:57 is right here in this callback where we're calling the auth GitHub callback with a code and some state. And so your job is to make an API call or just like call the loader with a request that has this in the URL. You don't need to worry about the rest of this

01:18 because that's all implementation detail stuff for Remix. Our code doesn't care about that anyway. So it's just this first part of this URL is the piece that we need to construct and make that request. And then we wanna make sure that the response has things correct.

01:35 So there are some cookies that are gonna be set that some of those things will be validating. And then there is a location header that is gonna be set as well. So here it's XRemixRedirect that again is an implementation detail. The actual redirect will be a location header

01:54 that you'll be taking a look at and asserting on. So we've got a couple of things that we're gonna be doing for this first test to just test the onboarding of our GitHub callback. So let's get started.