Anonymous Message Board - Test Errors? and Unclear Directions on Proper Response Object

Hi FCC,

I’m encountering some issues with the Anonymous Message Board Project on repl.it, and I’d like to know if it is because it is being updated in the background for maintenance.

  1. API route tests pass even without implementing any code - even before starting the project, when I input my Repl.it link for testing, all of the API route sections pass. I haven’t touched the fcctesting.js code at all. Let me know if you guys are updating this section and that is the reason for this.

  1. Clarification on API route response - for some of the API routing (GET, POST), I’m very unclear as to what the proper response (res.send, res.json) is. Based on the sample project, a “GET” or “POST” for a thread or reply would link to the "/views/board.html" page. Does that mean, for instance, a “POST” response would be "res.send(File(process.cwd( ) + '/views/board.html')), versus just "res.send(data)"?

I ask this because if I have the response to a POST/GET request as res.send(File(process.cwd( ) + '/views/board.html')), when it redirects the AJAX script does not work. Example (nothing shows up):

  .post(async (req, res) => {
    const {board, text, delete_password} = req.body;
    const MessageBoard = mongoose.model(board, messageSchema);
    
    //create new document
    const thread = new MessageBoard ({
      text: text,
      delete_password: delete_password,
      created_on: new Date().toISOString(),
      bumped_on: new Date().toISOString(),
      reported: false,
      replies: []
    })
    //save document to model
    await thread.save((err, data)=> {
      if (err) return (err);
      console.log('success')
      console.log(data);
      res.sendFile(process.cwd() + '/views/board.html'); //redirect to the message board
    })
  })

I know it’s supposed to look like this, based on the sample finished project:

But all I get is this:

Then I looked at the actual /views/board.html code, and you guys mentioned that this jQuery script is only set up for “Code Readabilities and Testing”. Does that mean this doesn’t actually work (and nothing would actually show up here?)

My initial impression is that there’s something about the jQuery script not picking up the GET request, and I’m missing some key concept here.

I hope I’ve explained my issue clearly. This is the last project I have on my plate with the Legacy QA and InfoSec Certification and I’d like to wrap up this chapter. Thanks!!! (I hope someone out there can help me).

1 Like

Hello there,

Some of the tests for this project have not been written yet:
freeCodeCamp/anonymous-message-board.md at main · freeCodeCamp/freeCodeCamp (github.com)

Based on the jQuery code, it is expecting the GET request data to be an array with the mentioned fields.
Your response to a POST should be a redirect…a literal redirect response.

I hope the clarifies.

Hi @Sky020 ,

Thank you, that makes sense! I found this github page as well and wasn’t sure why those route tests were blank. Can I actually contribute to this?

As for:

OMG I just figured this out, based off of this in server.js:

app.route('/b/:board/')
  .get(function (req, res) {
    res.sendFile(process.cwd() + '/views/board.html');
  });

Thank you so much for your help!!! :grinning: :grinning: :grinning: :grinning: :grinning:

1 Like

Absolutely! Be sure to check out the Contribute to the freeCodeCamp.org Community Docs, and reach out if you need any assistance.

1 Like

Thank you @Sky020! I will check it out.

Outside of this, do you have any ideas when the tests will be written? I understand that this project has been around for some time, I’m wondering why all of a sudden the tests disappeared (or maybe they were never there to begin with?)

Unfortunately, unless I do it myself, there is no way to tell. The projects are open to contribution, and this is not the only project with little/no tests.

Correct. They were never written.

The projects were released when they were ready, but before the tests.

An important aspect of freeCodeCamp to remember is that it is free. This means a few things:

  1. There are limited dedicated resources to cover everything. By resources I mean staff time.
  2. There is technically no need to test the projects completely/thoroughly. The certification is free. It is not accredited by anyone. If a Camper is dishonest with their work, and knowingly submits something that does not fit the given criteria (user stories), then they are shooting themselves in the foot - they gain no benefit from being academically dishonest. Also, the work is sometimes checked, which can lead to the revocation of any claimed certificate.
  3. See this as an opportunity to contribute, if you can. I have learnt the most from freeCodeCamp by contributing to the code base - not from the curriculum. To clarify, the curriculum has been an important stepping-stone for me to learn the tools freeCodeCamp majoritively uses for the codebase stack, but I just learnt the most from applying it to a codebase

I hope that is not too long :smiley:

1 Like

@Sky020 Thanks for the explanation, it makes sense. I ask, because when I’m learning and doing the projects, I really do pretend that it is the REALEST thing in the world, because it raises the stakes and makes me more focused. I understand this is a fully volunteer effort.

I just finished the project, but still struggling to write the functional tests (particularly, how do you tests for Window.Alert( ) and for redirected pages in Chai). Once I figure it out I’d be happy to contribute.

1 Like

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