Welcome to Sprint 7 Challenge! In this project, you will demonstrate your ability using React Router, creating forms with proper validation, and testing React components.
Your main goal is to implement a form that handles a pizza order, validates user input, and POSTs the order to the backend. Your next goal will be to demonstrate basic ability testing functions and components.
To successfully complete this project, you will need the following technical knowledge:
Additionally, the following soft skills will greatly impact your performance:
Project repository: https://github.com/bloominstituteoftechnology/W_S7_Challenge
You have been given a take-home coding assessment as part of the hiring process for a Web Developer position. Your task is to implement basic routing for a home-delivery pizza site and create a form to take pizza orders.
Here are the steps to set up this project:
npm i
.npm run dev
.npm test
.http://localhost:3003
.❗ Note: On the event of NPM errors during setup, delete the node_modules
folder and the package-lock.json
file, and retry npm i
and npm run dev
.
Your fully-functional design mock is https://bloominstituteoftechnology.github.io/W_S7_Challenge/
Study it using Chrome Dev Tools, paying special attention to the Elements tab.
Your finished product will have to match the functionality of the design exactly.
Study with Postman the following endpoint: [POST] http://localhost:9009/api/order
Here is an example of a valid request payload:
{ "fullName": "Jane Doe", "size": "L", "toppings": ["1","2","3","4","5"] }
❗ Endpoint notes:
fullName
is required and must have min length of 3 chars, and max length of 20 chars.fullName
length requirement ignores whitespace padding (E.G. " x " is not valid as the server will trim whitespace and count its length as 1).size
is required and only has three possible values: "S", "M" or "L".toppings
array is optional and can only contain valid topping IDs:
Here are more valid payloads (test in Postman!):
{"fullName": "Jane Doe", "size": "S", "toppings": [2,"3",1]} {"fullName": "Jane Doe", "size": "M", "toppings": []} {"fullName": "Jane Doe", "size": "L"}
Here are some invalid payloads (test in Postman!):
{ "fullName": " X ", "size": "S" } { "fullName": "Jane Doe", "size": "X" } { "fullName": "Jane Doe", "size": "L", "toppings": ["1","1",6] }
Inside the index.js module:
<App />
element using BrowserRouter
from React Router.Inside the App.js module:
nav
, render two NavLinks
:
nav
, render a Routes
element containing two Route
elements:
<Home />
.<Form />
.Inside the Home.js module:
Continue inside the Form.js module.
Continue inside the mvpB.test.js module.
This assignment is graded by running the tests in the mvpA.test.js
and mvpB.tests.js
modules.
You can run the same tests by executing npm test
.
The tests depend on being able to locate some crucial elements on the page:
#fullName
CSS selector. Do not delete this id from the JSX.#size
. Do not delete this id from the JSX.input[type=checkbox]
. Render only the checkboxes you see in the mock, in the same order.input[type=submit]
. Do not convert it into a button.Also do not create accidental duplicates of elements:
// this FAILS if more than one element on the page has the text content "hurrah" const element = screen.queryByText('hurrah')
Do not struggle for an unreasonable amount of time! Request support via one of the available channels.
Run npm test
. Note that Codegrade will run your code against its own copy of the mvpA.test.js
test file.
On occasion the test runner will get stuck. Use CTRL-C to kill the tests, and then npm test
to launch them again. Try to reproduce the problem the test is complaining about by interacting with the site in Chrome, and do not code "to make the test happy". Code so that your app does exactly what the mock does. The tests are there for confirmation. Although it's possible that a particular test be flawed, it's more likely that the bug is in your own code. If the problem persists, please request assistance from Staff.
If you need to disable all tests except the one you are focusing on, edit the test file and, as an example, change test('👉 focus on this', () => { etc })
to be test.only('👉 focus on this', () => { etc })
. (Note the "only".) This won't affect Codegrade, because Codegrade runs its own version of the tests. Keep in mind though, if there is a syntax problem with your code that is causing an error to be thrown, all tests will fail.
This project requires Node to be correctly installed on your computer to work. Try deleting node_modules
and running npm install
. If that fails, try deleting both node_modules
and package-lock.json
before reinstalling. If all fails, please request support!
No. Everything you need should be installed already, including Yup, Axios and React Testing Library.
Of course! Have at it. But solve the challenge first, and then be careful not to break any tests!
With React, it's very important that we use the React Dev Tools to monitor the state of our components as we interact with the App. If the state is not adjusting like it should, that's one situation. If the state does change correctly but the UI does not respond, that's a different problem.
If your code has a syntax problem, the app will print error messages in the console. Focus on the first message. Place console logs right before the crash site and see if your variables contain the data you think they do. Comment out chunks of code until you get the app to compile!
Do NOT delete your repository from GitHub! Instead, commit frequently as you work. Make a commit whenever you achieve anything and the app isn't crashing in Chrome. This in practice creates restore points you can use should you wreak havoc with your app. If you find yourself in a mess, use git reset --hard to simply discard all changes to your code since your last commit.