This is a test repository for the zipBoard junior position application process. This project demonstrates a simple React application with a login form and Cypress testing setup.
This repository is for testing purposes only. Please fork this repository to your own account and do not modify this original repository. All your work should be done in your forked version.
To run this project locally, you need to have the following installed:
- Node.js (version 18 or higher)
- npm (comes with Node.js)
- Git
- Fork this repository to your own account
- Clone your forked repository:
git clone <your-forked-repo-url>
- Install dependencies:
npm install
- Start the development server:
The application will be available at http://localhost:3000
npm start
This project uses Cypress for end-to-end testing. To run the tests:
-
Make sure the development server is running (
npm start) -
In a new terminal, you can run Cypress in two ways:
npm run cypress:open
This will open the Cypress Test Runner UI where you can:
- Choose your preferred browser
- See all test files
- Run tests interactively
- Watch tests run in real-time
npm run cypress:run
This will run all tests in the terminal without opening the UI.
npm run test:e2e
This command will:
- Start the development server
- Wait for it to be available
- Run all Cypress tests
- Shut down the server when done
├── src/
│ ├── components/
│ │ ├── LoginForm.js
│ │ ├── LoginForm.css
│ │ ├── Welcome.js
│ │ └── Welcome.css
│ ├── App.js
│ └── App.css
├── cypress/
│ ├── e2e/
│ │ └── login.cy.js
│ └── support/
│ ├── commands.js
│ └── e2e.js
└── package.json
npm start- Runs the app in development modenpm test- Runs the React testing suitenpm run build- Builds the app for productionnpm run cypress:open- Opens Cypress Test Runnernpm run cypress:run- Runs Cypress tests in headless modenpm run test:e2e- Runs Cypress tests with the dev server
This project is for testing purposes only and is not licensed for public use.
The original issue in the app was that logging in did not redirect the user to the welcome page.
This occurred because the login logic didn’t properly trigger the redirect using React Router.
- I created a wrapper
LoginPagecomponent usinguseNavigate()fromreact-router-dom. - Inside the login handler, after updating login state, I added
navigate('/welcome')to redirect the user upon successful login.
This ensured the login flow completes and navigates to the welcome screen.
I wrote a Cypress test (cypress/e2e/login.cy.js) that performs the following:
- Opens the login page
- Enters a username and password
- Submits the login form
- Asserts that the user is redirected to
/welcome - Checks that the personalized welcome message appears
All test cases pass successfully, confirming that the login functionality and redirection work as expected.