feat(learn): Stock Price Checker user stories (#40218)

* Adjust user stories, add instructions

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

* Apply review suggestion

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* Move tests to /learn

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

* Apply suggestions from code review

Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
This commit is contained in:
Nicholas Carrigan (he/him)
2020-11-25 09:55:03 -08:00
committed by GitHub
parent ebb4e0d5cc
commit b5d5ec5a90

View File

@ -9,13 +9,31 @@ forumTopicId: 301572
<section id='description'>
Build a full stack JavaScript app that is functionally similar to this: <a href="https://stock-price-checker.freecodecamp.rocks/" target="_blank">https://stock-price-checker.freecodecamp.rocks/</a>.
Since all reliable stock price APIs require an API key, we've built a workaround. Use <a href="https://stock-price-checker-proxy.freecodecamp.rocks/" target="_blank">https://stock-price-checker-proxy.freecodecamp.rocks/</a> to get up-to-date stock price information without needing to sign up for your own key.
Working on this project will involve you writing your code on Repl.it on our starter project. After completing this project you can copy your public Repl.it URL (to the homepage of your app) into this screen to test it! Optionally you may choose to write your project on another platform but must be publicly visible for our testing.
Start this project on Repl.it using <a href="https://repl.it/github/freeCodeCamp/boilerplate-project-stockchecker">this link</a> or clone <a href='https://github.com/freeCodeCamp/boilerplate-project-stockchecker/'>this repository</a> on GitHub! If you use Repl.it, remember to save the link to your project somewhere safe!
Working on this project will involve you writing your code using one of the following methods:
- Clone <a href='https://github.com/freeCodeCamp/boilerplate-project-stockchecker/' target='_blank'>this GitHub repo</a> and complete your project locally.
- Use <a href='https://repl.it/github/freeCodeCamp/boilerplate-project-stockchecker' target='_blank'>our repl.it starter project</a> to complete your project.
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.
When you are done, make sure a working demo of your project is hosted somewhere public. Then submit the URL to it in the `Solution Link` field. Optionally, also submit a link to your projects source code in the `GitHub Link` field.
</section>
## Instructions
<section id='instructions'>
1. SET `NODE_ENV` to `test` without quotes and set `DB` to your MongoDB connection string
2. Complete the project in `routes/api.js` or by creating a handler/controller
3. You will add any security features to `server.js`
4. You will create all of the functional tests in `tests/2_functional-tests.js`
Write the following tests in `tests/2_functional-tests.js`:
- Viewing one stock: GET request to `/api/stock-prices/`
- Viewing one stock and liking it: GET request to `/api/stock-prices/`
- Viewing the same stock and liking it again: GET request to `/api/stock-prices/`
- Viewing two stocks: GET request to `/api/stock-prices/`
- Viewing two stocks and liking them: GET request to `/api/stock-prices/`
</section>
## Tests
@ -23,12 +41,12 @@ Start this project on Repl.it using <a href="https://repl.it/github/freeCodeCamp
```yml
tests:
- text: I can provide my own project, not the example URL.
- text: You can provide your own project, not the example URL.
testString: |
getUserInput => {
assert(!/.*\/stock-price-checker\.freecodecamp\.rocks/.test(getUserInput('url')));
}
- text: Set the content security policies to only allow loading of scripts and CSS from your server.
- text: You should set the content security policies to only allow loading of scripts and CSS from your server.
testString: "async getUserInput => {
const data = await fetch(getUserInput('url') + '/_api/app-info');
const parsed = await data.json();
@ -36,13 +54,13 @@ tests:
assert.isTrue(parsed.headers['content-security-policy'].includes('style-src \\'self\\''));
}
"
- text: I can GET /api/stock-prices with form data containing a Nasdaq stock ticker and receive back an object stockData.
- text: You can send a `GET` request to `/api/stock-prices` with form data containing a NASDAQ stock ticker. Returned will be an object with the property `stockData`.
testString: "async getUserInput => {
const data = await fetch(getUserInput('url') + '/api/stock-prices?stock=GOOG');
const parsed = await data.json();
assert.property(parsed, 'stockData');
}"
- text: In stockData, I can see the stock (the ticker as a string), price (decimal in string format), and likes (int).
- text: The `stockData` property includes the `stock` ticker as a string, the `price` as a number, and `likes` as a number.
testString: "async getUserInput => {
const data = await fetch(getUserInput('url') + '/api/stock-prices?stock=GOOG');
const parsed = await data.json();
@ -51,9 +69,9 @@ tests:
assert.typeOf(ticker.likes, 'number');
assert.typeOf(ticker.stock, 'string');
}"
- text: I can also pass along field like as true (boolean) to have my like added to the stock(s). Only 1 like per IP should be accepted.
- text: You can also pass along a `like` field as `true` (boolean) to have your like added to the stock(s). Only 1 like per IP should be accepted.
testString: ''
- text: If I pass along 2 stocks, the return object will be an array with information about both stocks. Instead of likes, it will display rel_likes (the difference between the likes on both stocks) on both.
- text: If you pass along 2 stocks, the returned value will be an array with information about both stocks. Instead of `likes`, it will display `rel_likes` (the difference between the likes on both stocks) for both `stockData` objects.
testString: "async getUserInput => {
const data = await fetch(getUserInput('url') + '/api/stock-prices?stock=GOOG&stock=MSFT');
const parsed = await data.json();