diff --git a/apps/backend-e2e/.eslintrc.json b/apps/backend-e2e/.eslintrc.json deleted file mode 100644 index 9d9c0db5..00000000 --- a/apps/backend-e2e/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/apps/backend-e2e/jest.config.ts b/apps/backend-e2e/jest.config.ts deleted file mode 100644 index befc444b..00000000 --- a/apps/backend-e2e/jest.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'apps/backend-e2e', - preset: '../../jest.preset.js', - globalSetup: '/src/support/global-setup.ts', - globalTeardown: '/src/support/global-teardown.ts', - setupFiles: ['/src/support/test-setup.ts'], - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - }, - ], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/apps/backend-e2e', -}; diff --git a/apps/backend-e2e/project.json b/apps/backend-e2e/project.json deleted file mode 100644 index 28491170..00000000 --- a/apps/backend-e2e/project.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "apps/backend-e2e", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "implicitDependencies": ["apps/backend"], - "projectType": "application", - "targets": { - "e2e": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{e2eProjectRoot}"], - "options": { - "jestConfig": "apps/backend-e2e/jest.config.ts", - "passWithNoTests": true - } - }, - "lint": { - "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/backend-e2e/**/*.{js,ts}"] - } - } - } -} diff --git a/apps/backend-e2e/src/apps/backend/apps/backend.spec.ts b/apps/backend-e2e/src/apps/backend/apps/backend.spec.ts deleted file mode 100644 index e8ac2a6c..00000000 --- a/apps/backend-e2e/src/apps/backend/apps/backend.spec.ts +++ /dev/null @@ -1,10 +0,0 @@ -import axios from 'axios'; - -describe('GET /api', () => { - it('should return a message', async () => { - const res = await axios.get(`/api`); - - expect(res.status).toBe(200); - expect(res.data).toEqual({ message: 'Hello API' }); - }); -}); diff --git a/apps/backend-e2e/src/support/global-setup.ts b/apps/backend-e2e/src/support/global-setup.ts deleted file mode 100644 index c1f51444..00000000 --- a/apps/backend-e2e/src/support/global-setup.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* eslint-disable */ -var __TEARDOWN_MESSAGE__: string; - -module.exports = async function () { - // Start services that that the app needs to run (e.g. database, docker-compose, etc.). - console.log('\nSetting up...\n'); - - // Hint: Use `globalThis` to pass variables to global teardown. - globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n'; -}; diff --git a/apps/backend-e2e/src/support/global-teardown.ts b/apps/backend-e2e/src/support/global-teardown.ts deleted file mode 100644 index 32ea345c..00000000 --- a/apps/backend-e2e/src/support/global-teardown.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable */ - -module.exports = async function () { - // Put clean up logic here (e.g. stopping services, docker-compose, etc.). - // Hint: `globalThis` is shared between setup and teardown. - console.log(globalThis.__TEARDOWN_MESSAGE__); -}; diff --git a/apps/backend-e2e/src/support/test-setup.ts b/apps/backend-e2e/src/support/test-setup.ts deleted file mode 100644 index 07f28703..00000000 --- a/apps/backend-e2e/src/support/test-setup.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* eslint-disable */ - -import axios from 'axios'; - -module.exports = async function () { - // Configure axios for tests to use. - const host = process.env.HOST ?? 'localhost'; - const port = process.env.PORT ?? '3000'; - axios.defaults.baseURL = `http://${host}:${port}`; -}; diff --git a/apps/backend-e2e/tsconfig.json b/apps/backend-e2e/tsconfig.json deleted file mode 100644 index ed633e1d..00000000 --- a/apps/backend-e2e/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.spec.json" - } - ], - "compilerOptions": { - "esModuleInterop": true - } -} diff --git a/apps/backend-e2e/tsconfig.spec.json b/apps/backend-e2e/tsconfig.spec.json deleted file mode 100644 index d7f9cf20..00000000 --- a/apps/backend-e2e/tsconfig.spec.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": ["jest.config.ts", "src/**/*.ts"] -} diff --git a/apps/backend/src/allocations/allocations.controller.ts b/apps/backend/src/allocations/allocations.controller.ts index 44776a3d..d8d2324d 100644 --- a/apps/backend/src/allocations/allocations.controller.ts +++ b/apps/backend/src/allocations/allocations.controller.ts @@ -5,11 +5,4 @@ import { Allocation } from './allocations.entity'; @Controller('allocations') export class AllocationsController { constructor(private allocationsService: AllocationsService) {} - - @Get(':orderId/get-all-allocations') - async getAllAllocationsByOrder( - @Param('orderId', ParseIntPipe) orderId: number, - ): Promise { - return this.allocationsService.getAllAllocationsByOrder(orderId); - } } diff --git a/apps/backend/src/allocations/allocations.module.ts b/apps/backend/src/allocations/allocations.module.ts index 26e36b74..fed7360b 100644 --- a/apps/backend/src/allocations/allocations.module.ts +++ b/apps/backend/src/allocations/allocations.module.ts @@ -10,5 +10,6 @@ import { JwtStrategy } from '../auth/jwt.strategy'; imports: [TypeOrmModule.forFeature([Allocation])], controllers: [AllocationsController], providers: [AllocationsService, AuthService, JwtStrategy], + exports: [AllocationsService], }) export class AllocationModule {} diff --git a/apps/backend/src/allocations/allocations.service.ts b/apps/backend/src/allocations/allocations.service.ts index a2797376..d5bbf460 100644 --- a/apps/backend/src/allocations/allocations.service.ts +++ b/apps/backend/src/allocations/allocations.service.ts @@ -11,10 +11,17 @@ export class AllocationsService { async getAllAllocationsByOrder( orderId: number, - ): Promise { + ): Promise[]> { return this.repo.find({ - where: { orderId: orderId }, + where: { orderId }, relations: ['item'], + select: { + allocationId: true, + allocatedQuantity: true, + reservedAt: true, + fulfilledAt: true, + status: true, + }, }); } } diff --git a/apps/backend/src/orders/order.controller.spec.ts b/apps/backend/src/orders/order.controller.spec.ts new file mode 100644 index 00000000..b03201ee --- /dev/null +++ b/apps/backend/src/orders/order.controller.spec.ts @@ -0,0 +1,75 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { OrdersController } from './order.controller'; +import { OrdersService } from './order.service'; +import { AllocationsService } from '../allocations/allocations.service'; +import { Order } from './order.entity'; +import { Allocation } from '../allocations/allocations.entity'; +import { mock } from 'jest-mock-extended'; + +const mockOrdersService = mock(); +const mockAllocationsService = mock(); + +describe('OrdersController', () => { + let controller: OrdersController; + + const mockOrders: Partial[] = [ + { orderId: 1, status: 'pending' }, + { orderId: 2, status: 'delivered' }, + ]; + + const mockAllocations: Partial[] = [ + { allocationId: 1, orderId: 1 }, + { allocationId: 2, orderId: 1 }, + { allocationId: 3, orderId: 2 }, + ]; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [OrdersController], + providers: [ + { provide: OrdersService, useValue: mockOrdersService }, + { provide: AllocationsService, useValue: mockAllocationsService }, + ], + }).compile(); + + controller = module.get(OrdersController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); + + describe('getAllOrders', () => { + it('should call ordersService.getAll and return orders', async () => { + const status = 'pending'; + const pantryNames = ['Test Pantry', 'Test Pantry 2']; + mockOrdersService.getAll.mockResolvedValueOnce([ + mockOrders[0], + ] as Order[]); + + const result = await controller.getAllOrders(status, pantryNames); + + expect(result).toEqual([mockOrders[0]] as Order[]); + expect(mockOrdersService.getAll).toHaveBeenCalledWith({ + status, + pantryNames, + }); + }); + }); + + describe('getAllAllocationsByOrder', () => { + it('should call allocationsService.getAllAllocationsByOrder and return allocations', async () => { + const orderId = 1; + mockAllocationsService.getAllAllocationsByOrder.mockResolvedValueOnce( + mockAllocations.slice(0, 2) as Allocation[], + ); + + const result = await controller.getAllAllocationsByOrder(orderId); + + expect(result).toEqual(mockAllocations.slice(0, 2) as Allocation[]); + expect( + mockAllocationsService.getAllAllocationsByOrder, + ).toHaveBeenCalledWith(orderId); + }); + }); +}); diff --git a/apps/backend/src/orders/order.controller.ts b/apps/backend/src/orders/order.controller.ts index 9b8579d0..42f2214b 100644 --- a/apps/backend/src/orders/order.controller.ts +++ b/apps/backend/src/orders/order.controller.ts @@ -5,6 +5,7 @@ import { Param, ParseIntPipe, Body, + Query, } from '@nestjs/common'; import { OrdersService } from './order.service'; import { Order } from './order.entity'; @@ -12,14 +13,26 @@ import { Pantry } from '../pantries/pantries.entity'; import { FoodManufacturer } from '../foodManufacturers/manufacturer.entity'; import { FoodRequest } from '../foodRequests/request.entity'; import { Donation } from '../donations/donations.entity'; +import { AllocationsService } from '../allocations/allocations.service'; @Controller('orders') export class OrdersController { - constructor(private ordersService: OrdersService) {} + constructor( + private readonly ordersService: OrdersService, + private readonly allocationsService: AllocationsService, + ) {} - @Get('/get-all-orders') - async getAllOrders(): Promise { - return this.ordersService.getAll(); + // Called like: /?status=pending&pantryName=Test%20Pantry&pantryName=Test%20Pantry%2 + // %20 is the URL encoded space character + @Get('/') + async getAllOrders( + @Query('status') status?: string, + @Query('pantryName') pantryNames?: string | string[], + ): Promise { + if (typeof pantryNames === 'string') { + pantryNames = [pantryNames]; + } + return this.ordersService.getAll({ status, pantryNames }); } @Get('/get-current-orders') @@ -74,6 +87,13 @@ export class OrdersController { return this.ordersService.findOrderByRequest(requestId); } + @Get(':orderId/allocations') + async getAllAllocationsByOrder( + @Param('orderId', ParseIntPipe) orderId: number, + ) { + return this.allocationsService.getAllAllocationsByOrder(orderId); + } + @Patch('/update-status/:orderId') async updateStatus( @Param('orderId', ParseIntPipe) orderId: number, diff --git a/apps/backend/src/orders/order.module.ts b/apps/backend/src/orders/order.module.ts index fe2d5584..bf07f1cd 100644 --- a/apps/backend/src/orders/order.module.ts +++ b/apps/backend/src/orders/order.module.ts @@ -5,9 +5,10 @@ import { Order } from './order.entity'; import { OrdersService } from './order.service'; import { JwtStrategy } from '../auth/jwt.strategy'; import { AuthService } from '../auth/auth.service'; +import { AllocationModule } from '../allocations/allocations.module'; @Module({ - imports: [TypeOrmModule.forFeature([Order])], + imports: [TypeOrmModule.forFeature([Order]), AllocationModule], controllers: [OrdersController], providers: [OrdersService, AuthService, JwtStrategy], }) diff --git a/apps/backend/src/orders/order.service.spec.ts b/apps/backend/src/orders/order.service.spec.ts new file mode 100644 index 00000000..586da4c2 --- /dev/null +++ b/apps/backend/src/orders/order.service.spec.ts @@ -0,0 +1,185 @@ +import { Test } from '@nestjs/testing'; +import { getRepositoryToken } from '@nestjs/typeorm'; +import { Repository, SelectQueryBuilder } from 'typeorm'; +import { Order } from './order.entity'; +import { OrdersService } from './order.service'; +import { mock } from 'jest-mock-extended'; +import { Pantry } from '../pantries/pantries.entity'; +import { User } from '../users/user.entity'; + +const mockOrdersRepository = mock>(); + +const mockPantry: Pantry = { + pantryId: 1, + pantryName: 'Test Pantry', + address: '123 Test St', + allergenClients: '', + refrigeratedDonation: '', + reserveFoodForAllergic: false, + reservationExplanation: '', + dedicatedAllergyFriendly: '', + clientVisitFrequency: '', + identifyAllergensConfidence: '', + serveAllergicChildren: '', + newsletterSubscription: false, + restrictions: [], + ssfRepresentative: null as unknown as User, + pantryRepresentative: null as unknown as User, + status: 'active', + dateApplied: new Date(), + activities: '', + questions: null, + itemsInStock: '', + needMoreOptions: '', +}; + +describe('OrdersService', () => { + let service: OrdersService; + let qb: SelectQueryBuilder; + + beforeAll(async () => { + mockOrdersRepository.createQueryBuilder.mockReset(); + + const module = await Test.createTestingModule({ + providers: [ + OrdersService, + { + provide: getRepositoryToken(Order), + useValue: mockOrdersRepository, + }, + ], + }).compile(); + + service = module.get(OrdersService); + }); + + beforeEach(() => { + qb = { + leftJoinAndSelect: jest.fn().mockReturnThis(), + select: jest.fn().mockReturnThis(), + andWhere: jest.fn().mockReturnThis(), + getMany: jest.fn().mockResolvedValue([]), + } as unknown as SelectQueryBuilder; + + mockOrdersRepository.createQueryBuilder.mockReturnValue(qb); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); + + describe('getAll', () => { + it('should return orders filtered by status', async () => { + const mockOrders: Partial[] = [ + { orderId: 1, status: 'pending' }, + { orderId: 2, status: 'delivered' }, + ]; + + (qb.getMany as jest.Mock).mockResolvedValue([mockOrders[0] as Order]); + + const result = await service.getAll({ status: 'pending' }); + + expect(result).toEqual([mockOrders[0]]); + expect(qb.andWhere).toHaveBeenCalledWith('order.status = :status', { + status: 'pending', + }); + }); + + it('should return empty array when no status filters match', async () => { + (qb.getMany as jest.Mock).mockResolvedValue([]); + + const result = await service.getAll({ status: 'invalid status' }); + + expect(result).toEqual([]); + expect(qb.andWhere).toHaveBeenCalledWith('order.status = :status', { + status: 'invalid status', + }); + }); + + it('should return orders filtered by pantryName', async () => { + const mockOrders: Partial[] = [ + { + orderId: 3, + status: 'delivered', + pantry: { ...mockPantry, pantryName: 'Test Pantry' }, + }, + { + orderId: 4, + status: 'delivered', + pantry: { ...mockPantry, pantryName: 'Test Pantry 2' }, + }, + { + orderId: 5, + status: 'delivered', + pantry: { ...mockPantry, pantryName: 'Test Pantry 3' }, + }, + ]; + + (qb.getMany as jest.Mock).mockResolvedValue( + mockOrders.slice(0, 2) as Order[], + ); + + const result = await service.getAll({ + pantryNames: ['Test Pantry', 'Test Pantry 2'], + }); + + expect(result).toEqual(mockOrders.slice(0, 2) as Order[]); + expect(qb.andWhere).toHaveBeenCalledWith( + 'pantry.pantryName IN (:...pantryNames)', + { pantryNames: ['Test Pantry', 'Test Pantry 2'] }, + ); + }); + + it('should return empty array when no pantryName filters match', async () => { + (qb.getMany as jest.Mock).mockResolvedValue([]); + + const result = await service.getAll({ + pantryNames: ['Nonexistent Pantry'], + }); + + expect(result).toEqual([]); + expect(qb.andWhere).toHaveBeenCalledWith( + 'pantry.pantryName IN (:...pantryNames)', + { pantryNames: ['Nonexistent Pantry'] }, + ); + }); + + it('should return orders filtered by both status and pantryName', async () => { + const mockOrders: Partial[] = [ + { + orderId: 3, + status: 'delivered', + pantry: { ...mockPantry, pantryName: 'Test Pantry 1' }, + }, + { + orderId: 4, + status: 'delivered', + pantry: { ...mockPantry, pantryName: 'Test Pantry 2' }, + }, + { + orderId: 5, + status: 'delivered', + pantry: { ...mockPantry, pantryName: 'Test Pantry 2' }, + }, + ]; + + (qb.getMany as jest.Mock).mockResolvedValue( + mockOrders.slice(1, 3) as Order[], + ); + + const result = await service.getAll({ + status: 'delivered', + pantryNames: ['Test Pantry 2'], + }); + + expect(result).toEqual(mockOrders.slice(1, 3) as Order[]); + expect(qb.andWhere).toHaveBeenCalledWith('order.status = :status', { + status: 'delivered', + }); + expect(qb.andWhere).toHaveBeenCalledWith( + 'pantry.pantryName IN (:...pantryNames)', + { pantryNames: ['Test Pantry 2'] }, + ); + }); + }); +}); diff --git a/apps/backend/src/orders/order.service.ts b/apps/backend/src/orders/order.service.ts index ad1e280c..611de4bd 100644 --- a/apps/backend/src/orders/order.service.ts +++ b/apps/backend/src/orders/order.service.ts @@ -12,8 +12,30 @@ import { validateId } from '../utils/validation.utils'; export class OrdersService { constructor(@InjectRepository(Order) private repo: Repository) {} - async getAll() { - return this.repo.find(); + async getAll(filters?: { status?: string; pantryNames?: string[] }) { + const qb = this.repo + .createQueryBuilder('order') + .leftJoinAndSelect('order.pantry', 'pantry') + .select([ + 'order.orderId', + 'order.status', + 'order.createdAt', + 'order.shippedAt', + 'order.deliveredAt', + 'pantry.pantryName', + ]); + + if (filters?.status) { + qb.andWhere('order.status = :status', { status: filters.status }); + } + + if (filters?.pantryNames) { + qb.andWhere('pantry.pantryName IN (:...pantryNames)', { + pantryNames: filters.pantryNames, + }); + } + + return qb.getMany(); } async getCurrentOrders() { diff --git a/apps/backend/src/pantries/pantries.entity.ts b/apps/backend/src/pantries/pantries.entity.ts index 354d0caf..1b4fd689 100644 --- a/apps/backend/src/pantries/pantries.entity.ts +++ b/apps/backend/src/pantries/pantries.entity.ts @@ -29,7 +29,7 @@ export class Pantry { reserveFoodForAllergic: boolean; @Column({ name: 'reservation_explanation', type: 'text' }) - reservationExplanation: Text; + reservationExplanation: string; @Column({ name: 'dedicated_allergy_friendly', type: 'varchar', length: 255 }) dedicatedAllergyFriendly: string; diff --git a/apps/frontend-e2e/.eslintrc.json b/apps/frontend-e2e/.eslintrc.json deleted file mode 100644 index 696cb8b1..00000000 --- a/apps/frontend-e2e/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": ["plugin:cypress/recommended", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/apps/frontend-e2e/cypress.config.ts b/apps/frontend-e2e/cypress.config.ts deleted file mode 100644 index a45b4fd6..00000000 --- a/apps/frontend-e2e/cypress.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { defineConfig } from 'cypress'; -import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset'; - -export default defineConfig({ - e2e: nxE2EPreset(__dirname, { - bundler: 'vite', - }), -}); diff --git a/apps/frontend-e2e/project.json b/apps/frontend-e2e/project.json deleted file mode 100644 index eac6b111..00000000 --- a/apps/frontend-e2e/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "frontend-e2e", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "apps/frontend-e2e/src", - "projectType": "application", - "targets": { - "e2e": { - "executor": "@nx/cypress:cypress", - "options": { - "cypressConfig": "apps/frontend-e2e/cypress.config.ts", - "devServerTarget": "frontend:serve:development", - "testingType": "e2e" - }, - "configurations": { - "production": { - "devServerTarget": "frontend:serve:production" - }, - "ci": { - "devServerTarget": "frontend:serve-static" - } - } - }, - "lint": { - "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/frontend-e2e/**/*.{js,ts}"] - } - } - }, - "tags": [], - "implicitDependencies": ["frontend"] -} diff --git a/apps/frontend-e2e/src/e2e/app.cy.ts b/apps/frontend-e2e/src/e2e/app.cy.ts deleted file mode 100644 index c37b7f7c..00000000 --- a/apps/frontend-e2e/src/e2e/app.cy.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { getGreeting } from '../support/app.po'; - -describe('frontend', () => { - beforeEach(() => cy.visit('/')); - - it('should display welcome message', () => { - // Custom command example, see `../support/commands.ts` file - cy.login('my-email@something.com', 'myPassword'); - - // Function helper example, see `../support/app.po.ts` file - getGreeting().contains('Welcome frontend'); - }); -}); diff --git a/apps/frontend-e2e/src/fixtures/example.json b/apps/frontend-e2e/src/fixtures/example.json deleted file mode 100644 index 294cbed6..00000000 --- a/apps/frontend-e2e/src/fixtures/example.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io" -} diff --git a/apps/frontend-e2e/src/support/app.po.ts b/apps/frontend-e2e/src/support/app.po.ts deleted file mode 100644 index 32934246..00000000 --- a/apps/frontend-e2e/src/support/app.po.ts +++ /dev/null @@ -1 +0,0 @@ -export const getGreeting = () => cy.get('h1'); diff --git a/apps/frontend-e2e/src/support/commands.ts b/apps/frontend-e2e/src/support/commands.ts deleted file mode 100644 index 310f1fa0..00000000 --- a/apps/frontend-e2e/src/support/commands.ts +++ /dev/null @@ -1,33 +0,0 @@ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** - -// eslint-disable-next-line @typescript-eslint/no-namespace -declare namespace Cypress { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - interface Chainable { - login(email: string, password: string): void; - } -} -// -// -- This is a parent command -- -Cypress.Commands.add('login', (email, password) => { - console.log('Custom command example: Login', email, password); -}); -// -// -- This is a child command -- -// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/apps/frontend-e2e/src/support/e2e.ts b/apps/frontend-e2e/src/support/e2e.ts deleted file mode 100644 index 3d469a6b..00000000 --- a/apps/frontend-e2e/src/support/e2e.ts +++ /dev/null @@ -1,17 +0,0 @@ -// *********************************************************** -// This example support/index.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands'; diff --git a/apps/frontend-e2e/tsconfig.json b/apps/frontend-e2e/tsconfig.json deleted file mode 100644 index cc509a73..00000000 --- a/apps/frontend-e2e/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "sourceMap": false, - "outDir": "../../dist/out-tsc", - "allowJs": true, - "types": ["cypress", "node"] - }, - "include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"] -} diff --git a/apps/frontend/src/api/apiClient.ts b/apps/frontend/src/api/apiClient.ts index 2b8c5ed6..bebdcb56 100644 --- a/apps/frontend/src/api/apiClient.ts +++ b/apps/frontend/src/api/apiClient.ts @@ -165,7 +165,7 @@ export class ApiClient { public async getAllOrders(): Promise { return this.axiosInstance - .get('/api/orders/get-all-orders') + .get('/api/orders/') .then((response) => response.data); } @@ -193,7 +193,7 @@ export class ApiClient { async getAllAllocationsByOrder(orderId: number): Promise { return this.axiosInstance - .get(`api/allocations/${orderId}/get-all-allocations`) + .get(`api/orders/${orderId}/allocations`) .then((response) => response.data); } diff --git a/package.json b/package.json index 83e1b96d..a69ffe4a 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "framer-motion": "^11.5.6", "global": "^4.4.0", "google-libphonenumber": "^3.2.40", + "jest-mock-extended": "^4.0.0", "jwks-rsa": "^3.1.0", "mongodb": "^6.1.0", "multer": "^1.4.5-lts.1", diff --git a/yarn.lock b/yarn.lock index 7a038925..ca4c7ff5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10135,6 +10135,13 @@ jest-message-util@^29.7.0: slash "^3.0.0" stack-utils "^2.0.3" +jest-mock-extended@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jest-mock-extended/-/jest-mock-extended-4.0.0.tgz#fe8cfa686c7ada4be2e7f7a3eced794b1338c18b" + integrity sha512-7BZpfuvLam+/HC+NxifIi9b+5VXj/utUDMPUqrDJehGWVuXPtLS9Jqlob2mJLrI/pg2k1S8DMfKDvEB88QNjaQ== + dependencies: + ts-essentials "^10.0.2" + jest-mock@^29.7.0: version "29.7.0" resolved "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz" @@ -13728,6 +13735,11 @@ ts-api-utils@^2.0.1: resolved "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.0.1.tgz" integrity sha512-dnlgjFSVetynI8nzgJ+qF62efpglpWRk8isUEWZGWlJYySCTD6aKvbUDu+zbPeDakk3bg5H4XpitHukgfL1m9w== +ts-essentials@^10.0.2: + version "10.1.1" + resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-10.1.1.tgz#4e1d29b7c9b33c1a2744482376634c4fafba5210" + integrity sha512-4aTB7KLHKmUvkjNj8V+EdnmuVTiECzn3K+zIbRthumvHu+j44x3w63xpfs0JL3NGIzGXqoQ7AV591xHO+XrOTw== + ts-jest@^29.1.0: version "29.1.1" resolved "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz"