Git Product home page Git Product logo

wuweidegug1's Introduction

React: HackerShop Checkout

Environment

  • React Version: 16.13.1
  • Node Version: ^12.18.3
  • Default Port: 8000

Application Demo:

Functionality Requirements

The app has two separate views/components. The Product Listing Component and Cart Component. The list of products to be displayed is already provided in the app. 

The Product Listing component should implement the following functionalities:

  • Clicking on each 'Add To Cart' button should add the item to the shopping cart. When an item is added to the cart, 

    • 'Add To Cart' button should be removed from view and 'Remove From Cart' button should be displayed.
    • An entry should be added to the table in Cart Component.
  • Clicking on each 'Remove From Cart' button should remove the item from the cart and display 'Add to Cart' button for the corresponding product item.

  • The Cart Component should have the following functionalities:

    • Display all the items in the cart in a table.

    • Display the Cart Subtotal, Discount Value, and Total Price. 

    • The Cart has a Coupon Select Input. On selecting a coupon from this input, an appropriate discount is applied and the total price is calculated and displayed. (Subtotal - Discount = Total Price)

  • Items should be displayed in the Cart Component in the order they are added to Cart. 

  • The list of products and the cart object is passed as Prop to the Product Listing Component and Cart Component respectively.

Each product object contains the following properties: 

  • name: Name of the product. [STRING]
  • price - The price of the Product. [NUMBER]
  • id: Unique ID of the product. (Auto Generated) [NUMBER]
  • image:  The image URL of the product. [STRING]
  • cartQuantity: The quantity of the item in the cart. The default value should be 0. [NUMBER]

Each item in the cart, Type CartItem has the following properties:

  • id: Same as ID of the product. [NUMBER]
  • item - The heading property of the product. [STRING]
  • quantity: The quantity of the item in the cart [NUMBER]
  • price: The total amount of the item in cart. (quantity x product.price) [NUMBER]

Testing Requirements

The following data-testid/class attributes are required in the component for the tests to pass:

  • Each product item in the Listing component should have the class product-item.
  • Each Add to Cart button should have the data-testid attribute 'btn-item-add'.
  • Each Remove to Cart button should have the data-testid attribute 'btn-item-add'.
  • The table rows <tr> in the Cart Component corresponding to items in the cart should have the data-testid attribute of cart-item-0, cart-item-1, and so on.
  • The table data <td> containing the Name of the Item in the cart should have the data-testid attribute 'cart-item-name'.
  • The table data <td> containing the Quantity of the Item in the cart should have the data-testid attribute 'cart-item-quantity'.
  • The table data <td> containing the Price of the Item in the cart should have the data-testid attribute 'cart-item-price'.
  • The Coupon Select input should have a data-testid attribute 'cart-coupon'
  • The Cart Subtotal value container should have a data-testid 'cart-subtotal'. 
  • The Cart Discount value container should have a data-testid 'cart-discount'. 
  • The Cart Total Price value container should have a data-testid 'cart-total'. 

Note: Please note that the component has the above data-testid attributes for test cases and certain classes and ids for rendering purposes. It is advised not to change them.

Project Specifications

Read Only Files

  • [src/App.test.js]

Commands

  • run:
bash bin/env_setup && . $HOME/.nvm/nvm.sh && npm start
  • install:
bash bin/env_setup && . $HOME/.nvm/nvm.sh && npm install
  • test:
bash bin/env_setup && . $HOME/.nvm/nvm.sh && npm test

wuweidegug1's People

Contributors

xiayu012 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.