Skip to content

Commit

Permalink
Conflift resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndevu12 committed Jun 5, 2024
2 parents 0fee7ef + d8eed35 commit 42c52a5
Show file tree
Hide file tree
Showing 26 changed files with 5,130 additions and 3,705 deletions.
8,571 changes: 4,902 additions & 3,669 deletions model.nlp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/__test__/getProduct.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Creating new product', () => {

expect(response.status).toBe(201);
expect(response.body.data.product).toBeDefined;
}, 60000);
}, 20000);
});
describe('Get single product', () => {
it('should get a single product', async () => {
Expand Down
3 changes: 1 addition & 2 deletions src/__test__/roleCheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { dbConnection } from '../startups/dbConnection';
import { v4 as uuid } from 'uuid';
import { getConnection } from 'typeorm';
import { cleanDatabase } from './test-assets/DatabaseCleanup';
import { server } from '..';


let reqMock: Partial<Request>;
let resMock: Partial<Response>;
Expand Down Expand Up @@ -37,7 +37,6 @@ beforeAll(async () => {

afterAll(async () => {
await cleanDatabase();
server.close();
});

describe('hasRole MiddleWare Test', () => {
Expand Down
6 changes: 5 additions & 1 deletion src/__test__/test-assets/DatabaseCleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { server } from '../..';
import { VendorOrderItem } from '../../entities/VendorOrderItem';
import { VendorOrders } from '../../entities/vendorOrders';
import { Feedback } from '../../entities/Feedback';
import { NotificationItem } from '../../entities/NotificationItem';
import { Notification } from '../../entities/Notification';

export const cleanDatabase = async () => {
const connection = getConnection();
Expand All @@ -28,6 +30,8 @@ export const cleanDatabase = async () => {
await connection.getRepository(CartItem).delete({});
await connection.getRepository(Cart).delete({});
await connection.getRepository(wishList).delete({});
await connection.getRepository(NotificationItem).delete({});
await connection.getRepository(Notification).delete({});

// Many-to-Many relations
// Clear junction table entries before deleting products and categories
Expand All @@ -49,4 +53,4 @@ export const cleanDatabase = async () => {
// console.log('Database cleaned');
// }).catch(error => {
// console.error('Error cleaning database:', error);
// });
// });
4 changes: 2 additions & 2 deletions src/__test__/vendorProduct.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('Vendor product management tests', () => {

expect(response.status).toBe(201);
expect(response.body.data.product).toBeDefined;
}, 120000);
}, 60000);

it('return an error if the number of product images exceeds 6', async () => {
const response = await request(app)
Expand Down Expand Up @@ -470,4 +470,4 @@ describe('Vendor product management tests', () => {
expect(response.status).toBe(400);
});
});
});
});
2 changes: 1 addition & 1 deletion src/__test__/wishList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@ describe('Wish list management tests', () => {
expect(response.body.message).toBe('All products removed successfully');
});
});
});
});
2 changes: 1 addition & 1 deletion src/controllers/productController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ export const searchProduct = async (req: Request, res: Response) => {
};
export const Payment = async (req: Request, res: Response) => {
await confirmPayment(req, res);
};
};
126 changes: 126 additions & 0 deletions src/docs/notifications.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/notification:
get:
tags:
- Notification Management
summary: Get all user notifications
description: Return all user notifications of an authenticated buyer
security:
- bearerAuth: []
responses:
'200':
description: Return all user notifications for a user
'400':
description: Bad Request (syntax error, incorrect input format, etc..)
'401':
description: Unauthorized
'403':
description: Forbidden (Unauthorized action)
'500':
description: Internal server error

delete:
tags:
- Notification Management
summary: Delete selected notifications
description: Delete all selected notification for an authenticated buyer
security:
- bearerAuth: []
consumes:
- application/json
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
notificationIds:
example: "[]"
responses:
'200':
description: Notifications deleted successfully
'400':
description: Bad Request (syntax error, incorrect input format, etc..)
'401':
description: Unauthorized
'403':
description: Forbidden (Unauthorized action)
'404':
description: Notification not found
'500':
description: Internal server error

put:
tags:
- Notification Management
summary: Update selected notifications
description: Update selected notifications for an authenticated buyer
security:
- bearerAuth: []
consumes:
- application/json
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
notificationIds:
example: "[]"
responses:
'200':
description: Notification updated successfully
'400':
description: Bad Request (syntax error, incorrect input format, etc..)
'401':
description: Unauthorized
'403':
description: Forbidden (Unauthorized action)
'404':
description: Notification not found
'500':
description: Internal server error

/notification/all:
delete:
tags:
- Notification Management
summary: Delete all notifications
description: Delete all notification for an authenticated buyer
security:
- bearerAuth: []
responses:
'200':
description: All notifications deleted successfully
'400':
description: Bad Request (syntax error, incorrect input format, etc..)
'401':
description: Unauthorized
'403':
description: Forbidden (Unauthorized action)
'404':
description: Notification not found
'500':
description: Internal server error

put:
tags:
- Notification Management
summary: Update all notifications
description: Update all notifications for an authenticated buyer
security:
- bearerAuth: []
responses:
'200':
description: Notification updated successfully
'400':
description: Bad Request (syntax error, incorrect input format, etc..)
'401':
description: Unauthorized
'403':
description: Forbidden (Unauthorized action)
'404':
description: Notification not found
'500':
description: Internal server error
29 changes: 29 additions & 0 deletions src/docs/orderDocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,32 @@ paths:
description: Order not found
'500':
description: Internal Server Error

/product/client/orders/{orderId}:
get:
tags:
- Order
summary: Get a single order
description: Retrieve an order for the authenticated user
security:
- bearerAuth: []
parameters:
- in: path
name: orderId
schema:
type: string
required: true
description: The ID of the order
responses:
'200':
description: Order Retrived successfully
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Order not found
'500':
description: Internal Server Error
2 changes: 1 addition & 1 deletion src/entities/Cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ export class Cart {
this.totalAmount = 0;
}
}
}
}
2 changes: 1 addition & 1 deletion src/entities/CartItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ export class CartItem {
updateTotal (): void {
this.total = this.newPrice * this.quantity;
}
}
}
2 changes: 1 addition & 1 deletion src/entities/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export class Category {

@UpdateDateColumn()
updatedAt!: Date;
}
}
2 changes: 1 addition & 1 deletion src/entities/Feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export class Feedback {

@UpdateDateColumn()
updatedAt!: Date;
}
}
1 change: 0 additions & 1 deletion src/entities/Order.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import {
Entity,
PrimaryGeneratedColumn,
Expand Down
2 changes: 1 addition & 1 deletion src/entities/OrderItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export class OrderItem {
@IsNotEmpty()
@IsNumber()
quantity!: number;
}
}
2 changes: 1 addition & 1 deletion src/entities/Product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ export class Product {

@UpdateDateColumn()
updatedAt!: Date;
}
}
2 changes: 1 addition & 1 deletion src/entities/VendorOrderItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export class VendorOrderItem {
@IsNotEmpty()
@IsNumber()
'quantity'!: number;
}
}
2 changes: 1 addition & 1 deletion src/entities/coupon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ export class Coupon {

@UpdateDateColumn()
updatedAt!: Date;
}
}
2 changes: 1 addition & 1 deletion src/entities/vendorOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ export class VendorOrders {

@UpdateDateColumn()
updatedAt!: Date;
}
}
2 changes: 1 addition & 1 deletion src/entities/wishList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export class wishList extends BaseEntity {

@UpdateDateColumn()
updatedAt!: Date;
}
}
7 changes: 4 additions & 3 deletions src/routes/ProductRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
listAllProducts,
singleProduct,
createOrder,
getOrders,
getOrders, getOrder,
updateOrder,
getOrdersHistory,Payment,
getSingleVendorOrder,
Expand All @@ -41,6 +41,7 @@ router.put('/availability/:id', authMiddleware as RequestHandler, hasRole('VENDO

router.post('/orders', authMiddleware as RequestHandler, hasRole('BUYER'), createOrder);
router.get('/client/orders', authMiddleware as RequestHandler, hasRole('BUYER'), getOrders);
router.get('/client/orders/:orderId', authMiddleware as RequestHandler, hasRole('BUYER'), getOrder);
router.put('/client/orders/:orderId', authMiddleware as RequestHandler, hasRole('BUYER'), updateOrder);
router.get('/orders/history', authMiddleware as RequestHandler, hasRole('BUYER'), getOrdersHistory);

Expand All @@ -53,6 +54,6 @@ router.put('/vendor/orders/:id', authMiddleware as RequestHandler, hasRole('VEND
router.get('/admin/orders', authMiddleware as RequestHandler, hasRole('ADMIN'), getBuyerVendorOrders);
router.get('/admin/orders/:id', authMiddleware as RequestHandler, hasRole('ADMIN'), getSingleBuyerVendorOrder);
router.put('/admin/orders/:id', authMiddleware as RequestHandler, hasRole('ADMIN'), updateBuyerVendorOrder);
router.post('/payment/:id', authMiddleware as RequestHandler, hasRole('BUYER'), Payment)
router.post('/payment/:id', authMiddleware as RequestHandler, hasRole('BUYER'), Payment);

export default router;
export default router;
Loading

0 comments on commit 42c52a5

Please sign in to comment.