Issue Tracker - Not able to pass tests #7 and #9

I am doing the issue tracker project of the sixth certification (Quality Assurance).

I have spent a lot of time to make the two tests pass :

#7 : You can send a PUT request to /api/issues/{projectname} with an _id and one or more fields to update. On success, the updated_on field should be updated, and returned should be { result: 'successfully updated', '_id': _id }

and

#9 : When the PUT request sent to /api/issues/{projectname} does not include update fields, the return value is { error: 'no update field(s) sent', '_id': _id } . On any other error, the return value is { error: 'could not update', '_id': _id }

I have tried every possible solution and to cover all the requirement but with no result.

This is a link to my replit : https://C6-P2.ali-b-123.repl.co

Update: I have succeeded to make the test #9 pass, I just have now the test #7

Any help please would be appreciated.

That link took me to your page, but is there a way to also view the code? If not, could you share the revelate code, like a github or something?

1 Like

This is a link to the code

“C6-P2 - Replit”

I have succeeded to make to test #9 pass, I just have the test #7 now

Well, without diving into the code, one thing I noticed just playing with the API is that when I try to update a single field, it updates all other fields to blank.

Example: If I perform a put to api/issues/kinome79 with an _id of one of my issues, and only the assigned_to field in the request… it updates the assigned_to properly, but then makes all other fields that I didn’t supply blank. I believe its not supposed to edit fields not supplied in the request.

Fixing that bug will probably help with not failing the PUT request test.

Actually I intended to make all other fields blank in the case that you mentioned, because when I tried to update a single field in the freecodecamp’s issue tracker, the same also happens.

But anyway, I will try to get rid of that and see the results…

Thank you for your participation.

I got rid of that and the test is still not passing

Yeah, that was confusing to me too, but the reason it happens when using the example gui is because the gui actually sends the request with all fields, but the ones you don’t fill in it sends as empty strings… that’s not the same as not sending the fields at all. I’m not at a computer at the moment, but will look at your code again soon.

1 Like

Hum, functionality seems to be OK now, but test still not passing. The only thing I see that might be an issue is that on success you seem to be returning the _id as an ID Object instead of a string… not sure if that would matter. Your other DELETE and POST methods you actually return a string, but for PUT you’re returning an IOObject.

If that’s not it, I’m not sure the cause… hopefully someone else has time to take a look.

1 Like

I have replaced idAsObject by req.body._id but the test still fails, thank you so much anyway.

I have finally found the error, when saving the “created_on” and the “updated_on” dates, if the day, hour, minute or second is less than 10, for example 9, it was written in the database as 9 instead of 09. This was causing a problem later, when freecodecamp’s tests make a get request according to the _id, and try to check if the updated_on date is bigger than created_on, using Assert.isAbove(Date.parse(updated_on_string), Date.parse(created_on_string)), which was causing the error “expected NaN to be above NaN”.

Thank you so much for your time.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.