# Prepare Me - Sprint 1 ![](https://media.giphy.com/media/AKpT8WrRQnfpe/giphy.gif =500x) --- ## Demo Website :crocodile: [Prepare Me](https://prepare-me.netlify.app/) ![](https://media.giphy.com/media/3o6nV06zWbeR3Tb1NC/giphy.gif =400x) --- ### Sprint 1 Summary :monkey: - Total 36 hours to work on the project - we did work 33 hours - Plus 3 hours of technical dificulties - estimated = actual (almost) ![](https://media.giphy.com/media/4ZvxPywN6FB0BKIrmA/giphy.gif =400x) --- ![](https://i.imgur.com/h6yhezT.png) --- ![](https://i.imgur.com/QQ71jAs.png) --- ### Writing PERT estimations for week 2 :monkey: - we planned 31 hours work - plus 6 hours of debuging and refactoring ![](https://media.giphy.com/media/mpTN9Ogfp4gWA/giphy.gif =400x) --- ### The magic of Cloudinary :cat: - breaks down handling and manipulating images and into URL manipulation - User uploads image to our cloudinary account - returns url to reflect manipulated image ![](https://media.giphy.com/media/3o6nUMv4TNmvOjB4L6/giphy.gif =400x) --- - cloudinary returns the image as a url res.cloudinary.com/.../sample.jpg - changing the width returns res.cloudinary.com/.../**w_300**/sample.jpg - cropping returns res.cloudinary.com/.../w_300,**c_fit**/sample.jpg ![](https://media.giphy.com/media/3o6nUW7bqpF8IdHRYI/giphy.gif =400x) --- ### The Upload widget :cat: ``` npm i cloudinary-react ``` ```javascript= window.cloudinary.openUploadWidget( { cloudName: '<your-cloud>', uploadPreset: '<preset-1>', sources: ['local', 'image_search', 'google_drive', 'facebook'], googleApiKey: googleKey, cropping: true, } (error, result) => { if (!error && result.event === 'success') { const url = result.info.url; dispatch({ type: 'upload image', url, fieldName, pageNumber }); } }, ); ``` --- ### Testing with Cypress :elephant: ![](https://media.giphy.com/media/3o7aCPX0oehPMBNOBW/giphy.gif =300x) --- #### Cypress?? :elephant: Cypress is a front end testing tool that enables you to write all types of tests: - **End-to-end tests** (Test driving the car) - Integration tests - Unit tests (Testing a wheel of a car) ![](https://i.imgur.com/4cbDbHi.png =300x) --- #### Terminal Bashing :elephant: To install Cypress ``` npm install cypress --save-dev ``` To open Cypress ``` npx cypress open ``` To open in terminal Cypress ``` npx cypress run ``` Note, Local sever must be running :running: --- #### Open sesame :elephant: ![](https://i.imgur.com/Qf1KjF9.png) --- #### Yummy tests :elephant: ![](https://i.imgur.com/0TL7xNM.png) --- #### Files??? :elephant: ![](https://i.imgur.com/TVn3Zn0.png) Note, Can even record a video of the test!!! --- ### Managing state :crocodile: ![](https://i.imgur.com/HeShgud.jpg) --- ### why useContext + useReducer - Never mutate state directly in React - Otherwise it may not react correctly - Could use useState and share setState - Model logic spread across the whole app - Potential code duplication - useReducer keeps model logic in one place - No model code in handlers or components --- ```javascript // Share the state and dispatch function via context function App() { const [state, dispatch] = useReducer(updater, initState); return ( <SiteContext.Provider value={[state, dispatch]}> ``` ```javascript // "dispatch" messages to the state updater function function Landscape1({ pageNumber, fields }) { const [state, dispatch] = React.useContext(SiteContext); const handleClick = (event) => { const template = event.currentTarget.id; dispatch({ type: 'load story template', template }); history.push('/story-page/1'); }; ``` --- ```javascript // Centralised updater function handles messages function updater(state, message) { const copy = clone(state); // Clones the state switch (message.type) { // Switch on "type" case 'load story template': { // Case for each message const { template } = message; // Destructure params copy.pages = components[template].pages; // Modify return copy; // Returns newly modified copy of state } ``` --- ### Team Achievements :cat: - Our PO trina is brilliant and we're lucky to have her! :heartbeat: - The upload component - Use of State! - Big plans for a lot of testing :hand_with_index_and_middle_fingers_crossed: ![](https://media.giphy.com/media/nZumtdOQfdVxm/giphy.gif =300x) --- ### What will make our MVP *the* MVP :monkey: - Print and download - more page tempaltes to choose from - edit images ![](https://media.giphy.com/media/fwFL2J2B4aJKJgYpaW/giphy.gif =400x) --- ### Resources :elephant: [Cypress set-up Notes](https://github.com/fac19/research/blob/master/student-roles/cypress%2C-qa-notes.md) [e2e, intergration & unit](https://medium.com/@lawrey/unit-tests-ui-tests-integration-tests-end-to-end-tests-c0d98e0218a6) [useContext + useReducer](https://hackmd.io/VMtk0P3UTdGCH-BCompzDA) ![](https://media.giphy.com/media/VoqUivxZUaTV6/giphy.gif =400x) --- ### Questions? :elephant: ![](https://media.giphy.com/media/aACeieARpEEE/giphy.gif =400x)
{"metaMigratedAt":"2023-06-15T09:27:53.597Z","metaMigratedFrom":"Content","title":"Prepare Me - Sprint 1","breaks":true,"contributors":"[{\"id\":\"b4905d1f-6321-4767-ab1f-4fc252ee8196\",\"add\":5281,\"del\":3362},{\"id\":\"0e4f99ec-9dff-4b8d-9f98-aa3f5444e9ce\",\"add\":1747,\"del\":258},{\"id\":\"3c970cbc-e792-4aab-bd26-9f18c46b45b6\",\"add\":550,\"del\":5},{\"id\":\"84d28a23-6942-43f3-a6ba-6835bb139040\",\"add\":2277,\"del\":1062}]"}
    511 views