Coder Social home page Coder Social logo

ajonesb / react-next-jest-cypress-tailwind-multi-step-form Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 468 KB

This application is a multi step form developed in React, Next, Cypress and Jest for end to end and Unit testing.

JavaScript 99.11% CSS 0.89%

react-next-jest-cypress-tailwind-multi-step-form's Introduction

Multi Step Form

A ticket-ordering frontend app in React that:

  1. Collects user input.
  2. Uses correct input types for each field.
  3. Validates the fields according to the validation rules provided below.
  4. Preserves the state between steps.
  5. Displays the collected information on the last step.
  6. Includes unit tests for one module of your choice.
  7. Makes the provided E2E tests pass.
  8. Has the UI styled with design system scalability in mind. Use this Figma mockup as a reference.

Navigation elements

Each step of the form should also contain the "Submit" and "Back" buttons.

data-testid attributes are used to identify those elements.

The form steps

The inputs on the form steps have the following data-testid attributes:

Step 1

<form ...>
  <input data-testid="firstName" ... />
  <input data-testid="lastName" ... />
  <input data-testid="age" ... />
  <button data-testid="submit" />
</form>

Step 2

<form ...>
  <input data-testid="phone" ... />
  <input data-testid="email" ... />
  <button data-testid="submit" />
  <button data-testid="back" />
</form>

Step 3

<form ...>
  <input data-testid="seat" ... />
  <input data-testid="food" ... />
  <input data-testid="allergies" ... />
  <button data-testid="submit" />
  <button data-testid="back" />
</form>

Result

On the results page we see the values collected by the form. Each element containing the value has a data-testid field with the corresponding field name:

<div data-testid="<field name>">value</div>
<button data-testid="back" />

Validation rules

Form steps have the following validations:

Step 1

  • firstName is a required field.
    • Validation message: First name is a required field
  • firstName should not contain numbers.
    • Validation message: First name should not contain numbers
  • lastName is a required field.
    • Validation message: Last name is a required field
  • lastName should not contain numbers.
    • Validation message: Last name should not contain numbers
  • age is a required field.
    • Validation message: Age must be a number
  • age should be a positive number.
    • Validation message: Age should be positive

Step 2

  • email is a required field.
    • Validation message: Email is a required field
  • email should have correct email format.
    • Validation message: Email should have correct format
  • phone is a required field.
    • Validation message: Phone number is a required field

Step 3

  • seat is a required field.
    • Validation message: Seat is a required field
  • food is a required field.
    • Validation message: Food is a required field
  • allergies is a required field.
    • Validation message: Allergies is a required field

Try running the E2E tests locally

npm install
# Run your app here
npm run test

Application UX experience:

  1. Fulfills the requirements in the task description above.
  2. Ensures that state management is well organized.
  3. Unit test one module.
  4. Avoids duplication and extracts re-usable modules where it makes sense.
  5. Cleaned up code as if it was used in production.

react-next-jest-cypress-tailwind-multi-step-form's People

Stargazers

Roman avatar Alan Jones  avatar

Watchers

Alan Jones  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.