URL Shortener project with testable user stories - Guinea Pigs needed šŸ¹

As you may have heard, @em-ant, @Greenheart, and @systimotic have been hard at work building projects with testable user stories. We are looking for a few volunteers to attempt to build these based on their automated tests.

The goal is for campers to be able to build these projects step by step following user stories. This will make the projects less intimidating and more fun. Oh, and donā€™t worry - weā€™ll still have plenty of optional projects where we donā€™t provide you with any tests. And if youā€™ve previously built these projects, you donā€™t need to build them again.

If youā€™re interested in attempting this, please reply to the thread and let us know youā€™ve started it. The more people who want to build this, the better, as we can start gathering feedback.

Thanks, and happy coding!

The project tester (enter the public HyperDev URL for your project and set it to MS3-url shortener): https://narrow-plane.hyperdev.space/

Working example: https://thread-paper.hyperdev.space/

Boilerplate to remix: https://hyperdev.com/#!/project/pastoral-caution

Note that in order to build this project, you need to first add an mLab URI to your .env file.

Also, your tests must be run sequentially

Iā€™m going to start this project today. Iā€™ll be using a custom domain name, so Iā€™ll have to add some routes just for the purpose of the automated tests hitting them.

Is there any chance that the option to customize the API endpoints could be added? For example, to cause the automated tests to optionally GET [base url]/[short url] instead of GET [base url]/api/shorturl/[short url]? I know itā€™s an edge case, but it might be nice for people who are hosting on platforms other than hyperdev.

1 Like

Iā€™ve completed this but I will try to pair with someone who hasnā€™t done it.

1 Like

Iā€™m not sure. This would be a good question for @greenheart or @systimotic.

Ok, I just got the last automated test to pass! :smile:

It seems to work well although my project is hosted on my VPS.

https://www.zackward.net/projects/url-shortener

My feedback:

I had some trouble getting the last test (5. Invalid URL) to pass. I was returning a json object of the correct format, but I was also setting the HTTP status of the response to 400. The test wouldnā€™t pass until I returned a response with a 200 status. It seems to me that a 400 status would be more appropriate in the case of the client passing an invalid URL. Would it be possible to have the automated test check for the correct json regardless of the status?

2 Likes

I just finished the url shortener service (just on c9 so far - have not yet hooked it up to Heroku) and would like to contribute to the project if I can. What is the first step? How does this work?

1 Like

Fork the boilerplate and start building. You can use the tester to check whether youā€™ve met the individual user stories.

I had to modify my old url shortener a good bit to make it work with the current tests, but everything works now.
Code : https://gomix.com/#!/project/juniper-puppy

Iā€™ve built this project, and it works fine, but when I test it with https://narrow-plane.glitch.me/, it fails tests 2 and 4 with error message saying only ā€˜errorā€™ (I ran these tests sequentially, so that shouldnā€™t be the cause of the problem). I tried to test the example project, https://thread-paper.glitch.me, and the result is the same. In the developer console it prints the following: "XMLHttpRequest cannot load https://curse-arrow.gomix.me/api/timestamp. Redirect from ā€˜https://curse-arrow.gomix.me/api/timestampā€™ to ā€˜https://curse-arrow.glitch.me/api/timestampā€™ has been blocked by CORS policy: No ā€˜Access-Control-Allow-Originā€™ header is present on the requested resource. Origin ā€˜nullā€™ is therefore not allowed access."
So, is that a bug or is there a problem in my code? My project is here: https://glitch.com/edit/#!/literate-ravioli

I have the same issue, maybe itā€™s a CORS problem on the tester app

@Enikol Thanks for discovering this issue. Could you open a GitHub issue describing this?

Done! https://github.com/freeCodeCamp/testable-projects-fcc/issues/154
I also think I found the problem (itā€™s described in the issue, but I canā€™t open a PR because I canā€™t find the source code for the testing app.

Thanks for the note about the response status codes! I was also using 400/404 status codes to handle invalid requests and this prevented the last test from passing. Frustratingā€¦