Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 5.0.0 updates #58

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_BASE_URL=http://localhost:8003
VITE_GOOGLE_MAPS_KEY=AIzaSyBw0uqvcSsyWIiAtoGcZEdRbfiGG67e2rE
20 changes: 20 additions & 0 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
41 changes: 21 additions & 20 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
6 changes: 3 additions & 3 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# pull official base image
FROM node:19.0-alpine
FROM node:21-alpine

# set working directory
WORKDIR /usr/src/app

# add `/usr/src/app/node_modules/.bin` to $PATH
# add _/usr/src/app/node_modules/.bin_ to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH

# install app dependencies
COPY package.json .
COPY yarn.lock .
RUN yarn install --production
RUN yarn install

# copy project
COPY . .
72 changes: 5 additions & 67 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,8 @@
# Getting Started with Create React App
# React + Vite

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

## Available Scripts
Currently, two official plugins are available:

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `yarn build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
10 changes: 7 additions & 3 deletions client/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const { defineConfig } = require("cypress");
import { defineConfig } from "cypress";

module.exports = defineConfig({
export default defineConfig({
e2e: {
baseUrl: "http://localhost:3001",
baseUrl: "http://localhost:5174",
env: {
credentials: {
username: "[email protected]",
password: "pAssw0rd",
},
},
experimentalRunAllSpecs: true,
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
100 changes: 50 additions & 50 deletions client/cypress/e2e/authentication.cy.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
const faker = require('faker');
const faker = require('faker')

const email = faker.internet.email();
const firstName = faker.name.firstName();
const lastName = faker.name.lastName();
const email = faker.internet.email()
const firstName = faker.name.firstName()
const lastName = faker.name.lastName()

describe('Authentication', function () {
it('Can sign up.', function () {
cy.addUser(email, firstName, lastName, 'rider');
});
cy.addUser(email, firstName, lastName, 'rider')
})

it('Cannot visit the sign up page when logged in.', function () {
cy.logIn(email);
cy.visit('/#/sign-up');
cy.hash().should('eq', '#/');
});
cy.logIn(email)
cy.visit('/#/sign-up')
cy.hash().should('eq', '#/')
})

it('Can log out.', function () {
cy.logIn(email);
cy.logIn(email)
cy.get('[data-cy="logOut"]').click().should(() => {
expect(window.localStorage.getItem('taxi.auth')).to.be.null;
});
cy.get('[data-cy="logOut"]').should('not.exist');
});
expect(window.localStorage.getItem('taxi.auth')).to.be.null
})
cy.get('[data-cy="logOut"]').should('not.exist')
})

it('Show invalid fields on sign up error.', function () {
cy.intercept('POST', 'sign_up', {
Expand All @@ -31,41 +31,41 @@ describe('Authentication', function () {
'A user with that username already exists.'
]
}
}).as('signUp');
cy.visit('/#/sign-up');
cy.get('input#username').type(email);
cy.get('input#firstName').type('Gary');
cy.get('input#lastName').type('Cole');
cy.get('input#password').type('pAssw0rd', { log: false });
cy.get('select#group').select('driver');
}).as('signUp')
cy.visit('/#/sign-up')
cy.get('input#username').type(email)
cy.get('input#firstName').type('Gary')
cy.get('input#lastName').type('Cole')
cy.get('input#password').type('pAssw0rd', { log: false })
cy.get('select#group').select('driver')

// Handle file upload
cy.get('input#photo').attachFile('images/photo.jpg');
cy.get('button').contains('Sign up').click();
cy.wait('@signUp');
cy.get('input#photo').selectFile('cypress/fixtures/images/photo.jpg')
cy.get('button').contains('Sign up').click()
cy.wait('@signUp')
cy.get('div.invalid-feedback').contains(
'A user with that username already exists'
);
cy.hash().should('eq', '#/sign-up');
});
)
cy.hash().should('eq', '#/sign-up')
})

it('Can log in.', function () {
cy.logIn(email);
cy.hash().should('eq', '#/');
cy.get('button').contains('Log out');
});
cy.logIn(email)
cy.hash().should('eq', '#/')
cy.get('button').contains('Log out')
})

it('Cannot visit the login page when logged in.', function () {
cy.logIn(email);
cy.visit('/#/log-in');
cy.hash().should('eq', '#/');
});
cy.logIn(email)
cy.visit('/#/log-in')
cy.hash().should('eq', '#/')
})

it('Cannot see links when logged in.', function () {
cy.logIn(email);
cy.get('[data-cy="signUp"]').should('not.exist');
cy.get('[data-cy="logIn"]').should('not.exist');
});
cy.logIn(email)
cy.get('[data-cy="signUp"]').should('not.exist')
cy.get('[data-cy="logIn"]').should('not.exist')
})

it('Shows an alert on login error.', function () {
cy.intercept('POST', 'log_in', {
Expand All @@ -76,16 +76,16 @@ describe('Authentication', function () {
'Note that both fields may be case-sensitive.'
]
}
}).as('logIn');
cy.visit('/#/log-in');
cy.get('input#username').type(email);
cy.get('input#password').type('pAssw0rd', { log: false });
cy.get('button').contains('Log in').click();
cy.wait('@logIn');
}).as('logIn')
cy.visit('/#/log-in')
cy.get('input#username').type(email)
cy.get('input#password').type('pAssw0rd', { log: false })
cy.get('button').contains('Log in').click()
cy.wait('@logIn')
cy.get('div.alert').contains(
'Please enter a correct username and password. ' +
'Note that both fields may be case-sensitive.'
);
cy.hash().should('eq', '#/log-in');
});
});
)
cy.hash().should('eq', '#/log-in')
})
})
Loading