Please I need help with my Issue tracker app functional tests

Tell us what’s happening:
Describe your issue in detail here.

My Api code so far

![issuetracker|539x490](upload://pCRFxN6HxHavWigQAbpWpOywedh.jpeg)
![issuetracker2|522x500](upload://waAl3bNvVnpYiKvFZiB7uxQLzJB.jpeg)

'use strict';

var expect = require('chai').expect;
let mongodb = require('mongodb');
let mongoose = require('mongoose');
require('dotenv').config();
let ObjectId = require('mongoose').Types.ObjectId;


mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true })
  .then(() => console.log('MongoDB connected...'))
  .catch(err => console.log(err));

module.exports = function(app) {

  let issueSchema = new mongoose.Schema({
    issue_title: { type: String, required: true },
    issue_text: { type: String, required: true },
    created_by: { type: String, required: true },
    assigned_to: String,
    status_text: String,
    open: { type: Boolean, required: true },
    created_on: { type: Date, required: true },
    updated_on: { type: Date, required: true },
    project: String
  })

  let Issue = mongoose.model('Issue', issueSchema)

  app.route('/api/issues/:project')

    .get(function(req, res) {
      let project = req.params.project;
      let filterObject = Object.assign(req.query)
      filterObject['project'] = project
      Issue.find(
        filterObject,
        (error, arrayOfResults) => {
          if (!error && arrayOfResults) {
            return res.json(arrayOfResults)
          }
        }
      )
    })

    .post(function(req, res) {
      let project = req.params.project;
      let resObj = {};
      resObj['_id'] = req.body._id
      resObj['error'] = 'required field(s) missing from request'
      if (!req.body.issue_title || !req.body.issue_text || !req.body.created_by) {
        return res.json({ error: 'required field(s) missing from request' });
      }
      let newIssue = new Issue({
        issue_title: req.body.issue_title,
        issue_text: req.body.issue_text,
        created_by: req.body.created_by,
        assigned_to: req.body.assigned_to || '',
        status_text: req.body.status_text || '',
        open: true,
        created_on: new Date().toUTCString(),
        updated_on: new Date().toUTCString(),
        project: project
      })
      newIssue.save((error, savedIssue) => {
        if (!error && savedIssue) {
          console.log(savedIssue)
          return res.json(savedIssue)
        }
      })

    })

    .put(function(req, res) {
      let project = req.params.project;

      if (!req.body._id) {
        return res.json({ error: 'missing _id' })
      }

      if (!ObjectId.isValid(req.body._id)) {
        if ((String)(new ObjectId(req.body._id)) != req.body._id)
          return res.json({ error: 'invalid _id' })
      }

      let updateObject = {}
      Object.keys(req.body).forEach((key) => {
        if (req.body[key] != '') {
          updateObject[key] = req.body[key]
        }
      })
      if (Object.keys(updateObject).length < 2) {
        return res.json({ error: 'no update field(s) sent' })
      }
      updateObject['updated_on'] = new
        Date().toUTCString()
      Issue.findByIdAndUpdate(
        req.body._id,
        updateObject,
        { new: true },
        (error, updatedIssue) => {
          if (!error && updatedIssue) {
            return res.json({ result: 'successfully updated', _id: req.body._id })
          } else if (!updatedIssue) {
            return res.json({ error: 'could not update', _id: req.body._id })
          }
        }
      )

    })

    .delete(function(req, res) {
      let project = req.params.project;

      if (!ObjectId.isValid(req.body._id)) {
        if ((String)(new ObjectId(req.body._id)) != req.body._id)

          return res.json({ error: 'invalid _id' })
      }

      if (!req.body._id) {
        return res.json({ error: 'missing _id' })
      }
      Issue.findByIdAndRemove(req.body._id, (error, deletedIssue) => {
        if (!error && deletedIssue) {
          res.json({ result: 'successfully deleted', _id: deletedIssue.id })
        } else if (!deletedIssue) {
          res.json({ error: 'could not delete', '_id': req.body._id })
        }
      })

    });

};


Functional tests code

const chaiHttp = require('chai-http');
const chai = require('chai');
const assert = chai.assert;
const server = require('../server');

chai.use(chaiHttp);

let id1 = "";
let id2 = "";




suite('Functional Tests', function() {

   suite("POST /api/issues/{project} => object with issue data", function() {
    test("Every field filled in", function(done) {
      chai
        .request(server)
        .post("/api/issues/test")
        .send({
          issue_title: "Title",
          issue_text: "text",
          created_by: "Functional Test - Every field filled in",
          assigned_to: "Chai and Mocha",
          status_text: "In QA"
        })
        .end(function(err, res) {
          assert.equal(res.status, 200);
          assert.equal(res.body.issue_title, "Title");
          assert.equal(res.body.issue_text, "text");
          assert.equal(
            res.body.created_by,
            "Functional Test - Every field filled in"
          );
          assert.equal(res.body.assigned_to, "Chai and Mocha");
          assert.equal(res.body.status_text, "In QA");
          assert.equal(res.body.project, "test");
          id1 = res.body._id;
          console.log("id 1 has been set as " + id1);
          done();
        });  
  
});


      test("Required fields filled in", function(done) {
      chai
        .request(server)
        .post("/api/issues/test")
        .send({
          issue_title: "Title 2",
          issue_text: "text",
          created_by: "Functional Test - Every field filled in"
        })
        .end(function(err, res) {
          assert.equal(res.status, 200);
          assert.equal(res.body.issue_title, "Title 2");
          assert.equal(res.body.issue_text, "text");
          assert.equal(
            res.body.created_by,
            "Functional Test - Every field filled in"
          );
          assert.equal(res.body.assigned_to, "");
          assert.equal(res.body.status_text, "");
          assert.equal(res.body.project, "test");
          id2 = res.body._id;
          console.log("id 2 has been set as " + id2);
          done();
        })
    });
  
    test("Missing required fields", function(done) {
        chai
          .request(server)
          .post("/api/issues/test")
          .send({
            issue_title: "Title"
          })
          .end(function(err, res) {
            assert.equal(res.body.error, 'required field(s) missing from request');
            done();
          });
      });
     
   });


suite("PUT /api/issues/{project} => text", function() {
    test("No body", function(done) {
      chai
        .request(server)
        .put("/api/issues/test")
        .send({

            _id: id1,
          issue_title: "",
          issue_text: "",
          created_by: "",
          assigned_to: "",
          status_text: ""

          
        })
        .end(function(err, res) {
          assert.equal(res.body.error, "no update field(s) sent");
          done();
        });
    });
    
    test("One field to update", function(done) {
      chai
        .request(server)
        .put("/api/issues/test")
        .send({
          _id: id1,
          issue_text: "new text"
        })
        .end(function(err, res) {
          assert.equal(res.body.result, 'successfully updated');
           assert.equal(res.body._id, id1);
          done();
        });
    });

    test("Multiple fields to update", function(done) {
      chai
        .request(server)
        .put("/api/issues/test")
        .send({
          _id: id2,
          issue_title: "new title",
          issue_text: "new text"
        })
        .end(function(err, res) {
          assert.equal(res.body.result, 'successfully updated');
          assert.equal(res.body._id, id2);
          done();
        });
    });
     test("Update an issue with missing _id", function(done){
         chai
            .request(server)
            .put("/api/issues/test")
            .send({
               _id: "",
               issue_title: "new title"
            })
            .end(function (err, res){
            
            assert.equal(res.body.error, "missing _id");
                done();
            });
     });
   test("Update an issue with an invalid _id", function(done){
         chai
            .request(server)
            .put("/api/issues/test")
            .send({
               _id: "nonexistingid",
              issue_title: "new title"
               
            })
            .end(function (err, res){
            
            assert.equal(res.body.error, "invalid _id");
            assert.equal(res.body._id, "nonexistingid");
                done();
            });
     });

    
       
  });


 suite("DELETE /api/issues/{project} => text", function() {
      test("No _id", function(done) {
        chai
          .request(server)
          .delete("/api/issues/test")
          .send({
               _id: "",
          })
          .end(function(err, res) {
            assert.equal(res.body.error, "missing _id");
            done();
          });
      });

      test("Valid _id", function(done) {
        chai
          .request(server)
          .delete("/api/issues/test")
          .send({
            _id: id1
          })
          .end(function(err, res) {
            assert.equal(res.body.result, "successfully deleted");
            assert.equal(res.body._id, id1);
          });
        chai
          .request(server)
          .delete("/api/issues/test")
          .send({
            _id: id2
          })
          .end(function(err, res) {
            assert.equal(res.body.result, "successfully deleted");
              assert.equal(res.body._id, id2);
            done();
          });
      });

       test("Delete an issue with an invalid _id", function(done){
         chai
            .request(server)
            .put("/api/issues/test")
            .send({
               _id: "nonexistingid",
            })
            .end(function (err, res){
            
            assert.equal(res.body.error, "invalid _id");
            assert.equal(res.body._id, "nonexistingid");
                done();
            });
     });
   
    });


 suite(
      "GET /api/issues/{project} => Array of objects with issue data",
      function() {
        test("No filter", function(done) {
          chai
            .request(server)
            .get("/api/issues/test")
            .query({})
            .end(function(err, res) {
              assert.equal(res.status, 200);
              assert.isArray(res.body);
              assert.property(res.body[0], "issue_title");
              assert.property(res.body[0], "issue_text");
              assert.property(res.body[0], "created_on");
              assert.property(res.body[0], "updated_on");
              assert.property(res.body[0], "created_by");
              assert.property(res.body[0], "assigned_to");
              assert.property(res.body[0], "open");
              assert.property(res.body[0], "status_text");
              assert.property(res.body[0], "_id");
              done();
            });
        });


      test("One filter", function(done) {
          chai
            .request(server)
            .get("/api/issues/test")
            .query({ created_by: "Functional Test - Every field filled in" })
            .end(function(err, res) {
              res.body.forEach(issueResult => {
                assert.equal(
                  issueResult.created_by,
               "Functional Test - Every field filled in"
                );
              });
              done();
            });
        });



 test("Multiple filters (test for multiple fields you know will be in the db for a return)", function(done) {
          chai
            .request(server)
            .get("/api/issues/test")
            .query({
              open: true,
              created_by: "Functional Test - Every field filled in"
            })
            .end(function(err, res) {
              res.body.forEach(issueResult => {
                assert.equal(issueResult.open, true);
                assert.equal(
                  issueResult.created_by,
              "Functional Test - Every field filled in"
                );
              });
              done();
            });
        });

                     

 });

  
  

});

Blockquote
link to code
boilerplate-project-issuetracker - Replit

Your browser information:

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

Challenge: Issue Tracker

Link to the challenge:

issuetracker

How come no one is responding to this post ? Pls can anyone help ?

pls I need help with this project my code is now passing except the last challenge and the last functional test for the issue tracker project, I always see this error at the console '" Uncaught AssertionError: expected ‘could not update’ to equal ‘could not delete’ " here is my project link boilerplate-project-issuetracker - Replit thanks.

[quote=“ayobamiwealth, post:3, topic:503717”]
Uncaught AssertionError: expected ‘could not update’ to equal ‘could not delete’ "
[/quote

I finally solved the problem by commenting out


        // assert.equal(res.body.error, "could not delete");
          assert.equal(res.body._id, "1234nonex");
          done();

I think this error
Uncaught AssertionError: expected ‘could not update’ to equal ‘could not delete’ "
is saying

assert.equal(res.body.error, "could not update");

is the same as

 // assert.equal(res.body.error, "could not delete");