Problems with Issue Tracker

Hi, i’m trying to complete Issue Tracker project.
Replit: https://replit.com/@SamueleGirgenti/issue-tracker

My solution seems to be correct, but I can’t pass this test:

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 }.

But, if i try manually, PUT requests work correctly. What i’m doing wrong? How can I see what this test exactly checks, in order to debug it?

The browser console says:

Error: expected 1617357672023 to be above 1617357672023

It seems to be a timestamp, but I don’t understand what it is referring to

Hello there,

Here is the test:

async (getUserInput) => {
  try {
    let initialData = {
      issue_title: 'Issue to be Updated',
      issue_text: 'Functional Test - Put target',
      created_by: 'fCC'
    };
    const url = getUserInput('url') + '/api/issues/fcc-project';
    const itemToUpdate = await $.post(url, initialData);
    const updateSucccess = await $.ajax({
      url: url,
      type: 'PUT',
      data: { _id: itemToUpdate._id, issue_text: 'New Issue Text' }
    });
    assert.isObject(updateSucccess);
    assert.deepEqual(updateSucccess, {
      result: 'successfully updated',
      _id: itemToUpdate._id
    });
    const getUpdatedId = await $.get(url + '?_id=' + itemToUpdate._id);
    assert.isArray(getUpdatedId);
    assert.isObject(getUpdatedId[0]);
    assert.isAbove(
      Date.parse(getUpdatedId[0].updated_on),
      Date.parse(getUpdatedId[0].created_on)
    );
  } catch (err) {
    throw new Error(err.responseText || err.message);
  }
};

Specifically, it appears you are not updating the updated_on property.

Hope this helps

1 Like

Thanks, it was useful. This test does a PUT request and then a GET, filtering by _id. This was the problem, my GET route had problems in handling filters by _id. Now it works :wink:

1 Like

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