Metric Imperial Conversion Project with testable user stories - Guinea Pigs needed šŸ¹

This project will be part of our new Quality Assurance and Information Security section. It was designed by @JosephLivengood.

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!

User Stories

  • I will prevent the client from trying to guess(sniff) the MIME type.
  • I will prevent cross-site scripting (XSS) attacks.
  • I can GET /api/convert with a single parameter containing an accepted number and unit and have it converted. (Hint: Split the input by looking for the index of the first character which will mark the start of the unit)
  • I can convert ā€˜galā€™ to ā€˜Lā€™ and vice versa. (1 gal to 3.78541 L)
  • I can convert ā€˜lbsā€™ to ā€˜kgā€™ and vice versa. (1 lbs to 0.453592 kg)
  • I can convert ā€˜miā€™ to ā€˜kmā€™ and vice versa. (1 mi to 1.60934 km)
  • If my unit of measurement is invalid, returned will be ā€˜invalid unitā€™.
  • If my number is invalid, returned with will ā€˜invalid numberā€™.
  • If both are invalid, return will be ā€˜invalid number and unitā€™.
  • I can use fractions, decimals or both in my parameter(ie. 5, 1/2, 2.5/6), but if nothing is provided it will default to 1.
  • My return will consist of the initNum, initUnit, returnNum, returnUnit, and string spelling out units in format ā€˜{initNum} {initial_Units} converts to {returnNum} {return_Units}ā€™ with the result rounded to 5 decimals in the string.
  • All 16 unit tests are complete and passing.
  • All 5 functional tests are complete and passing.

The 16 unit tests are named with some being filled in for example. They test each function in the convertHandler(6 total) with valid/invalid/blank/ect inputs. The 5 functional tests test valid input, the 3 invalid inputs and a no number input.

Passing prototype built on boilerplate: https://gomix.com/#!/project/hard-twilight
Boilerplate: https://gomix.com/#!/project/fcc-convert
Tester(ISQA_2-Metric/Imp Converter): https://pricey-hugger.gomix.me/

1 Like

Good morning,
I have completed all user stories except the unit test and functional tests. They keep displaying

TypeError: Cannot read property ā€˜assertionsā€™ of undefined

when the tests I created are correct

Hmm, after tackling this today, I have to say that I really, really donā€™t like the way that these new projects are forcing users to write test suites. I aim for full test coverage with every project that I make, and already have my own go-to list of packages that let me write all kinds of tests in a manner that Iā€™m familiar with, so I donā€™t want to have to write another set of tests just so that I can submit the project.

I also donā€™t like how restrictive these tests are in terms of project structure. I basically have to use the boiler plate to get the tests to pass, which is a bit ridiculous. Users should be able to structure their projects however they want to and not be penalised for it, providing the API endpoints all pass the appropriate tests. It would be great if the unit/functional tests were optional, especially for users who already write tests as they build the project.

@QuincyLarson, are the unit and functional tests definitely gonna be mandatory for all of the information security projects?

1 Like

Thank you so much for the feedback; it does help us adjust these projects while theyā€™re in beta still. I can explain why it current is how it is though:

These projects are built with the main focus being testing information security and quality assurance and not specifically just back-end development in general. The lessons leading up to these projects is all about this test suite and chai assertion style that it is expecting currently. In order for us to properly test oneā€™s project on the back to see that theyā€™ve been able to implement the lessons learned from this section correctly in a real world way is to be very clear about what we expect and only expect that, which can unfortunately take freedom away from the user if they bring in outside knowledge outside the curriculum.

With your feedback in mind though, I will look into a way that may allow for more freedom for advanced users not using the curriculum but still technically meeting the quality assurance requirements weā€™re looking for in the testing!

Thanks for the reply Joseph. Yeah, I get why the projects have been set up this way, and it will benefit most users, Iā€™m sure. Just a bit frustrating having to completely alter the way that I code in order to get the project to pass.

Would be great if you could come up with some sort of way that allows more flexibility, but I think Iā€™m just gonna have to adapt in the meantime!

OK, so I just wrote the app again using the boiler plate and copied and pasted in parts from the app that Iā€™d previously written. Really didnā€™t take long at all, and I got all tests to pass with only minor refactoring, so I think my response above might have been a bit over the topā€¦

Anyway, I actually found the requirement for the ā€˜Lā€™ in litre to be capitalised to be the most troublesome partā€¦ is it standard to capitalise the L for that unit?

And as I said, writing the tests didnā€™t take long at all. The only thing Iā€™d quite like to see changed would be to add the option of using Chaiā€™s expect assertion style. Any plans to incorporate that into the curriculum at any point? I think itā€™s definitely easier to grasp than assert for newcomers to testing. Hope the feedback helps in some way.

@tom-p-uk

So we can definitely add the support for expect in time- but Im thrilled you were able to get them working with assert!

The capital L for Liter(/litre) is actually something I never thought about possibly being different in different parts of the world. In North America we learn its absolutely wrong to ever leave liter abbreviation lowercase in any situation ever!.. But looking into it, I see in Europe its okay either way! Iā€™ll look into either possibly removing the requirement or clarifying why its there (if we want to leave that complexity)

Thank you so much for the continued feedback and support to help us make these projects better!

Demo ==> https://brusbilis.com/freecodecamp/6-backEnd/metric/metric.html

Code ==> https://github.com/brusbilis/freeCodeCamp/tree/master/6-backEnd/metric

I made input data not case sensitive to avoid misunderstandings

Backend is made with Golang instead of node

Security requirements are implemented in nginx

Using https://pricey-hugger.glitch.me/ only pass the 5th test

Hi guys, could you look on https://glitch.com/edit/#!/metric-imperial-converter-fcc, please.

It looks that everything is fine, but it fails on tests 11-16 with error TypeError: Cannot read property 'assertions' of undefined.

I am having this problem too. Does anyone have any insight to offer?

UPDATE: For anyone else having this problem, in your .env file set NODE_ENV=test. That solved it for me.

1 Like

The demo project is broken, all the code is missing from Glitch. I tried contacting @JosephLivengood here and on GitHub, but he was last seen here on Feb 21, '17. I guess he is not involved with FCC anymore?

I donā€™t know if it is possible to take over his demo project just like that and restore the code. If we make a new one, the links on the challenge page, here in this thread and possibly on the Tester need to be updated. The Links on the Tester all still use the old gomix links and should be updated anyway.

Maybe someone in charge can look into this? Or someone is still in contact with @JosephLivengood ?

5 Likes

@jeremylshepherd Thank you! That works

yes the demo project is broken, how can we proceed?

Hello Everyone,

I encountered an error in the functional test (6. Functional Tests (5)) of the FCC Back-end Tester > Nasdaq Stock Prices project

TypeError: Cannot read property ā€˜0ā€™ of undefined

The steps to reproduce are documented here: FCC Back-end Tester > Nasdaq Stock Prices > 6. Functional Tests (5) = TypeError: Cannot read property '0' of undefined

I did not encountered this issue in all of the Functional Tests in the 4 other projects.

Any advise on how could we debug this?

Itā€™s my last certification and I am trying to complete this project from since 1 month, itā€™s getting too tough and somehow irritating for me to complete it. If I try to fulfill functional and unit test, then it doesnā€™t fulfill my actual tests, if i fulfill my actual tests, the error occurs in fulfilling functional and unit tests. Kindly help it out