Quality Assurance Projects - Issue Tracker

Tell us what’s happening:

I have completed the issue tracker project in Replit.  All of the 14 tests pass when I run the code. When I submitt the code to fcc one of the test fails.
The test which fails is : 
 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 }` .

Folowed after that by:
 // console output
[Error: expected 1710058818000 to be above 1710058818000]
[Error: At least one assertion per test: expected +0 to be at least 1]
I have not pushed the repl back to github  so github is not  the same as the repl and also github reject my attempts to push from Replit. 
Some help with how I can get test to pass would be appreciated.



###Your project link(s)

githubLink: GitHub - PetrosaMan/project-issuetracker: Tracks changes to project issues

code: issue-tracker - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

Quality Assurance Projects - Issue Tracker

Did you use the GitHub desktop app for any of this?

Your updated_on date is the same as the created_on date. I would expect it to be different (so does the tests).

I assume the one assert per test is just from the missing assert in one of your GET tests.

Tests: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/06-quality-assurance/quality-assurance-projects/issue-tracker.md

No, I  I cloned it to replit. I have since fixed up  my link to github and  cloned it  to my desktop from github to vs code.  It passes all 14 tests I wrote.

1 Like

I checked the update date and it does change ok when I use the PUT request with an _id

It didn’t when I checked.

POST response

{
    "issue_title": "Issue to be Updated",
    "issue_text": "Functional Test - Put target",
    "created_on": "2024-03-11T17:26:04.000Z",
    "updated_on": "2024-03-11T17:26:04.000Z",
    "created_by": "fCC",
    "assigned_to": "",
    "open": true,
    "status_text": "",
    "project": "fcc-project",
    "_id": "65ef3eac8866caec6443a5ae",
    "__v": 0
}

GET response after PUT

[
    {
        "_id": "65ef3eac8866caec6443a5ae",
        "issue_title": "Issue to be Updated",
        "issue_text": "New Issue Text",
        "created_on": "2024-03-11T17:26:04.000Z",
        "updated_on": "2024-03-11T17:26:04.000Z",
        "created_by": "fCC",
        "assigned_to": "",
        "open": true,
        "status_text": "",
        "project": "fcc-project",
        "__v": 0
    }
]

But I checked again and it passed one time, then it didn’t the rest of the time.

Also, when that test fails it tells you that the dates are the same. The assert message is from this part of the test.

assert.isAbove(
  Date.parse(getUpdatedId[0].updated_on),
  Date.parse(getUpdatedId[0].created_on)
);

You shouldn’t have to manually create the dates or update them, the Schema/model should be able to handle it. But when I tried using Date.now as the default in the Schema it still failed.

Using timestamps did work when I tested it with your code (let the model handle the dates, do not create or update manually).

https://mongoosejs.com/docs/guide.html#timestamps

Thanks for you response. I added timestamps and all 14 tests are passing (as previousl stated) and I see the time changes when updated as previously but the timestamp is a better option. The problem with the “at least one assert” was a fixed when I added : assert.equal(res.status, 200) to the top section of the GET. All tests now pass and I was able to post as completed. Thank you for your help

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