WEBVTT

00:03.730 --> 00:04.630
Hey, did everyone.

00:04.720 --> 00:05.350
They share?

00:05.350 --> 00:07.420
And I know this video is getting too long.

00:07.420 --> 00:10.000
In fact, this entire situation is getting too long.

00:10.000 --> 00:12.400
But I wanted to give you a different aspect of the things.

00:12.400 --> 00:17.650
And don't worry, after this particular controller, we won't be spending this much of time in handling

00:17.650 --> 00:18.490
these kinds of issues.

00:18.490 --> 00:20.350
We'll have a better plan and strategy.

00:20.350 --> 00:24.310
But right now, the important thing is we want to test out that whether our images are getting uploaded

00:24.310 --> 00:24.990
or not.

00:25.000 --> 00:28.780
So for this, let me just fire up my sublime text.

00:28.780 --> 00:31.900
So I'm going to go ahead and open up my sublime text.

00:31.920 --> 00:32.830
Where is it?

00:33.100 --> 00:33.760
There we go.

00:34.270 --> 00:35.920
So this is my sublime text again.

00:35.920 --> 00:40.450
Feel free to open up any of the code data and I'll just drag and drop this forms and images.

00:40.450 --> 00:42.700
The one which we have worked already in the past.

00:42.700 --> 00:46.030
In case you noticed, we have this aegis installed in this one.

00:46.030 --> 00:49.840
So what we're going to do is we're going to install edges onto this one as well.

00:49.840 --> 00:56.560
So NPM install aegis in case you know about that, which you should be that EEGs will help us to actually

00:56.560 --> 00:57.880
work on with the things.

00:58.000 --> 01:03.160
So we're going to go ahead and say NPM, run dev here and let's borrow in some of the code.

01:03.160 --> 01:08.320
From the views of the Aegis, especially the post form, we're going to go ahead and copy entirety of

01:08.320 --> 01:08.860
the things.

01:08.860 --> 01:13.300
Again, we'll be doing the same things up here that onto the home root of this one.

01:13.300 --> 01:16.300
Let me close all of these routes, all of these folders.

01:16.660 --> 01:19.810
And in here we're going to go ahead and create views.

01:20.440 --> 01:23.770
And inside these views, we are going to go ahead and create a new file.

01:23.770 --> 01:28.390
We're going to call this one assign up test dot G's, of course.

01:28.570 --> 01:29.560
And there we go.

01:30.040 --> 01:31.330
Now we have this template.

01:31.330 --> 01:33.040
All good up and running and my bad.

01:33.040 --> 01:36.370
It's not sign up test or geez, it should be HTML.

01:36.370 --> 01:38.380
So let me go ahead and rename this.

01:40.010 --> 01:40.990
And there we go.

01:41.000 --> 01:42.290
It is HTML.

01:42.320 --> 01:42.860
There we go.

01:42.860 --> 01:44.510
So now it is all good and okay.

01:44.540 --> 01:45.620
Now a couple of things.

01:45.620 --> 01:48.680
Very interestingly, this is a post form, so make sure the method is post.

01:48.680 --> 01:51.680
Since we have copied this, the encryption type is multipart form data.

01:51.680 --> 01:54.950
This is also important and we have this sample file up here.

01:54.950 --> 01:56.600
So this needs to be changed as well.

01:56.750 --> 02:01.580
A little bit more of the configuration needs to be changed in case you remember in the index or JS.

02:01.580 --> 02:04.220
We now need to set this as edges.

02:04.220 --> 02:08.990
So we're going to go ahead and copy this that now the view engine that we are having is the edges.

02:09.020 --> 02:10.100
That's all it takes.

02:10.100 --> 02:15.350
So let's go up into JS and this is basically just a temp check.

02:15.350 --> 02:21.830
So we're going to go ahead and mention that this is just a temp check and we are having this IGs up

02:21.830 --> 02:23.300
and running now.

02:23.300 --> 02:27.890
We need to create a new route which actually can serve this set signup test.

02:27.890 --> 02:34.940
So we're going to go into the into the route and we have this home route and let's go ahead and get

02:34.940 --> 02:37.550
a simple get route, which will be handled by all of that.

02:37.820 --> 02:38.660
But you know what?

02:38.660 --> 02:39.800
This is too much.

02:39.800 --> 02:41.150
This is just a simple test.

02:41.150 --> 02:43.280
So I'm going to go ahead and write a test up here.

02:43.280 --> 02:48.800
So after the middleware, I'm going to go ahead and simply write a simple get here, since this is any

02:48.800 --> 02:49.820
way is just a test route.

02:49.820 --> 02:51.920
So we're going to call this one as sign up test.

02:52.610 --> 02:56.630
And again, this needs to go inside the code just like that.

02:57.710 --> 03:00.710
And after that, we need to have a simple request.

03:02.330 --> 03:04.660
Request response.

03:04.670 --> 03:05.870
And there we go.

03:06.290 --> 03:09.380
And here we're going to say rez, dot, render.

03:11.340 --> 03:12.210
Come on.

03:13.170 --> 03:13.890
Dot render.

03:13.890 --> 03:20.550
And inside that we're going to say that, hey, what we want to render is simply this sign up test.

03:21.470 --> 03:22.640
Dot HTML.

03:24.200 --> 03:24.530
Okay.

03:24.530 --> 03:28.940
Let's go ahead and quickly verify that all of the things are just exactly same as we have worked on.

03:28.940 --> 03:32.480
So this is all and let me go ahead, scroll there.

03:32.480 --> 03:33.710
And again, this is all.

03:33.710 --> 03:35.510
And again, we don't need to write the HTML.

03:35.540 --> 03:36.200
My bad.

03:36.830 --> 03:38.240
It automatically picks that up.

03:38.240 --> 03:40.160
So sign up test is all what we got.

03:40.160 --> 03:45.710
So if I go ahead and now visit the sign up test route, I should be in theory be able to get this form.

03:45.980 --> 03:52.130
So let's go ahead and move on to the local host, 4000 slash sign up test and it says, hey, failed

03:52.130 --> 03:54.380
to render the sign of test in views directory.

03:54.380 --> 03:59.240
So it looks like some of the render method is not working out.

04:00.660 --> 04:05.760
After spending a lot of time with the screen, I realized that this is not even XHTML.

04:05.790 --> 04:06.700
Come on, what am I doing?

04:06.720 --> 04:08.070
Looks like it's too late.

04:08.100 --> 04:09.630
It's just 1:00 in the night.

04:09.630 --> 04:12.090
But again, it looks like I need to figure it out.

04:12.090 --> 04:12.690
Come on.

04:12.690 --> 04:16.290
So it is eggs, and now it should be all working.

04:16.290 --> 04:18.450
Finally, let's go ahead and hit a reload up here.

04:18.810 --> 04:20.100
And there we go.

04:20.100 --> 04:22.060
We are able to load this get form.

04:22.080 --> 04:26.820
At least it's taking a little while to actually load all of this.

04:26.820 --> 04:29.400
I don't know why, what's the reason for that?

04:29.520 --> 04:34.950
But at least now we are getting the sign up test request and the form is actually loading up nicely.

04:35.070 --> 04:35.380
Okay.

04:35.400 --> 04:40.740
A couple of things now we need to do is the first thing is now we need to go ahead and worry about where

04:40.740 --> 04:42.210
this request is going in.

04:42.210 --> 04:44.430
So let's go ahead and open this up.

04:45.000 --> 04:50.820
Previously we were able to see that this is our form and the request was going on to directly on slash

04:50.820 --> 04:51.330
my post.

04:51.330 --> 04:58.200
Now the localhost column 4000 will be added up, but not the slash API slash v one.

04:58.200 --> 05:02.790
So this we need to add and then the post that we are going to go up is sign up.

05:02.790 --> 05:05.790
So this is the basic route that we need to go there.

05:06.390 --> 05:11.520
So the name is going up as first name, so we don't want that input.

05:11.520 --> 05:14.730
So I'll just have this one a little bit bigger.

05:14.730 --> 05:15.450
There we go.

05:15.780 --> 05:22.410
So this one is actually just the name and we can actually remove this part.

05:23.180 --> 05:25.220
So that I can actually place this one.

05:25.370 --> 05:28.280
So this is just basically the name that is going in.

05:28.370 --> 05:30.190
I'll copy this one up here.

05:30.200 --> 05:32.240
So copy this part.

05:32.780 --> 05:34.070
Paste that again.

05:34.790 --> 05:37.790
This is for email.

05:38.150 --> 05:39.380
This is actually for name.

05:39.380 --> 05:40.340
All the way all.

05:40.520 --> 05:41.900
So this is name.

05:43.030 --> 05:43.690
Copy that.

05:43.690 --> 05:44.500
Paste this one.

05:44.500 --> 05:47.200
As for name and this one.

05:47.290 --> 05:50.920
We don't need this diva or anything, so we're going to just go ahead and remove that part.

05:50.920 --> 05:51.640
We don't need this.

05:51.640 --> 05:57.010
Dave So yes, again, just the basic HTML and playing around with that, I'll copy this email.

05:57.010 --> 06:02.320
This name is going for email and this one is email also.

06:02.470 --> 06:04.030
This one is also email.

06:04.240 --> 06:08.260
So we have name, email and another compulsory field is password.

06:08.260 --> 06:09.580
So we're going to be working with that.

06:09.580 --> 06:15.310
So let's go ahead and say pass word and this is copy password.

06:15.670 --> 06:17.470
This is for password field.

06:17.500 --> 06:19.930
This should be a type password as well.

06:20.230 --> 06:21.610
ID should be password.

06:21.610 --> 06:24.100
Now importantly, this is for the file.

06:24.100 --> 06:31.120
So we need to check out or we need to ask our frontend, our backend engineer that what you are actually

06:31.120 --> 06:31.870
calling this one.

06:31.870 --> 06:37.480
So this is going to say that hey, I'm expecting a file which should name as a photo, so we need to

06:37.480 --> 06:38.290
make that as photo.

06:38.290 --> 06:41.080
So let's go into the IGs and call this one s photo.

06:41.140 --> 06:45.970
So this is for photo and we need to copy this.

06:45.970 --> 06:48.270
This is a type file name is photo.

06:48.320 --> 06:49.720
Name is the most important thing.

06:49.720 --> 06:51.700
Rest, you can just keep it whatever you like.

06:51.700 --> 06:56.920
But this name is the most important property and this should be all up and running and all.

06:56.920 --> 06:57.220
Good.

06:57.220 --> 06:58.990
Now let's go ahead and save this one.

06:59.020 --> 07:01.300
Go back up here, hit a quick reload.

07:01.300 --> 07:06.520
And now hopefully this is going to allow us to test at least our route that how this is going on further

07:06.520 --> 07:06.790
down.

07:06.790 --> 07:13.240
I would like to bring up my MongoDB campus, hit a refresh on this that this is all what we got.

07:13.540 --> 07:17.470
One is already being injected, but now we want to inject the two as well.

07:17.530 --> 07:27.670
So the first name is to email is to add the rate ae dev and the email is this is password.

07:27.670 --> 07:32.770
So actually one, two, three, four, five, six and let's go ahead and choose a file.

07:33.780 --> 07:36.930
I'm going to go ahead and choose the same CP file.

07:36.960 --> 07:37.740
Copy that.

07:37.740 --> 07:39.480
And let's go ahead and hit the submit.

07:39.870 --> 07:44.610
And now it says the path must be a type string received an instance of an object.

07:44.610 --> 07:50.700
So notice here we did the same classic mistake that we talked about in here that, hey, we were actually

07:50.760 --> 07:56.700
let me just show you that at the time of posting the data, we were uploading just the file, which

07:56.700 --> 07:57.570
is not a correct thing.

07:57.570 --> 07:59.670
So we need to give this STEM file path as well.

07:59.670 --> 08:02.550
So this is exactly why testing is necessary.

08:02.550 --> 08:07.500
Let's go back up onto the code editor and this user controller.

08:07.500 --> 08:13.380
So this time we are saying a file dot and we will be saying temp a file path.

08:14.700 --> 08:16.800
So this is all good.

08:16.800 --> 08:18.150
Now let's go ahead and save this.

08:18.150 --> 08:21.390
They should restart the things and let's go back up here.

08:21.720 --> 08:22.800
Back up here.

08:22.800 --> 08:23.880
Hit a reload.

08:23.880 --> 08:24.570
There we go.

08:24.570 --> 08:26.040
No, please don't save anything.

08:26.040 --> 08:28.020
Let's go ahead and try it one more time too.

08:28.020 --> 08:36.720
And this should be to add the rate ae dev and the password is one, two, three, four, five, six.

08:36.900 --> 08:41.640
Let's again choose the file and let's use the classic go.

08:41.670 --> 08:46.670
It's a meanwhile let's go ahead and hit the submit and now this time it's going so cloud.

08:46.800 --> 08:47.490
It takes time.

08:47.490 --> 08:53.340
Our front end engineer can actually work on showing a logo or some kind of a something like that.

08:53.340 --> 08:57.000
So notice here everything is token and everything is coming back nicely.

08:57.000 --> 09:02.610
In fact, our user interestingly, let's go ahead and check out the database now that if I go ahead

09:02.610 --> 09:05.700
and refresh the database, now we have the photo, which is an object.

09:05.700 --> 09:10.290
So notice we are getting the ID, we are getting the URL, we are getting the password.

09:10.470 --> 09:12.840
And this is all going nicely.

09:12.870 --> 09:18.320
Again, we did all of this to make sure that we are properly testing because to be honest, this temp

09:18.330 --> 09:20.340
file path was completely out.

09:20.340 --> 09:22.140
I didn't expected this to be an error.

09:22.140 --> 09:26.820
But again, quickly realize because we have done this in the past, so experience always counts and

09:26.820 --> 09:29.670
also there is no way of testing these things in the postman.

09:29.670 --> 09:29.850
Yes.

09:29.850 --> 09:33.960
There are some some ways of testing this with the postman, but they are really, really tricky.

09:34.080 --> 09:36.120
So we won't be testing it this much.

09:36.120 --> 09:38.730
In fact, I will be kind of a rewriting this.

09:39.120 --> 09:39.870
It makes sense.

09:39.870 --> 09:46.020
I won't be doing it, but it obviously makes sense if I rewrite or refactor this code a little bit that

09:46.020 --> 09:50.250
instead of checking the files directly, I would be checking the files and giving the error message

09:50.250 --> 09:52.620
that if the requests are filed, that photo is not there.

09:52.650 --> 09:54.030
This is your error message.

09:54.030 --> 09:55.830
Please give me the photo as well.

09:55.860 --> 09:58.470
Otherwise, just go ahead and use this one again.

09:58.470 --> 10:00.930
You get the idea of what I'm trying to say.

10:00.930 --> 10:04.650
Again, the code refactoring depends on you and how much time you have.

10:04.680 --> 10:09.540
The whole goal for me in this video was to show you that, yes, there are other ways of testing the

10:09.540 --> 10:10.650
application as well.

10:10.650 --> 10:12.270
In fact, this is not the only way.

10:12.270 --> 10:16.020
There is a way of handling these things in the documentation as well.

10:16.200 --> 10:18.450
Remember the swagger that is also one of the way.

10:18.450 --> 10:23.910
But again, this is all working fine and we'll be just shutting down this entire method just right here.

10:23.910 --> 10:27.510
Let's go ahead and move on further down the road because it's being too much.

10:27.510 --> 10:29.400
Let's go ahead and catch up in the next video.
