Skip to content

Commit

Permalink
Merge pull request #58 from CMU-17-356/integration
Browse files Browse the repository at this point in the history
add integration tests for user and employee
  • Loading branch information
samflattery authored Mar 22, 2022
2 parents 7ee772a + 3c42c80 commit d41bd85
Show file tree
Hide file tree
Showing 54 changed files with 820 additions and 600 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
# Run eslint
name: Run Eslint
name: Run Eslint in backend

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
run-lint:
run-lint-backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Node
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install Packages
run: npm ci

Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/eslint-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Run eslint
name: Run Eslint in frontend

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
run-lint-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Node
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install Packages
run: npm ci

- name: Lint Code Base
run: npm run lint
3 changes: 3 additions & 0 deletions .github/workflows/npm-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
jobs:
run-check:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Run all tests
name: Run Tests
name: Run Tests on backend

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
run-tests:
run-tests-backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/tests-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Run all tests
name: Run Tests on frontend

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
run-tests-frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Node
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install Packages
run: npm ci

- name: Run all tests
run: npm run test
24 changes: 24 additions & 0 deletions backend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
'env': {
'browser': true,
'es2021': true,
},
'extends': [
'google',
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'ecmaFeatures': {
'jsx': true,
},
'ecmaVersion': 'latest',
'sourceType': 'module',
},
'plugins': [
'@typescript-eslint',
],
'rules': {
'linebreak-style': 0,
'object-curly-spacing': ['error', 'always'],
},
};
1 change: 0 additions & 1 deletion backend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ const config: Config.InitialOptions = {
'jest-transform-stub',
},
testEnvironment: 'node',
projects: ['./database', './src'],
};
export default config;
2 changes: 1 addition & 1 deletion backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
"type": "git",
"url": "git+https://github.com/CMU-17-356/dronuts2022-group2.git"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"author": "",
"license": "MIT",
"bugs": {
Expand All @@ -39,7 +33,7 @@
"babel-jest": "^27.5.1",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react": "^7.29.4",
"jest": "^27.5.1",
"jest-transform-stub": "^2.0.0",
"react-test-renderer": "^17.0.2",
Expand Down
14 changes: 0 additions & 14 deletions backend/src/database/jest.config.ts

This file was deleted.

10 changes: 5 additions & 5 deletions backend/src/database/schemas/address_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export interface Address {
}

const addressSchema = new Schema<Address>({
street: {type: String, required: true },
city: {type: String },
state: {type: String },
zip: {type: String },
street: { type: String, required: true },
city: { type: String },
state: { type: String },
zip: { type: String },
});

const AddressModel = mongoose.model<Address>('Address', addressSchema);

export { addressSchema, AddressModel};
export { addressSchema, AddressModel };
10 changes: 5 additions & 5 deletions backend/src/database/schemas/donut_schema.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import mongoose, { Schema } from 'mongoose';

export interface Donut {
"name" : string, // Unique doughnut name
"price" : number, // Price in donutbucks (or whatever the world uses these days)
"description": string, // Longer description of doughnut
"imageurl": string, // Path to an image of the donut
'name' : string, // Unique doughnut name
'price' : number, // Price in donutbucks
'description': string, // Longer description of doughnut
'imageurl': string, // Path to an image of the donut
}

const donutSchema = new Schema<Donut>({
name: { type: String, required: true },
price: { type: Number, min: 0 },
description: { type: String },
imageurl: {type: String }
imageurl: { type: String },
});
const DonutModel = mongoose.model<Donut>('Donut', donutSchema);

Expand Down
8 changes: 4 additions & 4 deletions backend/src/database/schemas/drone_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import mongoose, { Schema } from 'mongoose';


export interface Drone {
"id" : number, // Unique drone ID
"charge" : number, // Remaining charge % [0,100]
"destinations": string[] // Drone's current route
'id' : number, // Unique drone ID
'charge' : number, // Remaining charge % [0,100]
'destinations': string[] // Drone's current route
}

const droneSchema = new Schema<Drone>({
id: { type: Number, required: true },
charge: { type: Number, min: 0, max: 1 },
destinations: { type: [String]},
destinations: { type: [String] },
});

const DroneModel = mongoose.model<Drone>('Drone', droneSchema);
Expand Down
16 changes: 8 additions & 8 deletions backend/src/database/schemas/order_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { User, userSchema } from './user_schema';
import { Address, addressSchema } from './address_schema';

export interface Order {
"order_id" : number, // Unique identifier for this order.
"user" : User, // User
"price" : number, // Price of all donuts, ±tax.
"donuts": Donut[], // List of ordered doughnuts
"quantities": number[], // Parallel list to doughnuts with the number of doughnuts being bought.
"destination": Address, // Location that the order is being sent to.
'order_id' : number, // Unique identifier for this order.
'user' : User, // User
'price' : number, // Price of all donuts, ±tax.
'donuts': Donut[], // List of ordered doughnuts
'quantities': number[], // Parallel list to doughnuts with number of donuts.
'destination': Address, // Location that the order is being sent to.
}

const orderSchema = new Schema<Order>({
Expand All @@ -18,8 +18,8 @@ const orderSchema = new Schema<Order>({
user: { type: userSchema, required: true },
// Total price of order.
price: { type: Number, min: 0 },
donuts: { type: [donutSchema], required:true },
quantities: { type: [Number], required:true },
donuts: { type: [donutSchema], required: true },
quantities: { type: [Number], required: true },
// Address that order will be delivered to.
destination: { type: addressSchema },
});
Expand Down
10 changes: 5 additions & 5 deletions backend/src/database/schemas/user_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import mongoose, { Schema } from 'mongoose';
import { Donut, donutSchema } from './donut_schema';

export interface User {
"username" : string, // Unique
"password" : string, // Hashed password
"employee": boolean, // boolean for whether user is an employee
'username' : string, // Unique
'password' : string, // Hashed password
'employee': boolean, // boolean for whether user is an employee
// list of previous orders
"previous_orders": Donut[],
'previous_orders': Donut[],
}

const userSchema = new Schema<User>({
Expand All @@ -15,7 +15,7 @@ const userSchema = new Schema<User>({
// Hashed password
password: { type: String, required: true },
employee: { type: Boolean, required: true },
previous_orders: {type: [donutSchema]}
previous_orders: { type: [donutSchema] },
});

const UserModel = mongoose.model<User>('User', userSchema);
Expand Down
2 changes: 1 addition & 1 deletion backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,5 @@ app.get('/donuts', (req: express.Request, res: express.Response) => {
});

app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
console.log(`Example app listening on port ${port}`);
});
2 changes: 1 addition & 1 deletion .eslintrc.js → frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
},
'extends': [
'plugin:react/recommended',
'google',
// 'google',
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
Expand Down
10 changes: 5 additions & 5 deletions frontend/database/schemas/address_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export interface Address {
}

const addressSchema = new Schema<Address>({
street: {type: String, required: true },
city: {type: String },
state: {type: String },
zip: {type: String },
street: { type: String, required: true },
city: { type: String },
state: { type: String },
zip: { type: String },
});

const AddressModel = mongoose.model<Address>('Address', addressSchema);

export { addressSchema, AddressModel};
export { addressSchema, AddressModel };
10 changes: 5 additions & 5 deletions frontend/database/schemas/donut_schema.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import mongoose, { Schema } from 'mongoose';

export interface Donut {
"name" : string, // Unique doughnut name
"price" : number, // Price in donutbucks (or whatever the world uses these days)
"description": string, // Longer description of doughnut
"imageurl": string, // Path to an image of the donut
'name' : string, // Unique doughnut name
'price' : number, // Price in donutbucks (or whatever the world uses these days)
'description': string, // Longer description of doughnut
'imageurl': string, // Path to an image of the donut
}

const donutSchema = new Schema<Donut>({
name: { type: String, required: true },
price: { type: Number, min: 0 },
description: { type: String },
imageurl: {type: String }
imageurl: { type: String },
});
const DonutModel = mongoose.model<Donut>('Donut', donutSchema);

Expand Down
6 changes: 3 additions & 3 deletions frontend/database/schemas/drone_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import mongoose, { Schema } from 'mongoose';


export interface Drone {
"id" : number, // Unique drone ID
"charge" : number, // Remaining charge % [0,100]
"position": string // Drone's current position
'id' : number, // Unique drone ID
'charge' : number, // Remaining charge % [0,100]
'position': string // Drone's current position
}

const droneSchema = new Schema<Drone>({
Expand Down
Loading

0 comments on commit d41bd85

Please sign in to comment.