From 99908e8073f30adacb2feab621d468326a3d8feb Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 09:45:16 +0000 Subject: [PATCH 01/37] refactor: use shared jest.base.js for client and server jest configs --- client/jest.config.js | 8 ++------ server/jest.config.js | 32 ++++---------------------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/client/jest.config.js b/client/jest.config.js index 2912df92..c51439c3 100644 --- a/client/jest.config.js +++ b/client/jest.config.js @@ -1,8 +1,4 @@ +const base = require('./shared/config/jest.base'); module.exports = { - moduleNameMapper: { - "src/(.*)": "/src/$1", - "@shared/(.*)": "/shared/$1" - }, - testEnvironment: 'jsdom', - setupFilesAfterEnv: ['./src/setupTests.js'], + ...base, }; \ No newline at end of file diff --git a/server/jest.config.js b/server/jest.config.js index 74c01139..85ed2082 100644 --- a/server/jest.config.js +++ b/server/jest.config.js @@ -1,29 +1,5 @@ -const { pathsToModuleNameMapper } = require('ts-jest') -const { compilerOptions } = require('./tsconfig') +const { compilerOptions } = require('./tsconfig'); +const makeJestBase = require('./shared/config/jest.base'); module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', - moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths), - modulePaths: [ - '' - ], - maxWorkers: 1, - testRegex: ".*\\.(spec|test)\\.ts$", - transform: { - "^.+\\.(t|j)s$": "ts-jest" - }, - collectCoverageFrom: [ - "**/*.(t|j)s", - "!**/node_modules/**", - "!**/dist/**", - "!**/coverage/**", - "!helpers/**", - "!.eslintrc.js", - "!jest.config.js", - "!**/migrations/**", - "!test/**", - "!**/config/**", - ], - coverageDirectory: "coverage", - coverageReporters: ["json", "lcov", "text", "clover"], -} + ...makeJestBase(compilerOptions), +}; From 99b57609d2387215765cd9b45bb06f8b168116d5 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 09:48:54 +0000 Subject: [PATCH 02/37] chore: update submodule pointers to feat/generalization-2026-04 --- client/shared | 2 +- server/shared | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/shared b/client/shared index 9276a7ea..c5fc4424 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit 9276a7eaa68f99fd88152dd7c845ae0ecf574899 +Subproject commit c5fc44244305a02a0651a536836281c98a3d5a4b diff --git a/server/shared b/server/shared index 2f339e04..da27cbad 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit 2f339e04741a7c1f3ab976c1c4a6e352125c1cbe +Subproject commit da27cbadc5bf995824ecc1c9d53b36701e08f182 From 61033534994eb13507f2689856104945b9a25de9 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 09:51:01 +0000 Subject: [PATCH 03/37] feat: use reusable run-tests workflow from multi-repo-codespace --- .github/workflows/copilot-setup-steps.yml | 69 ++++++++++++++++++++++ .github/workflows/run-tests.yml | 70 ++--------------------- 2 files changed, 74 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/copilot-setup-steps.yml diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 00000000..b6ddb87d --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,69 @@ +name: "Copilot Setup Steps" + +# Automatically run the setup steps when they are changed to allow for easy validation, and +# allow manual testing through the repository's "Actions" tab +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +jobs: + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. + copilot-setup-steps: + runs-on: ubuntu-latest + + # Set the permissions to the lowest permissions possible needed for your steps. + # Copilot will be given its own token for its operations. + permissions: + # Clone the repository to install dependencies + contents: read + + # Environment variables to configure development tools + env: + # Skip Chromium download for Puppeteer (firewall restrictions) + PUPPETEER_SKIP_DOWNLOAD: true + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # Initialize git submodules for shared components + submodules: recursive + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "yarn" + cache-dependency-path: | + server/yarn.lock + client/yarn.lock + + - name: Install server dependencies + working-directory: ./server + run: yarn install --frozen-lockfile + + - name: Install client dependencies + working-directory: ./client + run: yarn install --frozen-lockfile + + # - name: Build server + # working-directory: ./server + # run: yarn build + + # - name: Build client + # working-directory: ./client + # run: yarn build + + # - name: Verify server tests can run + # working-directory: ./server + # run: yarn test --passWithNoTests + + # - name: Verify client tests can run + # working-directory: ./client + # run: yarn test --passWithNoTests diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ff1fbaa7..2e476500 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -3,71 +3,11 @@ name: Run tests on pull request on: pull_request: branches: - - main + - main jobs: - prepare: - name: Prepare changes - runs-on: ubuntu-latest - outputs: - client: ${{ steps.changes.outputs.client }} - server: ${{ steps.changes.outputs.server }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Filter changes - uses: dorny/paths-filter@v2 - id: changes - with: - filters: | - client: - - 'client/**' - server: - - 'server/**' - - - server-tests: - name: Run server tests - runs-on: ubuntu-latest - needs: prepare - if: ${{ needs.prepare.outputs.server == 'true' }} - defaults: - run: - working-directory: ./server - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'yarn' - cache-dependency-path: server/yarn.lock - - run: yarn - - run: yarn test - - run: yarn test:e2e - - - client-tests: - name: Run client tests - runs-on: ubuntu-latest - needs: prepare - if: ${{ needs.prepare.outputs.client == 'true' }} - defaults: - run: - working-directory: ./client - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'yarn' - cache-dependency-path: client/yarn.lock - - run: yarn - - run: yarn test + tests: + uses: buzz-code/multi-repo-codespace/.github/workflows/reusable-tests.yml@main + with: + run_e2e: true From d829c18748aa76f15373818eb20172b116576fe0 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 09:53:43 +0000 Subject: [PATCH 04/37] chore: standardize Dockerfiles and rename docker-compose services to client/server/database --- client/Dockerfile | 12 ++++++------ docker-compose.override.yml.template | 12 ++++++------ docker-compose.yml | 20 ++++++++++---------- server/Dockerfile | 5 +++-- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/client/Dockerfile b/client/Dockerfile index 2d268816..aef78e31 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,14 +1,14 @@ -FROM node:18-alpine as development +FROM node:18-alpine AS development -RUN apk add git +RUN apk add --no-cache git -WORKDIR /app +ENV NODE_ENV development -# COPY package*.json /app/ -# COPY yarn.lock /app/ +WORKDIR /app +# No need to do this, because external node_modules are mounted +# COPY package*.json yarn.lock ./ # RUN yarn install - # COPY . . CMD ["yarn", "start"] diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index 80a77d71..e99832ea 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -1,8 +1,8 @@ version: "3" name: react-admin-nestjs-dev services: - frontend: - container_name: frontend-dev + client: + container_name: client-dev build: target: development environment: @@ -14,8 +14,8 @@ services: networks: - private-network - backend: - container_name: backend-dev + server: + container_name: server-dev build: target: development ports: @@ -25,8 +25,8 @@ services: networks: - private-network - mysql: - container_name: mysql-dev + database: + container_name: database-dev ports: - "3306:3306" # MySQL port for local access diff --git a/docker-compose.yml b/docker-compose.yml index 8b7b7665..4b4e82a0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ version: "3" services: - frontend: - container_name: frontend + client: + container_name: client restart: unless-stopped depends_on: - - backend + - server build: context: ./client target: production @@ -44,8 +44,8 @@ services: window: 120s - backend: - container_name: backend + server: + container_name: server restart: unless-stopped build: context: ./server @@ -64,7 +64,7 @@ services: MAINTENANCE_MODE: $MAINTENANCE_MODE MAINTENANCE_MESSAGE: $MAINTENANCE_MESSAGE depends_on: - - mysql + - database labels: caddy: api.$DOMAIN_NAME caddy.reverse_proxy: "{{upstreams 3000}}" @@ -97,8 +97,8 @@ services: max_attempts: 3 window: 120s - mysql: - container_name: mysql + database: + container_name: database restart: unless-stopped build: context: ./db @@ -119,13 +119,13 @@ services: container_name: php-myadmin restart: unless-stopped depends_on: - - mysql + - database image: phpmyadmin labels: caddy: sql.$DOMAIN_NAME caddy.reverse_proxy: "{{upstreams 80}}" environment: - PMA_HOST: mysql + PMA_HOST: database MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD # ports: # - "80" diff --git a/server/Dockerfile b/server/Dockerfile index 18ddcee4..8bc355ec 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -20,8 +20,6 @@ CMD ["yarn", "start:dev"] FROM node:16-alpine AS builder -RUN apk add curl bash - WORKDIR /app COPY package*.json /app/ @@ -30,6 +28,9 @@ COPY .yarnclean /app/ RUN yarn install --frozen-lockfile +# Copy shared directory first for better layer caching +COPY shared /app/shared +# Copy the rest of the application COPY . . RUN yarn build From 8f9a8a700ad2c039e4ce96c6f72ed15f8f8f7848 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 10:13:42 +0000 Subject: [PATCH 05/37] feat: use shared AppController, AppService, and bootstrapNraApplication --- server/shared | 2 +- server/src/app.controller.ts | 94 +----------------------------------- server/src/app.service.ts | 11 +---- server/src/main.ts | 18 +------ 4 files changed, 5 insertions(+), 120 deletions(-) diff --git a/server/shared b/server/shared index da27cbad..3162ed94 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit da27cbadc5bf995824ecc1c9d53b36701e08f182 +Subproject commit 3162ed94d0e713afc959b547d4506dda691f7c1e diff --git a/server/src/app.controller.ts b/server/src/app.controller.ts index 5c7810d4..f6457c8d 100644 --- a/server/src/app.controller.ts +++ b/server/src/app.controller.ts @@ -1,93 +1 @@ -import { Controller, Get, HttpCode, UnauthorizedException, Post, Request, Res, UseGuards, Body } from '@nestjs/common'; -import { AppService } from 'src/app.service'; -import { AuthService } from '@shared/auth/auth.service'; -import { JwtAuthGuard } from '@shared/auth/jwt-auth.guard'; -import { LocalAuthGuard } from '@shared/auth/local-auth.guard'; -import { Response } from 'express'; -import { LocalRegisterAuthGuard } from '@shared/auth/local-register-auth.guard'; -import { getUserIdFromUser } from '@shared/auth/auth.util'; -import { isAdmin } from '@shared/utils/permissionsUtil'; -import { AuthenticatedRequest } from '@shared/auth/auth.types'; -import { SkipMaintenance } from '@shared/decorators/skip-maintenance.decorator'; - -@Controller() -export class AppController { - constructor( - private readonly appService: AppService, - private authService: AuthService) { } - - @UseGuards(LocalAuthGuard) - @Post('auth/login') - @HttpCode(200) - async login(@Request() req: AuthenticatedRequest, @Res() response: Response) { - const cookie = await this.authService.getCookieWithJwtToken(req.user); - response.setHeader('Set-Cookie', cookie); - return response.send({ success: true }); - } - - @UseGuards(LocalRegisterAuthGuard) - @Post('auth/register') - @HttpCode(200) - async register(@Request() req: AuthenticatedRequest, @Res() response: Response) { - const cookie = await this.authService.getCookieWithJwtToken(req.user); - response.setHeader('Set-Cookie', cookie); - return response.send({ success: true }); - } - - @Post('auth/logout') - async logOut(@Res() response: Response) { - const cookie = await this.authService.getCookieForLogOut(); - response.setHeader('Set-Cookie', cookie); - return response.sendStatus(200); - } - - @UseGuards(JwtAuthGuard) - @Get('profile') - async getProfile(@Request() req: AuthenticatedRequest) { - const userId = getUserIdFromUser(req.user, true); - if (!userId) { - return req.user; - } - const user = await this.authService.getProfile(userId); - return Object.assign({}, req.user, user); - } - - @UseGuards(JwtAuthGuard) - @Post('auth/impersonate') - async impersonate(@Request() req: AuthenticatedRequest, @Res() response: Response) { - if (!isAdmin(req.user) || !req.body.userId) { - console.log('impersonate non authorized') - throw new UnauthorizedException(); - } - const cookie = await this.authService.getCookieForImpersonate(req.body.userId); - response.setHeader('Set-Cookie', cookie); - return response.send({ success: true }); - } - - @UseGuards(JwtAuthGuard) - @Post('auth/unimpersonate') - async unimpersonate(@Request() req: Express.AuthenticatedRequest, @Res() response: Response) { - const cookie = await this.authService.getCookieForLogOut(req.user); - response.setHeader('Set-Cookie', cookie); - return response.sendStatus(200); - } - - @UseGuards(JwtAuthGuard) - @Post('settings') - async updateSettings(@Request() req: AuthenticatedRequest, @Body() data: any) { - const userId = getUserIdFromUser(req.user); - return this.authService.updateSettings(userId, data); - } - - @Get() - getHello(): string { - return this.appService.getHello(); - } - - @SkipMaintenance() - @Get('health') - @HttpCode(200) - healthCheck() { - return { status: 'ok', timestamp: new Date().toISOString() }; - } -} +export { AppController } from '@shared/app/app.controller'; diff --git a/server/src/app.service.ts b/server/src/app.service.ts index 7a60d033..fbd4e1fe 100644 --- a/server/src/app.service.ts +++ b/server/src/app.service.ts @@ -1,10 +1 @@ -import { Injectable } from '@nestjs/common'; - -const serverStartTime = new Date(); - -@Injectable() -export class AppService { - getHello(): string { - return `Hello World! Server started at ${serverStartTime.toISOString()}`; - } -} +export { AppService } from '@shared/app/app.service'; diff --git a/server/src/main.ts b/server/src/main.ts index 83ab4e24..bad702d0 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -1,19 +1,5 @@ import '@shared/config/crud.config'; -import { NestFactory } from '@nestjs/core'; import { AppModule } from 'src/app.module'; -import { setupApplication, setupYemotRouter } from '@shared/utils/bootstrap.util'; +import { bootstrapNraApplication } from '@shared/utils/bootstrap.util'; -async function bootstrap() { - const app = await NestFactory.create(AppModule); - - setupApplication(app, { - swaggerTitle: 'react-admin-nestjs', - swaggerDescription: 'Demo website description', - swaggerTag: 'demo', - }); - - setupYemotRouter(app); - - await app.listen(3000); -} -bootstrap(); +bootstrapNraApplication(AppModule); From 178044d8cadb4cee08691196709fc91104a39f80 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 10:30:57 +0000 Subject: [PATCH 06/37] feat: remove re-export shims and stale tests, update server/shared for Day 5 --- server/shared | 2 +- server/src/__tests__/app.controller.spec.ts | 156 ---------------- server/src/__tests__/app.module.spec.ts | 188 -------------------- server/src/__tests__/app.service.spec.ts | 24 --- server/src/app.controller.ts | 1 - server/src/app.service.ts | 1 - 6 files changed, 1 insertion(+), 371 deletions(-) delete mode 100644 server/src/__tests__/app.controller.spec.ts delete mode 100644 server/src/__tests__/app.module.spec.ts delete mode 100644 server/src/__tests__/app.service.spec.ts delete mode 100644 server/src/app.controller.ts delete mode 100644 server/src/app.service.ts diff --git a/server/shared b/server/shared index 3162ed94..9b5158db 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit 3162ed94d0e713afc959b547d4506dda691f7c1e +Subproject commit 9b5158db322fef95b1c5b008026808a093541378 diff --git a/server/src/__tests__/app.controller.spec.ts b/server/src/__tests__/app.controller.spec.ts deleted file mode 100644 index bcd1e179..00000000 --- a/server/src/__tests__/app.controller.spec.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from '../app.controller'; -import { AppService } from '../app.service'; -import { AuthService } from '@shared/auth/auth.service'; -import { Response } from 'express'; -import { UnauthorizedException } from '@nestjs/common'; -import { AuthenticatedRequest } from '@shared/auth/auth.types'; - -describe('AppController', () => { - let appController: AppController; - let authService: AuthService; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [ - AppService, - { - provide: AuthService, - useValue: { - getCookieWithJwtToken: jest.fn(user => { - if (user) return 'cookie'; - throw new UnauthorizedException(); - }), - getCookieForImpersonate: jest.fn(user => { - if (user) return 'cookie'; - throw new UnauthorizedException(); - }), - getCookieForLogOut: jest.fn().mockResolvedValue('Authentication=; HttpOnly; Path=/; Max-Age=0; SameSite=true'), - registerUser: jest.fn().mockRejectedValue(new UnauthorizedException()), - getProfile: jest.fn().mockResolvedValue({}), - updateSettings: jest.fn().mockResolvedValue({}), - } - }, - ], - }).compile(); - - appController = app.get(AppController); - authService = app.get(AuthService); - }); - - it('should return hello message with startup timestamp', () => { - expect(appController.getHello()).toMatch(/^Hello World! Server started at /); - }); - - it('should log in a user and return a success message', async () => { - const req = { user: { email: 'test@example.com' } } as unknown as AuthenticatedRequest; - const res = { setHeader: jest.fn(), send: jest.fn() } as unknown as Response; - - await appController.login(req, res); - - expect(authService.getCookieWithJwtToken).toHaveBeenCalledWith(req.user); - expect(res.setHeader).toHaveBeenCalledWith('Set-Cookie', 'cookie'); - expect(res.send).toHaveBeenCalledWith({ success: true }); - }); - - it('should register a user and return a success message', async () => { - const req = { user: { email: 'test@example.com' } } as unknown as AuthenticatedRequest; - const res = { setHeader: jest.fn(), send: jest.fn() } as unknown as Response; - - await appController.register(req, res); - - expect(authService.getCookieWithJwtToken).toHaveBeenCalledWith(req.user); - expect(res.setHeader).toHaveBeenCalledWith('Set-Cookie', 'cookie'); - expect(res.send).toHaveBeenCalledWith({ success: true }); - }); - - it('should throw an UnauthorizedException when login with unauthenticated user', async () => { - const req = { user: null } as unknown as AuthenticatedRequest; - const res = { setHeader: jest.fn(), send: jest.fn() } as unknown as Response; - - await expect(appController.login(req, res)).rejects.toThrow(UnauthorizedException); - }); - - it('should throw an UnauthorizedException with non-admin user impersonation', async () => { - const req = { - user: { permissions: {} }, - body: { userId: 1 } - } as unknown as AuthenticatedRequest; - const res = { setHeader: jest.fn(), send: jest.fn() } as unknown as Response; - - await expect(appController.impersonate(req, res)).rejects.toThrow(UnauthorizedException); - }); - - it('should log out a user and return a success message', async () => { - const responseMock = { - setHeader: jest.fn(), - sendStatus: jest.fn(), - } as unknown as Response; - - await appController.logOut(responseMock); - - expect(responseMock.setHeader).toHaveBeenCalledWith( - 'Set-Cookie', - expect.any(String) - ); - expect(responseMock.sendStatus).toHaveBeenCalledWith(200); - }); - - it('should return the user\'s profile information', async () => { - const req = { - user: { - id: 1, - email: 'test@example.com', - name: 'Test User' - } - } as unknown as AuthenticatedRequest; - const expectedProfile = { id: 1, email: 'test@example.com', name: 'Test User' }; - - const profile = await appController.getProfile(req); - - expect(profile).toEqual(expectedProfile); - }); - - it('should impersonate a user and return a success message', async () => { - const userId = 1; - const responseMock = { - setHeader: jest.fn(), - send: jest.fn(), - } as unknown as Response; - const req = { - body: { userId }, - user: { permissions: { admin: true } } - } as unknown as AuthenticatedRequest; - - await appController.impersonate(req, responseMock); - - expect(authService.getCookieForImpersonate).toHaveBeenCalledWith(userId); - expect(responseMock.setHeader).toHaveBeenCalledWith('Set-Cookie', 'cookie'); - expect(responseMock.send).toHaveBeenCalledWith({ success: true }); - }); - - it('should unimpersonate a user and return a success message', async () => { - const responseMock = { - setHeader: jest.fn(), - sendStatus: jest.fn(), - send: jest.fn(), - } as unknown as Response; - const getCookieForLogOutSpy = jest.spyOn(authService, 'getCookieForLogOut').mockResolvedValue('cookie'); - - await appController.unimpersonate({} as AuthenticatedRequest, responseMock); - - expect(getCookieForLogOutSpy).toHaveBeenCalled(); - expect(responseMock.setHeader).toHaveBeenCalledWith('Set-Cookie', 'cookie'); - expect(responseMock.sendStatus).toHaveBeenCalledWith(200); - }); - - it('should update user settings', async () => { - const req = { user: { id: 1 } } as unknown as AuthenticatedRequest; - const data = { key: 'value' }; - - await appController.updateSettings(req, data); - - expect(authService.updateSettings).toHaveBeenCalledWith(1, data); - }); -}); diff --git a/server/src/__tests__/app.module.spec.ts b/server/src/__tests__/app.module.spec.ts deleted file mode 100644 index 02657096..00000000 --- a/server/src/__tests__/app.module.spec.ts +++ /dev/null @@ -1,188 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppModule } from '../app.module'; -import { AppController } from '../app.controller'; -import { AppService } from '../app.service'; -import { ThrottlerModule, ThrottlerGuard } from '@nestjs/throttler'; -import { APP_GUARD } from '@nestjs/core'; -import { TypeOrmModule } from '@nestjs/typeorm'; -import { RequestContextModule } from 'nestjs-request-context'; -import { LoggerModule } from 'nestjs-pino'; -import { AuthModule } from '@shared/auth/auth.module'; -import { YemotModule } from '@shared/utils/yemot/v2/yemot.module'; -import { MailSendModule } from '@shared/utils/mail/mail-send.module'; -import { EntitiesModule } from '../entities.module'; -import { getPinoConfig } from '@shared/config/pino.config'; -import { JwtModule } from '@nestjs/jwt'; - -// Mock required modules -jest.mock('../entities.module', () => ({ - EntitiesModule: class { - static imports = []; - } -})); - -jest.mock('@shared/config/pino.config', () => ({ - getPinoConfig: jest.fn().mockImplementation((isDev) => ({ - pinoHttp: { level: isDev ? 'debug' : 'info' } - })) -})); - -// Mock JWT configuration -jest.mock('@shared/auth/constants', () => ({ - jwtConstants: { - secret: 'test-secret', - maxAge: '60s' - } -})); - -// Other external configurations -jest.mock('@shared/config/pino.config', () => ({ - getPinoConfig: jest.fn().mockReturnValue({ - pinoHttp: { level: 'silent' } - }) -})); - -jest.mock('@shared/config/typeorm.config', () => ({ - typeOrmModuleConfig: { - type: 'sqlite', - database: ':memory:', - synchronize: true, - logging: false - } -})); - -describe('AppModule', () => { - let module: TestingModule; - - beforeEach(async () => { - const moduleRef = await Test.createTestingModule({ - imports: [ - AppModule - ], - }) - .overrideProvider('JWT_SECRET') - .useValue('test-secret') - .compile(); - - module = moduleRef; - }); - - it('should be defined', () => { - expect(module).toBeDefined(); - }); - - it('should have AppController', () => { - const controller = module.get(AppController); - expect(controller).toBeDefined(); - }); - - it('should have AppService', () => { - const service = module.get(AppService); - expect(service).toBeDefined(); - }); - - it('should configure ThrottlerModule with correct options', () => { - const throttlerModule = Reflect.getMetadata('imports', AppModule); - const throttlerConfig = throttlerModule.find( - (imp: any) => imp && imp.module === ThrottlerModule - ); - expect(throttlerConfig).toBeDefined(); - expect(throttlerConfig.module).toBe(ThrottlerModule); - }); - - it('should register ThrottlerGuard as APP_GUARD', () => { - const providers = Reflect.getMetadata('providers', AppModule); - const guardProvider = providers.find( - (provider: any) => provider.provide === APP_GUARD - ); - expect(guardProvider).toBeDefined(); - expect(guardProvider.useClass).toBe(ThrottlerGuard); - }); - - it('should configure TypeOrmModule', () => { - const imports = Reflect.getMetadata('imports', AppModule); - const typeOrmConfig = imports.find( - (imp: any) => imp && imp.module === TypeOrmModule - ); - expect(typeOrmConfig).toBeDefined(); - expect(typeOrmConfig.module).toBe(TypeOrmModule); - }); - - it('should import RequestContextModule', () => { - const imports = Reflect.getMetadata('imports', AppModule); - expect(imports.includes(RequestContextModule)).toBe(true); - }); - - it('should configure LoggerModule with Pino', () => { - const imports = Reflect.getMetadata('imports', AppModule); - const loggerConfig = imports.find( - (imp: any) => imp && imp.module === LoggerModule - ); - expect(loggerConfig).toBeDefined(); - expect(loggerConfig.module).toBe(LoggerModule); - expect(getPinoConfig).toHaveBeenCalled(); - }); - - it('should import MailSendModule', () => { - const imports = Reflect.getMetadata('imports', AppModule); - expect(imports.includes(MailSendModule)).toBe(true); - }); - - it('should import EntitiesModule', () => { - const imports = Reflect.getMetadata('imports', AppModule); - expect(imports.includes(EntitiesModule)).toBe(true); - }); - - it('should import AuthModule', () => { - const imports = Reflect.getMetadata('imports', AppModule); - const authModuleImport = imports.find( - (imp: any) => imp && imp.module === AuthModule - ); - expect(authModuleImport).toBeDefined(); - }); - - it('should configure YemotModule with chain', () => { - const imports = Reflect.getMetadata('imports', AppModule); - const yemotConfig = imports.find( - (imp: any) => imp && imp.module === YemotModule - ); - expect(yemotConfig).toBeDefined(); - expect(yemotConfig.module).toBe(YemotModule); - }); - - describe('Environment configuration', () => { - const previousEnv = process.env.NODE_ENV; - - beforeEach(() => { - jest.clearAllMocks(); - }); - - afterEach(() => { - process.env.NODE_ENV = previousEnv; - }); - - it('should configure Pino logger for development environment', async () => { - process.env.NODE_ENV = 'development'; - - const moduleRef = await Test.createTestingModule({ - imports: [LoggerModule.forRoot(getPinoConfig(true))] - }).compile(); - - const loggerModule = moduleRef.get(LoggerModule); - expect(getPinoConfig).toHaveBeenCalledWith(true); - expect(loggerModule).toBeDefined(); - }); - - it('should configure Pino logger for production environment', async () => { - process.env.NODE_ENV = 'production'; - - const moduleRef = await Test.createTestingModule({ - imports: [LoggerModule.forRoot(getPinoConfig(false))] - }).compile(); - - const loggerModule = moduleRef.get(LoggerModule); - expect(getPinoConfig).toHaveBeenCalledWith(false); - expect(loggerModule).toBeDefined(); - }); - }); -}); \ No newline at end of file diff --git a/server/src/__tests__/app.service.spec.ts b/server/src/__tests__/app.service.spec.ts deleted file mode 100644 index 1a5b3094..00000000 --- a/server/src/__tests__/app.service.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppService } from '../app.service'; - -describe('AppService', () => { - let service: AppService; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [AppService], - }).compile(); - - service = module.get(AppService); - }); - - it('should be defined', () => { - expect(service).toBeDefined(); - }); - - describe('getHello', () => { - it('should return hello message with startup timestamp', () => { - expect(service.getHello()).toMatch(/^Hello World! Server started at /); - }); - }); -}); \ No newline at end of file diff --git a/server/src/app.controller.ts b/server/src/app.controller.ts deleted file mode 100644 index f6457c8d..00000000 --- a/server/src/app.controller.ts +++ /dev/null @@ -1 +0,0 @@ -export { AppController } from '@shared/app/app.controller'; diff --git a/server/src/app.service.ts b/server/src/app.service.ts deleted file mode 100644 index fbd4e1fe..00000000 --- a/server/src/app.service.ts +++ /dev/null @@ -1 +0,0 @@ -export { AppService } from '@shared/app/app.service'; From 1996811a2ec6df0a7914cadf79b3c3bf1ac746e9 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 10:39:53 +0000 Subject: [PATCH 07/37] feat: migrate to BaseNraAppModule.forRoot and createSharedEntitiesImports (Day 6) --- server/src/app.module.ts | 47 ++++++---------------------------- server/src/entities.module.ts | 27 +++---------------- server/src/user-init.module.ts | 8 ++++-- 3 files changed, 18 insertions(+), 64 deletions(-) diff --git a/server/src/app.module.ts b/server/src/app.module.ts index 93354ed5..285c3612 100644 --- a/server/src/app.module.ts +++ b/server/src/app.module.ts @@ -1,42 +1,11 @@ -import { Module } from '@nestjs/common'; -import { APP_GUARD } from '@nestjs/core'; -import { ThrottlerModule, ThrottlerGuard } from '@nestjs/throttler'; -import { AppController } from 'src/app.controller'; -import { AppService } from 'src/app.service'; -import { TypeOrmModule } from '@nestjs/typeorm'; -import { RequestContextModule } from 'nestjs-request-context'; -import { LoggerModule } from 'nestjs-pino'; -import { typeOrmModuleConfig } from '@shared/config/typeorm.config'; -import { AuthModule } from '@shared/auth/auth.module'; -import { YemotModule } from '@shared/utils/yemot/v2/yemot.module'; -import { YemotHandlerService } from './yemot-handler.service'; -import { MailSendModule } from '@shared/utils/mail/mail-send.module'; +import { BaseNraAppModule } from '@shared/app/base-app.module'; import { EntitiesModule } from './entities.module'; -import { getPinoConfig } from '@shared/config/pino.config'; import { UserInitModule } from './user-init.module'; -import { UserInitializationService } from './user-initialization.service'; +import { YemotHandlerService } from './yemot-handler.service'; -@Module({ - imports: [ - RequestContextModule, - LoggerModule.forRoot(getPinoConfig(process.env.NODE_ENV === 'development')), - ThrottlerModule.forRoot({ ttl: 5, limit: 200 }), - TypeOrmModule.forRoot(typeOrmModuleConfig), - MailSendModule, - EntitiesModule, - AuthModule.forRootAsync({ - imports: [UserInitModule], - userInitServiceType: UserInitializationService, - }), - YemotModule.register(YemotHandlerService), - ], - controllers: [AppController], - providers: [ - AppService, - { - provide: APP_GUARD, - useClass: ThrottlerGuard - } - ], -}) -export class AppModule { } +export const AppModule = BaseNraAppModule.forRoot({ + entitiesModule: EntitiesModule, + yemotHandlerService: YemotHandlerService, + userInitModule: UserInitModule, + throttlerLimit: 200, +}); diff --git a/server/src/entities.module.ts b/server/src/entities.module.ts index 6c15a6bc..6a63b532 100644 --- a/server/src/entities.module.ts +++ b/server/src/entities.module.ts @@ -1,7 +1,6 @@ import { Module } from "@nestjs/common"; import { BaseEntityModule } from '@shared/base-entity/base-entity.module'; -// TODO: move all shared configs to shared folder -import userConfig from '@shared/entities/configs/user.config'; +import { createSharedEntitiesImports } from '@shared/entities/createSharedEntitiesImports'; import attReportConfig from './entity-modules/att-report.config'; import gradeConfig from './entity-modules/grade.config'; import klassConfig from './entity-modules/klass.config'; @@ -11,23 +10,16 @@ import lessonConfig from './entity-modules/lesson.config'; import studentKlassConfig from './entity-modules/student-klass.config'; import studentConfig from './entity-modules/student.config'; import teacherConfig from './entity-modules/teacher.config'; -import textConfig from '@shared/entities/configs/text.config'; import studentKlassReportConfig from './entity-modules/student-klass-report.config'; import { StudentBaseKlass } from './db/view-entities/StudentBaseKlass.entity'; import { createAuditLogConfig } from '@shared/entities/configs/audit-log.config'; -import { YemotCall } from '@shared/entities/YemotCall.entity'; -import { TextByUser } from '@shared/view-entities/TextByUser.entity'; -import mailAddressConfig from '@shared/utils/mail/mail-address.config'; -import { RecievedMail } from '@shared/entities/RecievedMail.entity'; -import { Image } from "@shared/entities/Image.entity"; -import pageConfig from '@shared/entities/configs/page.config'; +import { registerEntityNameMap } from '@shared/entities/configs/import-file.config'; import { ReportMonth } from './db/entities/ReportMonth.entity'; import teacherReportStatusConfig from './entity-modules/teacher-report-status.config'; import studentPercentReportConfig from './entity-modules/student-percent-report.config'; import { AttReportAndGrade } from "./db/view-entities/AttReportAndGrade.entity"; import { StudentGlobalReport } from "./db/view-entities/StudentGlobalReport.entity"; import studentByYearConfig from "./entity-modules/student-by-year.config"; -import paymentTrackConfig from "@shared/entities/configs/payment-track.config"; import teacherSalaryReportConfig from "./entity-modules/teacher-salary-report.config"; import attReportWithReportMonthConfig from "./entity-modules/att-report-with-report-month.config"; import { KnownAbsenceWithReportMonth } from "./db/view-entities/KnownAbsenceWithReportMonth.entity"; @@ -37,17 +29,15 @@ import teacherGradeReportStatusConfig from "./entity-modules/teacher-grade-repor import { GradeEffectByUser } from "src/db/view-entities/GradeEffectByUser.entity"; import { AbsCountEffectByUser } from "src/db/view-entities/AbsCountEffectByUser.entity"; import { LessonKlassName } from "./db/view-entities/LessonKlassName.entity"; -import importFileConfig from "@shared/entities/configs/import-file.config"; import { StudentSpeciality } from "./db/view-entities/StudentSpeciality.entity"; import { AttendanceName } from "./db/entities/AttendanceName.entity"; import reportGroupConfig from "./entity-modules/report-group.config"; import reportGroupSessionConfig from "./entity-modules/report-group-session.config"; -import transportationConfig from './entity-modules/transportation.config'; +import transportationConfig from './entity-modules/transportation.config'; import absenceTypeConfig from "./entity-modules/absenceType.config"; import uploadedFileConfig from "@shared/entities/configs/uploaded-file.config"; import { Student } from "./db/entities/Student.entity"; import { Teacher } from "./db/entities/Teacher.entity"; -import { registerEntityNameMap } from '@shared/entities/configs/import-file.config'; registerEntityNameMap({ att_report: 'נוכחות', @@ -64,7 +54,7 @@ registerEntityNameMap({ @Module({ imports: [ - BaseEntityModule.register(userConfig), + ...createSharedEntitiesImports(), BaseEntityModule.register(attReportConfig), BaseEntityModule.register(attReportWithReportMonthConfig), BaseEntityModule.register(gradeConfig), @@ -75,28 +65,19 @@ registerEntityNameMap({ BaseEntityModule.register(studentKlassConfig), BaseEntityModule.register(studentConfig), BaseEntityModule.register(teacherConfig), - BaseEntityModule.register(textConfig), BaseEntityModule.register(studentKlassReportConfig), BaseEntityModule.register({ entity: StudentBaseKlass }), BaseEntityModule.register({ entity: StudentSpeciality }), BaseEntityModule.register(createAuditLogConfig({ student: Student, teacher: Teacher })), - BaseEntityModule.register(importFileConfig), BaseEntityModule.register(reportGroupConfig), BaseEntityModule.register(reportGroupSessionConfig), - BaseEntityModule.register({ entity: YemotCall }), - BaseEntityModule.register(mailAddressConfig), - BaseEntityModule.register({ entity: RecievedMail }), - BaseEntityModule.register(pageConfig), BaseEntityModule.register({ entity: ReportMonth }), BaseEntityModule.register(teacherReportStatusConfig), BaseEntityModule.register(teacherGradeReportStatusConfig), - BaseEntityModule.register({ entity: TextByUser }), BaseEntityModule.register(studentPercentReportConfig), BaseEntityModule.register({ entity: AttReportAndGrade }), BaseEntityModule.register({ entity: StudentGlobalReport }), - BaseEntityModule.register({ entity: Image }), BaseEntityModule.register(studentByYearConfig), - BaseEntityModule.register(paymentTrackConfig), BaseEntityModule.register(teacherSalaryReportConfig), BaseEntityModule.register({ entity: KnownAbsenceWithReportMonth }), BaseEntityModule.register({ entity: GradeName }), diff --git a/server/src/user-init.module.ts b/server/src/user-init.module.ts index 56bc125a..426be10e 100644 --- a/server/src/user-init.module.ts +++ b/server/src/user-init.module.ts @@ -1,5 +1,6 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; +import { USER_INITIALIZATION_SERVICE } from '@shared/auth/user-initialization.interface'; import { UserInitializationService } from './user-initialization.service'; import { ReportMonth } from './db/entities/ReportMonth.entity'; @@ -7,7 +8,10 @@ import { ReportMonth } from './db/entities/ReportMonth.entity'; imports: [ TypeOrmModule.forFeature([ReportMonth]), ], - providers: [UserInitializationService], - exports: [UserInitializationService], + providers: [ + UserInitializationService, + { provide: USER_INITIALIZATION_SERVICE, useExisting: UserInitializationService }, + ], + exports: [UserInitializationService, USER_INITIALIZATION_SERVICE], }) export class UserInitModule { } \ No newline at end of file From 37894de1d80140b1e42b07c414778486734636ea Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 12:43:58 +0000 Subject: [PATCH 08/37] feat: migrate App.jsx to buildResources DSL, update client/shared pointer (Day 9) --- client/shared | 2 +- client/src/App.jsx | 55 ++++++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/client/shared b/client/shared index c5fc4424..326953e7 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit c5fc44244305a02a0651a536836281c98a3d5a4b +Subproject commit 326953e7d61de462b32aae9fdfbc06a5f2b121be diff --git a/client/src/App.jsx b/client/src/App.jsx index da2ed391..3e0c2ab8 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -1,4 +1,5 @@ import { Resource, CustomRoutes } from 'react-admin'; +import { buildResources } from '@shared/components/app/buildResources'; import { Route } from 'react-router-dom'; import { blue, purple } from '@mui/material/colors'; @@ -125,38 +126,40 @@ const App = () => ( <> ); } + const adminResources = [ + { name: 'teacher', config: teacher, icon: BadgeIcon, menuGroup: 'data' }, + { name: 'klass_type', config: klassType, icon: CategoryIcon, menuGroup: 'data' }, + { name: 'klass', config: klass, icon: SupervisedUserCircleIcon, menuGroup: 'data' }, + { name: 'lesson', config: lesson, icon: SchoolIcon, menuGroup: 'data' }, + { name: 'student_klass', config: studentKlass, icon: WorkspacesIcon, menuGroup: 'data' }, + { name: 'transportation', config: transportation, icon: DirectionsBusIcon, menuGroup: 'data', condition: p => isTransportation(p) || isAdmin(p) }, + { name: 'absence_type', config: absenceType, icon: CelebrationIcon, menuGroup: 'data', condition: p => isAbsenceType(p) || isAdmin(p) }, + { name: 'att_report_with_report_month', config: attReportWithReportMonth, icon: ViewListIcon, menuGroup: 'data' }, + { name: 'grade', config: grade, icon: GradingIcon, menuGroup: 'data' }, + { name: 'known_absence', config: knownAbsence, icon: PlaylistRemoveIcon, menuGroup: 'data' }, + { name: 'student_klass_report', config: studentKlassesReport, icon: GroupWorkIcon, menuGroup: 'report' }, + { name: 'teacher_report_status', config: teacherReportStatus, icon: RuleIcon, menuGroup: 'report' }, + { name: 'teacher_grade_report_status', config: teacherGradeReportStatus, icon: RuleIcon, menuGroup: 'report' }, + { name: 'teacher_salary_report', config: teacherSalaryReport, icon: LocalAtmIcon, menuGroup: 'report' }, + { name: 'student_percent_report', config: studentPercentReport, icon: SummarizeIcon, menuGroup: 'report', condition: isAdmin }, + { name: 'report_month', config: reportMonth, icon: DateRangeIcon, menuGroup: 'settings' }, + { name: 'uploaded_file', config: uploadedFile, icon: UploadFileIcon, menuGroup: 'settings', condition: isUploadedFiles }, + { name: 'att_report', config: attReport, icon: ViewListIcon, menuGroup: 'settings' }, + { name: 'grade_name', config: gradeName, icon: LabelIcon, menuGroup: 'settings' }, + { name: 'attendance_name', config: attendanceName, icon: LabelIcon, menuGroup: 'settings' }, + { name: 'att_grade_effect', config: attGradeEffect, icon: CalculateIcon, menuGroup: 'settings' }, + { name: 'student_by_year', config: resourceEntityGuesser, icon: PermContactCalendarIcon, menuGroup: 'admin', condition: isAdmin }, + { name: 'grade_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin', condition: isAdmin }, + { name: 'abs_count_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin', condition: isAdmin }, + ]; return ( <> - - - - + {buildResources(adminResources, permissions)} + {/* student resource has a nested route so stays inline */} } /> - - {(isTransportation(permissions) || isAdmin(permissions)) && } - {(isAbsenceType(permissions) || isAdmin(permissions)) && } - - - - - - - - - {CommonSettingsResources()} - {isUploadedFiles(permissions) && } - - - - - - - - - {isAdmin(permissions) && } {CommonAdminResources({ permissions })} {isLessonSignature(permissions) && <> From 97cd85931a2508e86c0818024344086583650d5c Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 12:45:34 +0000 Subject: [PATCH 09/37] feat: add prettier script to server package.json (Day 10) --- server/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/package.json b/server/package.json index a71e47d5..da3a321b 100644 --- a/server/package.json +++ b/server/package.json @@ -27,7 +27,8 @@ "typeorm:generate": "npm run typeorm:cli -- migration:generate", "typeorm:create": "npm run typeorm:cli-no-d -- migration:create", "typeorm:revert": "npm run typeorm:cli -- migration:revert", - "clean-migrations": "node helpers/clean-migrations" + "clean-migrations": "node helpers/clean-migrations", + "prettier": "prettier --write \"{src,apps,libs,test}/**/*.ts\"" }, "dependencies": { "@dataui/crud": "^5.2.3", From b119489ffbb288399643b29ac23154d0bb03c21e Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 13:03:46 +0000 Subject: [PATCH 10/37] feat: migrate vite.config.js to createViteConfig factory, fix dev port assignments in override template (Day 11) --- client/shared | 2 +- client/vite.config.js | 40 ++-------------------------- docker-compose.override.yml.template | 4 ++- 3 files changed, 6 insertions(+), 40 deletions(-) diff --git a/client/shared b/client/shared index 326953e7..c3a99009 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit 326953e7d61de462b32aae9fdfbc06a5f2b121be +Subproject commit c3a99009fbadc88fff16566af644afc72c47ceba diff --git a/client/vite.config.js b/client/vite.config.js index 633fcd81..b0f3066d 100644 --- a/client/vite.config.js +++ b/client/vite.config.js @@ -1,38 +1,2 @@ -import { defineConfig } from "vite"; -import react from "@vitejs/plugin-react"; -import path from 'path'; - -export default ({ mode }) => { - return defineConfig({ - envPrefix: 'REACT_APP', - plugins: [react()], - server: { - host: '0.0.0.0', - port: Number(process.env.PORT || 3000), - hmr: { - overlay: true, - clientPort: 3000, - }, - }, - define: { - "process.env.NODE_ENV": `"${mode}"`, - "process.env.REACT_APP_API_URL": `"${process.env.REACT_APP_API_URL ?? ''}"`, - }, - resolve: { - alias: { - '@shared': path.resolve(__dirname, './shared'), - 'src': path.resolve(__dirname, './src') - }, - }, - build: { - rollupOptions: { - onwarn(warning, warn) { - if (warning.code === 'MODULE_LEVEL_DIRECTIVE') { - return - } - warn(warning) - } - } - }, - }) -} +import { createViteConfig } from './shared/config/createViteConfig'; +export default createViteConfig(); diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index e99832ea..570ccd61 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -7,8 +7,10 @@ services: target: development environment: PORT: 3000 + HMR_PORT: 24678 ports: - - "3000:3000" # Main Vite dev server port + - "3000:3000" # Vite dev server + - "24678:24678" # Vite HMR volumes: - ./client:/app networks: From 640221b6d9b01d5c34e6f1ea050b704f21347c94 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 13:12:44 +0000 Subject: [PATCH 11/37] refactor: complete buildResources conversion in App.jsx (Day 9 follow-up) --- client/src/App.jsx | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index 3e0c2ab8..4d4f40a7 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -127,30 +127,30 @@ const App = () => ( ); } const adminResources = [ - { name: 'teacher', config: teacher, icon: BadgeIcon, menuGroup: 'data' }, - { name: 'klass_type', config: klassType, icon: CategoryIcon, menuGroup: 'data' }, - { name: 'klass', config: klass, icon: SupervisedUserCircleIcon, menuGroup: 'data' }, - { name: 'lesson', config: lesson, icon: SchoolIcon, menuGroup: 'data' }, - { name: 'student_klass', config: studentKlass, icon: WorkspacesIcon, menuGroup: 'data' }, - { name: 'transportation', config: transportation, icon: DirectionsBusIcon, menuGroup: 'data', condition: p => isTransportation(p) || isAdmin(p) }, - { name: 'absence_type', config: absenceType, icon: CelebrationIcon, menuGroup: 'data', condition: p => isAbsenceType(p) || isAdmin(p) }, - { name: 'att_report_with_report_month', config: attReportWithReportMonth, icon: ViewListIcon, menuGroup: 'data' }, - { name: 'grade', config: grade, icon: GradingIcon, menuGroup: 'data' }, - { name: 'known_absence', config: knownAbsence, icon: PlaylistRemoveIcon, menuGroup: 'data' }, - { name: 'student_klass_report', config: studentKlassesReport, icon: GroupWorkIcon, menuGroup: 'report' }, - { name: 'teacher_report_status', config: teacherReportStatus, icon: RuleIcon, menuGroup: 'report' }, - { name: 'teacher_grade_report_status', config: teacherGradeReportStatus, icon: RuleIcon, menuGroup: 'report' }, - { name: 'teacher_salary_report', config: teacherSalaryReport, icon: LocalAtmIcon, menuGroup: 'report' }, - { name: 'student_percent_report', config: studentPercentReport, icon: SummarizeIcon, menuGroup: 'report', condition: isAdmin }, - { name: 'report_month', config: reportMonth, icon: DateRangeIcon, menuGroup: 'settings' }, - { name: 'uploaded_file', config: uploadedFile, icon: UploadFileIcon, menuGroup: 'settings', condition: isUploadedFiles }, - { name: 'att_report', config: attReport, icon: ViewListIcon, menuGroup: 'settings' }, - { name: 'grade_name', config: gradeName, icon: LabelIcon, menuGroup: 'settings' }, - { name: 'attendance_name', config: attendanceName, icon: LabelIcon, menuGroup: 'settings' }, - { name: 'att_grade_effect', config: attGradeEffect, icon: CalculateIcon, menuGroup: 'settings' }, - { name: 'student_by_year', config: resourceEntityGuesser, icon: PermContactCalendarIcon, menuGroup: 'admin', condition: isAdmin }, - { name: 'grade_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin', condition: isAdmin }, - { name: 'abs_count_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin', condition: isAdmin }, + { name: 'teacher', config: teacher, icon: BadgeIcon, menuGroup: 'data' }, + { name: 'klass_type', config: klassType, icon: CategoryIcon, menuGroup: 'data' }, + { name: 'klass', config: klass, icon: SupervisedUserCircleIcon, menuGroup: 'data' }, + { name: 'lesson', config: lesson, icon: SchoolIcon, menuGroup: 'data' }, + { name: 'student_klass', config: studentKlass, icon: WorkspacesIcon, menuGroup: 'data' }, + { name: 'transportation', config: transportation, icon: DirectionsBusIcon, menuGroup: 'data', condition: p => isTransportation(p) || isAdmin(p) }, + { name: 'absence_type', config: absenceType, icon: CelebrationIcon, menuGroup: 'data', condition: p => isAbsenceType(p) || isAdmin(p) }, + { name: 'att_report_with_report_month', config: attReportWithReportMonth, icon: ViewListIcon, menuGroup: 'data' }, + { name: 'grade', config: grade, icon: GradingIcon, menuGroup: 'data' }, + { name: 'known_absence', config: knownAbsence, icon: PlaylistRemoveIcon, menuGroup: 'data' }, + { name: 'student_klass_report', config: studentKlassesReport, icon: GroupWorkIcon, menuGroup: 'report' }, + { name: 'teacher_report_status', config: teacherReportStatus, icon: RuleIcon, menuGroup: 'report' }, + { name: 'teacher_grade_report_status', config: teacherGradeReportStatus, icon: RuleIcon, menuGroup: 'report' }, + { name: 'teacher_salary_report', config: teacherSalaryReport, icon: LocalAtmIcon, menuGroup: 'report' }, + { name: 'student_percent_report', config: studentPercentReport, icon: SummarizeIcon, menuGroup: 'report', condition: isAdmin }, + { name: 'report_month', config: reportMonth, icon: DateRangeIcon, menuGroup: 'settings' }, + { name: 'uploaded_file', config: uploadedFile, icon: UploadFileIcon, menuGroup: 'settings', condition: isUploadedFiles }, + { name: 'att_report', config: attReport, icon: ViewListIcon, menuGroup: 'settings' }, + { name: 'grade_name', config: gradeName, icon: LabelIcon, menuGroup: 'settings' }, + { name: 'attendance_name', config: attendanceName, icon: LabelIcon, menuGroup: 'settings' }, + { name: 'att_grade_effect', config: attGradeEffect, icon: CalculateIcon, menuGroup: 'settings' }, + { name: 'student_by_year', config: resourceEntityGuesser, icon: PermContactCalendarIcon, menuGroup: 'admin', condition: isAdmin }, + { name: 'grade_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin', condition: isAdmin }, + { name: 'abs_count_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin', condition: isAdmin }, ]; return ( <> From fd90024c0060758730dffa6af48b6f8060dd4798 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 3 May 2026 13:23:18 +0000 Subject: [PATCH 12/37] refactor: convert condition properties to function items in App.jsx (buildResources API update) --- client/shared | 2 +- client/src/App.jsx | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/shared b/client/shared index c3a99009..e60c3f59 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit c3a99009fbadc88fff16566af644afc72c47ceba +Subproject commit e60c3f59ace7ff9b11aaa7e788df082808e6addb diff --git a/client/src/App.jsx b/client/src/App.jsx index 4d4f40a7..8f2f775d 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -132,8 +132,8 @@ const App = () => ( { name: 'klass', config: klass, icon: SupervisedUserCircleIcon, menuGroup: 'data' }, { name: 'lesson', config: lesson, icon: SchoolIcon, menuGroup: 'data' }, { name: 'student_klass', config: studentKlass, icon: WorkspacesIcon, menuGroup: 'data' }, - { name: 'transportation', config: transportation, icon: DirectionsBusIcon, menuGroup: 'data', condition: p => isTransportation(p) || isAdmin(p) }, - { name: 'absence_type', config: absenceType, icon: CelebrationIcon, menuGroup: 'data', condition: p => isAbsenceType(p) || isAdmin(p) }, + p => (isTransportation(p) || isAdmin(p)) && { name: 'transportation', config: transportation, icon: DirectionsBusIcon, menuGroup: 'data' }, + p => (isAbsenceType(p) || isAdmin(p)) && { name: 'absence_type', config: absenceType, icon: CelebrationIcon, menuGroup: 'data' }, { name: 'att_report_with_report_month', config: attReportWithReportMonth, icon: ViewListIcon, menuGroup: 'data' }, { name: 'grade', config: grade, icon: GradingIcon, menuGroup: 'data' }, { name: 'known_absence', config: knownAbsence, icon: PlaylistRemoveIcon, menuGroup: 'data' }, @@ -141,16 +141,16 @@ const App = () => ( { name: 'teacher_report_status', config: teacherReportStatus, icon: RuleIcon, menuGroup: 'report' }, { name: 'teacher_grade_report_status', config: teacherGradeReportStatus, icon: RuleIcon, menuGroup: 'report' }, { name: 'teacher_salary_report', config: teacherSalaryReport, icon: LocalAtmIcon, menuGroup: 'report' }, - { name: 'student_percent_report', config: studentPercentReport, icon: SummarizeIcon, menuGroup: 'report', condition: isAdmin }, + p => isAdmin(p) && { name: 'student_percent_report', config: studentPercentReport, icon: SummarizeIcon, menuGroup: 'report' }, { name: 'report_month', config: reportMonth, icon: DateRangeIcon, menuGroup: 'settings' }, - { name: 'uploaded_file', config: uploadedFile, icon: UploadFileIcon, menuGroup: 'settings', condition: isUploadedFiles }, + p => isUploadedFiles(p) && { name: 'uploaded_file', config: uploadedFile, icon: UploadFileIcon, menuGroup: 'settings' }, { name: 'att_report', config: attReport, icon: ViewListIcon, menuGroup: 'settings' }, { name: 'grade_name', config: gradeName, icon: LabelIcon, menuGroup: 'settings' }, { name: 'attendance_name', config: attendanceName, icon: LabelIcon, menuGroup: 'settings' }, { name: 'att_grade_effect', config: attGradeEffect, icon: CalculateIcon, menuGroup: 'settings' }, - { name: 'student_by_year', config: resourceEntityGuesser, icon: PermContactCalendarIcon, menuGroup: 'admin', condition: isAdmin }, - { name: 'grade_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin', condition: isAdmin }, - { name: 'abs_count_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin', condition: isAdmin }, + p => isAdmin(p) && { name: 'student_by_year', config: resourceEntityGuesser, icon: PermContactCalendarIcon, menuGroup: 'admin' }, + p => isAdmin(p) && { name: 'grade_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin' }, + p => isAdmin(p) && { name: 'abs_count_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin' }, ]; return ( <> From e7df934abb8bfa1ad828e1d8c7e75c28ba9df0af Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Tue, 5 May 2026 18:13:49 +0000 Subject: [PATCH 13/37] chore: sync override with template, use direct API URL, remove proxy --- docker-compose.override.yml | 55 ++++++++++++++++++++++++++++ docker-compose.override.yml.template | 28 +++++++++----- 2 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 docker-compose.override.yml diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 00000000..322d440b --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,55 @@ +version: "3" +name: react-admin-nestjs-dev +services: + client: + container_name: ran-client-dev + build: + target: development + environment: + PORT: 3000 + REACT_APP_API_URL: http://localhost:3001 + ports: + - "3000:3000" + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"] + interval: 10s + timeout: 5s + start_period: 60s + retries: 3 + volumes: + - ./client:/app + - ./client/node_modules:/app/node_modules + networks: + - private-network + + server: + container_name: ran-server-dev + build: + target: development + ports: + - "3001:3000" + volumes: + - ./server:/app + - ./server/node_modules:/app/node_modules + networks: + - private-network + + database: + container_name: ran-database-dev + ports: + - "3306:3306" + + phpmyadmin: + container_name: ran-phpmyadmin-dev + profiles: [tools] + ports: + - "8080:80" + networks: + - private-network + +networks: + private-network: + caddy: + external: false + elknet: + external: false diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index 570ccd61..322d440b 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -2,40 +2,48 @@ version: "3" name: react-admin-nestjs-dev services: client: - container_name: client-dev + container_name: ran-client-dev build: target: development environment: PORT: 3000 - HMR_PORT: 24678 + REACT_APP_API_URL: http://localhost:3001 ports: - - "3000:3000" # Vite dev server - - "24678:24678" # Vite HMR + - "3000:3000" + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"] + interval: 10s + timeout: 5s + start_period: 60s + retries: 3 volumes: - ./client:/app + - ./client/node_modules:/app/node_modules networks: - private-network server: - container_name: server-dev + container_name: ran-server-dev build: target: development ports: - - "3001:3000" # Map container port 3000 to host port 3001 + - "3001:3000" volumes: - ./server:/app + - ./server/node_modules:/app/node_modules networks: - private-network database: - container_name: database-dev + container_name: ran-database-dev ports: - - "3306:3306" # MySQL port for local access + - "3306:3306" phpmyadmin: - container_name: php-myadmin-dev + container_name: ran-phpmyadmin-dev + profiles: [tools] ports: - - "8080:80" # PhpMyAdmin web interface + - "8080:80" networks: - private-network From e031fe4c3ec7591ce6e4c22e1c3f4a740090b3b4 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Tue, 5 May 2026 18:15:08 +0000 Subject: [PATCH 14/37] chore: update nra-client submodule pointer (remove proxy from createViteConfig) --- client/shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/shared b/client/shared index e60c3f59..94697619 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit e60c3f59ace7ff9b11aaa7e788df082808e6addb +Subproject commit 946976198b50d04660cf907db6da4973aa04755d From 5f0fab1ab152be8f75a5b2be7716a9846b99892a Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Tue, 5 May 2026 18:25:20 +0000 Subject: [PATCH 15/37] chore: remove docker-compose.override.yml from gitignore (file is now committed) --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index f893cca2..6e565582 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ .env -docker-compose.override.yml /.idea/* From 8d2e3d2cba37e2d3bf7f8a077063debe2f9af2a6 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Thu, 7 May 2026 19:20:56 +0000 Subject: [PATCH 16/37] fix: run migrations on dev container startup Add build+migrate step to dev server command so TypeORM migrations run automatically when the container starts in dev mode. Before: CMD yarn start:dev (migrations never ran in dev) After: yarn build && typeorm migration:run && yarn start:dev --- docker-compose.override.yml | 1 + docker-compose.override.yml.template | 1 + 2 files changed, 2 insertions(+) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 322d440b..006eb79f 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -26,6 +26,7 @@ services: container_name: ran-server-dev build: target: development + command: sh -c "yarn build && ./node_modules/.bin/typeorm -d dist/shared/config/migration.config.js migration:run && yarn start:dev" ports: - "3001:3000" volumes: diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index 322d440b..006eb79f 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -26,6 +26,7 @@ services: container_name: ran-server-dev build: target: development + command: sh -c "yarn build && ./node_modules/.bin/typeorm -d dist/shared/config/migration.config.js migration:run && yarn start:dev" ports: - "3001:3000" volumes: From d602085d7c7d8a5cbec95805c36b8c31d5e067e9 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Thu, 7 May 2026 19:41:25 +0000 Subject: [PATCH 17/37] chore: add typeorm:run:ts script and shorten compose dev command --- docker-compose.override.yml | 2 +- docker-compose.override.yml.template | 2 +- server/package.json | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 006eb79f..e9e5047d 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -26,7 +26,7 @@ services: container_name: ran-server-dev build: target: development - command: sh -c "yarn build && ./node_modules/.bin/typeorm -d dist/shared/config/migration.config.js migration:run && yarn start:dev" + command: sh -c "yarn typeorm:run:ts && yarn start:dev" ports: - "3001:3000" volumes: diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index 006eb79f..e9e5047d 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -26,7 +26,7 @@ services: container_name: ran-server-dev build: target: development - command: sh -c "yarn build && ./node_modules/.bin/typeorm -d dist/shared/config/migration.config.js migration:run && yarn start:dev" + command: sh -c "yarn typeorm:run:ts && yarn start:dev" ports: - "3001:3000" volumes: diff --git a/server/package.json b/server/package.json index da3a321b..e5cd670a 100644 --- a/server/package.json +++ b/server/package.json @@ -20,9 +20,11 @@ "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json", "typeorm:cli": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli -d shared/config/migration.config.ts", + "typeorm:cli-ts": "ts-node --transpile-only -r tsconfig-paths/register ./node_modules/typeorm/cli -d shared/config/migration.config.ts", "typeorm:cli-js": "typeorm -d dist/shared/config/migration.config.js", "typeorm:cli-no-d": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli", "typeorm:run": "npm run typeorm:cli -- migration:run", + "typeorm:run:ts": "npm run typeorm:cli-ts -- migration:run", "typeorm:run:js": "npm run typeorm:cli-js -- migration:run", "typeorm:generate": "npm run typeorm:cli -- migration:generate", "typeorm:create": "npm run typeorm:cli-no-d -- migration:create", From 6a8d860e0efbdb9d11bc449e9fe3b88bd5273958 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Thu, 7 May 2026 19:46:35 +0000 Subject: [PATCH 18/37] chore: simplify typeorm:cli - add --transpile-only directly, remove cli-ts/run:ts duplicates --- docker-compose.override.yml | 2 +- docker-compose.override.yml.template | 2 +- server/package.json | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index e9e5047d..afa5719a 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -26,7 +26,7 @@ services: container_name: ran-server-dev build: target: development - command: sh -c "yarn typeorm:run:ts && yarn start:dev" + command: sh -c "yarn typeorm:run && yarn start:dev" ports: - "3001:3000" volumes: diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index e9e5047d..afa5719a 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -26,7 +26,7 @@ services: container_name: ran-server-dev build: target: development - command: sh -c "yarn typeorm:run:ts && yarn start:dev" + command: sh -c "yarn typeorm:run && yarn start:dev" ports: - "3001:3000" volumes: diff --git a/server/package.json b/server/package.json index e5cd670a..efcee350 100644 --- a/server/package.json +++ b/server/package.json @@ -19,12 +19,10 @@ "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json", - "typeorm:cli": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli -d shared/config/migration.config.ts", - "typeorm:cli-ts": "ts-node --transpile-only -r tsconfig-paths/register ./node_modules/typeorm/cli -d shared/config/migration.config.ts", + "typeorm:cli": "ts-node --transpile-only -r tsconfig-paths/register ./node_modules/typeorm/cli -d shared/config/migration.config.ts", "typeorm:cli-js": "typeorm -d dist/shared/config/migration.config.js", "typeorm:cli-no-d": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli", "typeorm:run": "npm run typeorm:cli -- migration:run", - "typeorm:run:ts": "npm run typeorm:cli-ts -- migration:run", "typeorm:run:js": "npm run typeorm:cli-js -- migration:run", "typeorm:generate": "npm run typeorm:cli -- migration:generate", "typeorm:create": "npm run typeorm:cli-no-d -- migration:create", @@ -112,4 +110,4 @@ "tsconfig-paths": "^4.2.0", "typescript": "^4.7.4" } -} +} \ No newline at end of file From 9485cccd1af6fef476c4177b9fc29f51e97ee724 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Thu, 7 May 2026 19:51:13 +0000 Subject: [PATCH 19/37] chore: fix MYSQL_HOST to 'database', add .vite-cache to .gitignore, remove duplicate AGENTS.md --- .env.template | 2 +- AGENTS.md | 245 ---------------------------------------------- client/.gitignore | 2 + 3 files changed, 3 insertions(+), 246 deletions(-) delete mode 100644 AGENTS.md diff --git a/.env.template b/.env.template index 907bfee5..9688169c 100644 --- a/.env.template +++ b/.env.template @@ -1,5 +1,5 @@ DOMAIN_NAME=demo.yoman.online -MYSQL_HOST=mysql +MYSQL_HOST=database MYSQL_USER=mysql_user MYSQL_PASSWORD=mysql_password MYSQL_DATABASE=mysql_database diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index d9b33c05..00000000 --- a/AGENTS.md +++ /dev/null @@ -1,245 +0,0 @@ -# Agent Workflow Documentation - -## Project Structure - -This is a full-stack application built with: -- **Backend**: NestJS (TypeScript) - located in `/server` -- **Frontend**: React with React-Admin (JavaScript/JSX) - located in `/client` -- **Shared Code**: Git submodules containing shared utilities - - `client/shared` - [nra-client](https://github.com/buzz-code/nra-client) - - `server/shared` - [nra-server](https://github.com/buzz-code/nra-server) - -## Initial Setup - -### 1. Clone Repository with Submodules -```bash -git clone -cd react-admin-nestjs -git submodule update --init --recursive -``` - -**Important**: The shared submodules MUST be initialized before running tests or building. - -### 2. Install Dependencies - -Backend: -```bash -cd server -yarn install -``` - -Frontend: -```bash -cd client -yarn install -``` - -## Testing Workflow - -### Backend Tests (NestJS) -```bash -cd server -yarn test -``` -- Test Framework: Jest with ts-jest -- Test Pattern: `*.spec.ts` or `*.test.ts` -- Expected Results: 79 test suites, 789 tests (as of current state) - -### Frontend Tests (React) -```bash -cd client -yarn test -``` -- Test Framework: Jest with jsdom -- Test Pattern: `*.test.js` or `*.spec.js` -- Expected Results: 11 test suites, 87 tests (as of current state) - -### Test Execution Sequence -1. **Always** run backend tests first -2. Then run frontend tests -3. Do not proceed with deployment or Docker setup if tests fail - -## Docker Development Workflow - -### Configuration Files -- `docker-compose.yml` - Base production configuration -- `docker-compose.override.yml.template` - Development overrides template - -### Port Assignments (Local Development) -Sequential port mapping for services: -- **Frontend (Vite)**: - - Main dev server: `3000` - - HMR (Hot Module Replacement): `24678` ⚠️ **Must be exposed** -- **Backend (NestJS)**: `3001` (maps to container port 3000) -- **MySQL**: `3306` -- **PhpMyAdmin**: `8080` - -### Volume Management for node_modules Reuse - -The Docker setup is optimized to reuse `node_modules` installed on the host machine, preventing duplicate installations inside containers: - -```yaml -volumes: - - ./client:/app # Mount source code - - /app/node_modules # Exclude: use container's node_modules - - /app/dist # Exclude: use container's dist -``` - -**Benefits**: -- Faster container startup -- Reduced disk space usage -- Consistent dependency versions between host and container - -### Running Docker Development Environment - -1. Copy the override template: -```bash -cp docker-compose.override.yml.template docker-compose.override.yml -``` - -2. Set up environment: -```bash -cp .env.template .env -# Edit .env with your configuration -``` - -3. Start services: -```bash -docker-compose up -d -``` - -4. View logs: -```bash -docker-compose logs -f frontend -docker-compose logs -f backend -``` - -## Puppeteer Configuration - -Puppeteer is used for PDF generation in reports and is properly configured in the backend. - -### Dockerfile Setup -The backend Dockerfile includes Chromium browser installation: -```dockerfile -RUN apk add --no-cache \ - udev \ - ttf-freefont \ - chromium -ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser -``` - -### Usage Location -- Primary use: `server/shared/utils/report/markup-to-pdf.generator.ts` -- Purpose: Convert HTML markup to PDF reports -- Configuration: Sandboxed mode with proper flags for Docker environment - -### Maintenance Notes -- Keep Puppeteer in the workflow unless it causes blocking issues -- The Chromium version is managed by Alpine package manager -- PDF generation tests are included in the test suite - -## Frontend Constants and Configuration - -### Vite Configuration -Located in `client/vite.config.js`: - -```javascript -server: { - host: '0.0.0.0', - port: Number(process.env.PORT || 3000), - hmr: { - overlay: true, - port: 24678, // HMR WebSocket port - timeout: 1000, - clientPort: 24678, - host: 'localhost', - }, -} -``` - -### Important Notes -- HMR (Hot Module Replacement) requires port **24678** to be exposed -- The main dev server port defaults to 3000 but can be configured via `PORT` env var -- API URL is configured via `REACT_APP_API_URL` environment variable - -## CI/CD Considerations - -### Pre-Deployment Checklist -1. ✅ All backend tests pass -2. ✅ All frontend tests pass -3. ✅ Git submodules are up to date -4. ✅ Docker containers build successfully -5. ✅ Environment variables are properly configured - -### Build Commands - -Backend production build: -```bash -cd server -yarn build -``` - -Frontend production build: -```bash -cd client -yarn build -``` - -## Development Best Practices - -1. **Always initialize submodules** before starting work -2. **Run tests locally** before committing -3. **Use Docker override** for local development customization -4. **Keep node_modules** on host machine for faster development -5. **Expose HMR port 24678** when running frontend in Docker -6. **Sequential port assignment** prevents conflicts in local development - -## Troubleshooting - -### Tests Fail with Module Not Found -**Solution**: Initialize git submodules -```bash -git submodule update --init --recursive -``` - -### Docker Container Can't Find node_modules -**Solution**: Ensure volume exclusions are present in docker-compose configuration -```yaml -volumes: - - /app/node_modules - - /app/dist -``` - -### HMR Not Working in Docker -**Solution**: Ensure port 24678 is exposed in docker-compose.override.yml -```yaml -ports: - - "24678:24678" -``` - -### Puppeteer PDF Generation Fails -**Solution**: Verify Chromium is installed in the container and PUPPETEER_EXECUTABLE_PATH is set correctly - -## Project Workflow Summary - -``` -1. Clone Repo → Initialize Submodules - ↓ -2. Install Dependencies (Backend & Frontend) - ↓ -3. Run Tests (Sequential: Backend → Frontend) - ↓ -4. Docker Setup (Copy templates, configure env) - ↓ -5. Start Development (docker-compose up) - ↓ -6. Develop & Test (Iterate with HMR) - ↓ -7. Build & Deploy (Production builds) -``` - -## Additional Resources - -- Backend Swagger API Documentation: `/api` endpoint (when running) -- React-Admin Documentation: https://marmelab.com/react-admin/ -- NestJS Documentation: https://docs.nestjs.com/ diff --git a/client/.gitignore b/client/.gitignore index 800f3a80..0c512d8a 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -22,3 +22,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +.vite-cache/ From fac91fec9d59e39c1183d0fdbea3e13fe276398e Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sat, 9 May 2026 21:00:48 +0000 Subject: [PATCH 20/37] chore: sync shared submodules to main and align app configs --- client/jest.config.js | 1 + client/shared | 2 +- server/shared | 2 +- server/src/entities.module.ts | 3 ++- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/jest.config.js b/client/jest.config.js index c51439c3..8ff6fde1 100644 --- a/client/jest.config.js +++ b/client/jest.config.js @@ -1,4 +1,5 @@ const base = require('./shared/config/jest.base'); module.exports = { ...base, + setupFilesAfterEnv: ['/src/setupTests.js'], }; \ No newline at end of file diff --git a/client/shared b/client/shared index 94697619..df48787f 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit 946976198b50d04660cf907db6da4973aa04755d +Subproject commit df48787f1e635825a262f163dc56f8ac26331234 diff --git a/server/shared b/server/shared index 9b5158db..4e5bdadc 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit 9b5158db322fef95b1c5b008026808a093541378 +Subproject commit 4e5bdadc935d2dc3d943704ce2eeb53b1710ec79 diff --git a/server/src/entities.module.ts b/server/src/entities.module.ts index 6a63b532..f79b3a5f 100644 --- a/server/src/entities.module.ts +++ b/server/src/entities.module.ts @@ -38,6 +38,7 @@ import absenceTypeConfig from "./entity-modules/absenceType.config"; import uploadedFileConfig from "@shared/entities/configs/uploaded-file.config"; import { Student } from "./db/entities/Student.entity"; import { Teacher } from "./db/entities/Teacher.entity"; +import userConfig from "../shared/entities/configs/user.config"; registerEntityNameMap({ att_report: 'נוכחות', @@ -54,7 +55,7 @@ registerEntityNameMap({ @Module({ imports: [ - ...createSharedEntitiesImports(), + ...createSharedEntitiesImports(userConfig), BaseEntityModule.register(attReportConfig), BaseEntityModule.register(attReportWithReportMonthConfig), BaseEntityModule.register(gradeConfig), From 1e55dfbb3486a8fc09a22640ea8aa94eb9a91926 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sat, 9 May 2026 21:10:59 +0000 Subject: [PATCH 21/37] ci: use correct inputs for shared reusable test workflow --- .github/workflows/run-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 2e476500..db4af482 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,5 +9,6 @@ jobs: tests: uses: buzz-code/multi-repo-codespace/.github/workflows/reusable-tests.yml@main with: - run_e2e: true + run_client: true + run_server: true From 90f51b0135211783a573d26835094d58e4cdccd2 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sat, 9 May 2026 21:23:40 +0000 Subject: [PATCH 22/37] fix: address copilot CI, docker, and compose review feedback --- .github/workflows/run-tests.yml | 2 +- docker-compose.override.yml | 1 + docker-compose.override.yml.template | 1 + server/Dockerfile | 3 --- server/helpers/sync-db-from-data-sql.sh | 14 +++++++------- server/src/entities.module.ts | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index db4af482..310a4e0c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -7,7 +7,7 @@ on: jobs: tests: - uses: buzz-code/multi-repo-codespace/.github/workflows/reusable-tests.yml@main + uses: buzz-code/multi-repo-codespace/.github/workflows/reusable-tests.yml@2fd248e058518a8d28f0ee90f03c73e187904c7e with: run_client: true run_server: true diff --git a/docker-compose.override.yml b/docker-compose.override.yml index afa5719a..ac2b47db 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -10,6 +10,7 @@ services: REACT_APP_API_URL: http://localhost:3001 ports: - "3000:3000" + - "24678:24678" healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"] interval: 10s diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index afa5719a..ac2b47db 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -10,6 +10,7 @@ services: REACT_APP_API_URL: http://localhost:3001 ports: - "3000:3000" + - "24678:24678" healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"] interval: 10s diff --git a/server/Dockerfile b/server/Dockerfile index 8bc355ec..cf730d02 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -28,9 +28,6 @@ COPY .yarnclean /app/ RUN yarn install --frozen-lockfile -# Copy shared directory first for better layer caching -COPY shared /app/shared -# Copy the rest of the application COPY . . RUN yarn build diff --git a/server/helpers/sync-db-from-data-sql.sh b/server/helpers/sync-db-from-data-sql.sh index df2f13b4..a4d8ec4d 100755 --- a/server/helpers/sync-db-from-data-sql.sh +++ b/server/helpers/sync-db-from-data-sql.sh @@ -8,8 +8,8 @@ set -e echo "🔄 Syncing database from data.sql..." # Check if docker compose is running -if ! docker compose ps mysql | grep -q "Up"; then - echo "❌ Database container is not running. Please start it with: docker compose up -d mysql" +if ! docker compose ps database | grep -q "Up"; then + echo "❌ Database container is not running. Please start it with: docker compose up -d database" exit 1 fi @@ -17,7 +17,7 @@ fi echo "⏳ Waiting for MySQL to be ready..." timeout=30 counter=0 -until docker compose exec mysql mysqladmin ping -h localhost --silent 2>/dev/null; do +until docker compose exec database mysqladmin ping -h localhost --silent 2>/dev/null; do sleep 1 counter=$((counter + 1)) if [ $counter -ge $timeout ]; then @@ -35,15 +35,15 @@ DB_PASSWORD=${MYSQL_PASSWORD:-mysql_password} # Drop and recreate database echo "🗑️ Dropping existing database..." -docker compose exec mysql mysql -u"$DB_USER" -p"$DB_PASSWORD" -e "DROP DATABASE IF EXISTS \`$DB_NAME\`;" +docker compose exec database mysql -u"$DB_USER" -p"$DB_PASSWORD" -e "DROP DATABASE IF EXISTS \`$DB_NAME\`;" echo "📦 Creating fresh database..." -docker compose exec mysql mysql -u"$DB_USER" -p"$DB_PASSWORD" -e "CREATE DATABASE \`$DB_NAME\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" +docker compose exec database mysql -u"$DB_USER" -p"$DB_PASSWORD" -e "CREATE DATABASE \`$DB_NAME\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" # Import data.sql echo "📥 Importing data.sql..." -docker compose exec -T mysql mysql -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" < db/data.sql +docker compose exec -T database mysql -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" < db/data.sql echo "✅ Database synced successfully!" echo "" -echo "💡 You can now run: docker compose exec backend yarn typeorm:generate src/migrations/migrationMeaningfulName -p --dr" +echo "💡 You can now run: docker compose exec server yarn typeorm:generate src/migrations/migrationMeaningfulName -p --dr" diff --git a/server/src/entities.module.ts b/server/src/entities.module.ts index f79b3a5f..ce419e5c 100644 --- a/server/src/entities.module.ts +++ b/server/src/entities.module.ts @@ -38,7 +38,7 @@ import absenceTypeConfig from "./entity-modules/absenceType.config"; import uploadedFileConfig from "@shared/entities/configs/uploaded-file.config"; import { Student } from "./db/entities/Student.entity"; import { Teacher } from "./db/entities/Teacher.entity"; -import userConfig from "../shared/entities/configs/user.config"; +import userConfig from "@shared/entities/configs/user.config"; registerEntityNameMap({ att_report: 'נוכחות', From ade1c60aa069b8e4d42a66de7475c491c9324d28 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sat, 9 May 2026 21:27:34 +0000 Subject: [PATCH 23/37] ci: inline test jobs to remove cross-repo reusable workflow dependency --- .github/workflows/run-tests.yml | 40 ++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 310a4e0c..cd607229 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -6,9 +6,39 @@ on: - main jobs: - tests: - uses: buzz-code/multi-repo-codespace/.github/workflows/reusable-tests.yml@2fd248e058518a8d28f0ee90f03c73e187904c7e - with: - run_client: true - run_server: true + server-tests: + name: Run server tests + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./server + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' + cache-dependency-path: server/yarn.lock + - run: yarn + - run: yarn test + + client-tests: + name: Run client tests + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./client + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' + cache-dependency-path: client/yarn.lock + - run: yarn + - run: yarn test From 8d65bae91627061016b1413f2eef61ef7ff90521 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sat, 9 May 2026 21:42:26 +0000 Subject: [PATCH 24/37] fix: remove network override from dev compose, restore e2e in CI, drop stale e2e test --- .github/workflows/run-tests.yml | 1 + docker-compose.override.yml | 4 ---- docker-compose.override.yml.template | 4 ---- server/test/app.e2e-spec.ts | 7 ------- 4 files changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index cd607229..10315c01 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -23,6 +23,7 @@ jobs: cache-dependency-path: server/yarn.lock - run: yarn - run: yarn test + - run: yarn test:e2e client-tests: name: Run client tests diff --git a/docker-compose.override.yml b/docker-compose.override.yml index ac2b47db..1a8e8d98 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -51,7 +51,3 @@ services: networks: private-network: - caddy: - external: false - elknet: - external: false diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index ac2b47db..1a8e8d98 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -51,7 +51,3 @@ services: networks: private-network: - caddy: - external: false - elknet: - external: false diff --git a/server/test/app.e2e-spec.ts b/server/test/app.e2e-spec.ts index 715c07bc..605a1f08 100644 --- a/server/test/app.e2e-spec.ts +++ b/server/test/app.e2e-spec.ts @@ -23,13 +23,6 @@ describe('AppController (e2e)', () => { await app.close(); }); - it('/ (GET)', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect(/^Hello World! Server started at /); - }); - it('should use SQLite in-memory database for E2E tests', () => { expect(dataSource).toBeDefined(); expect(dataSource.options.type).toBe('sqlite'); From 6c88be21e4e9cd7de0307a9e1fe5848522e9ce0a Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sat, 9 May 2026 21:59:12 +0000 Subject: [PATCH 25/37] fix: restore paths-filter, recordRepresentation, AGENTS.md, override gitignore - CI: restore prepare job with dorny/paths-filter@v2 so tests only run when relevant client/** or server/** paths changed - App.jsx: restore recordRepresentation on student_by_year (CommonRepresentation), grade_effect_by_user and abs_count_effect_by_user ('effect'); these 3 resources need the old conditional-spread pattern since buildResources doesn't support recordRepresentation - .gitignore: re-add docker-compose.override.yml (should stay local, not committed) - AGENTS.md: restore deleted file from main --- .github/workflows/run-tests.yml | 26 ++++ .gitignore | 1 + AGENTS.md | 245 ++++++++++++++++++++++++++++++++ client/src/App.jsx | 6 +- docker-compose.override.yml | 53 ------- 5 files changed, 275 insertions(+), 56 deletions(-) create mode 100644 AGENTS.md delete mode 100644 docker-compose.override.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 10315c01..46409518 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -6,9 +6,33 @@ on: - main jobs: + prepare: + name: Prepare changes + runs-on: ubuntu-latest + outputs: + client: ${{ steps.changes.outputs.client }} + server: ${{ steps.changes.outputs.server }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Filter changes + uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + client: + - 'client/**' + server: + - 'server/**' + server-tests: name: Run server tests runs-on: ubuntu-latest + needs: prepare + if: ${{ needs.prepare.outputs.server == 'true' }} defaults: run: working-directory: ./server @@ -28,6 +52,8 @@ jobs: client-tests: name: Run client tests runs-on: ubuntu-latest + needs: prepare + if: ${{ needs.prepare.outputs.client == 'true' }} defaults: run: working-directory: ./client diff --git a/.gitignore b/.gitignore index 6e565582..f893cca2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .env +docker-compose.override.yml /.idea/* diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..d9b33c05 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,245 @@ +# Agent Workflow Documentation + +## Project Structure + +This is a full-stack application built with: +- **Backend**: NestJS (TypeScript) - located in `/server` +- **Frontend**: React with React-Admin (JavaScript/JSX) - located in `/client` +- **Shared Code**: Git submodules containing shared utilities + - `client/shared` - [nra-client](https://github.com/buzz-code/nra-client) + - `server/shared` - [nra-server](https://github.com/buzz-code/nra-server) + +## Initial Setup + +### 1. Clone Repository with Submodules +```bash +git clone +cd react-admin-nestjs +git submodule update --init --recursive +``` + +**Important**: The shared submodules MUST be initialized before running tests or building. + +### 2. Install Dependencies + +Backend: +```bash +cd server +yarn install +``` + +Frontend: +```bash +cd client +yarn install +``` + +## Testing Workflow + +### Backend Tests (NestJS) +```bash +cd server +yarn test +``` +- Test Framework: Jest with ts-jest +- Test Pattern: `*.spec.ts` or `*.test.ts` +- Expected Results: 79 test suites, 789 tests (as of current state) + +### Frontend Tests (React) +```bash +cd client +yarn test +``` +- Test Framework: Jest with jsdom +- Test Pattern: `*.test.js` or `*.spec.js` +- Expected Results: 11 test suites, 87 tests (as of current state) + +### Test Execution Sequence +1. **Always** run backend tests first +2. Then run frontend tests +3. Do not proceed with deployment or Docker setup if tests fail + +## Docker Development Workflow + +### Configuration Files +- `docker-compose.yml` - Base production configuration +- `docker-compose.override.yml.template` - Development overrides template + +### Port Assignments (Local Development) +Sequential port mapping for services: +- **Frontend (Vite)**: + - Main dev server: `3000` + - HMR (Hot Module Replacement): `24678` ⚠️ **Must be exposed** +- **Backend (NestJS)**: `3001` (maps to container port 3000) +- **MySQL**: `3306` +- **PhpMyAdmin**: `8080` + +### Volume Management for node_modules Reuse + +The Docker setup is optimized to reuse `node_modules` installed on the host machine, preventing duplicate installations inside containers: + +```yaml +volumes: + - ./client:/app # Mount source code + - /app/node_modules # Exclude: use container's node_modules + - /app/dist # Exclude: use container's dist +``` + +**Benefits**: +- Faster container startup +- Reduced disk space usage +- Consistent dependency versions between host and container + +### Running Docker Development Environment + +1. Copy the override template: +```bash +cp docker-compose.override.yml.template docker-compose.override.yml +``` + +2. Set up environment: +```bash +cp .env.template .env +# Edit .env with your configuration +``` + +3. Start services: +```bash +docker-compose up -d +``` + +4. View logs: +```bash +docker-compose logs -f frontend +docker-compose logs -f backend +``` + +## Puppeteer Configuration + +Puppeteer is used for PDF generation in reports and is properly configured in the backend. + +### Dockerfile Setup +The backend Dockerfile includes Chromium browser installation: +```dockerfile +RUN apk add --no-cache \ + udev \ + ttf-freefont \ + chromium +ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser +``` + +### Usage Location +- Primary use: `server/shared/utils/report/markup-to-pdf.generator.ts` +- Purpose: Convert HTML markup to PDF reports +- Configuration: Sandboxed mode with proper flags for Docker environment + +### Maintenance Notes +- Keep Puppeteer in the workflow unless it causes blocking issues +- The Chromium version is managed by Alpine package manager +- PDF generation tests are included in the test suite + +## Frontend Constants and Configuration + +### Vite Configuration +Located in `client/vite.config.js`: + +```javascript +server: { + host: '0.0.0.0', + port: Number(process.env.PORT || 3000), + hmr: { + overlay: true, + port: 24678, // HMR WebSocket port + timeout: 1000, + clientPort: 24678, + host: 'localhost', + }, +} +``` + +### Important Notes +- HMR (Hot Module Replacement) requires port **24678** to be exposed +- The main dev server port defaults to 3000 but can be configured via `PORT` env var +- API URL is configured via `REACT_APP_API_URL` environment variable + +## CI/CD Considerations + +### Pre-Deployment Checklist +1. ✅ All backend tests pass +2. ✅ All frontend tests pass +3. ✅ Git submodules are up to date +4. ✅ Docker containers build successfully +5. ✅ Environment variables are properly configured + +### Build Commands + +Backend production build: +```bash +cd server +yarn build +``` + +Frontend production build: +```bash +cd client +yarn build +``` + +## Development Best Practices + +1. **Always initialize submodules** before starting work +2. **Run tests locally** before committing +3. **Use Docker override** for local development customization +4. **Keep node_modules** on host machine for faster development +5. **Expose HMR port 24678** when running frontend in Docker +6. **Sequential port assignment** prevents conflicts in local development + +## Troubleshooting + +### Tests Fail with Module Not Found +**Solution**: Initialize git submodules +```bash +git submodule update --init --recursive +``` + +### Docker Container Can't Find node_modules +**Solution**: Ensure volume exclusions are present in docker-compose configuration +```yaml +volumes: + - /app/node_modules + - /app/dist +``` + +### HMR Not Working in Docker +**Solution**: Ensure port 24678 is exposed in docker-compose.override.yml +```yaml +ports: + - "24678:24678" +``` + +### Puppeteer PDF Generation Fails +**Solution**: Verify Chromium is installed in the container and PUPPETEER_EXECUTABLE_PATH is set correctly + +## Project Workflow Summary + +``` +1. Clone Repo → Initialize Submodules + ↓ +2. Install Dependencies (Backend & Frontend) + ↓ +3. Run Tests (Sequential: Backend → Frontend) + ↓ +4. Docker Setup (Copy templates, configure env) + ↓ +5. Start Development (docker-compose up) + ↓ +6. Develop & Test (Iterate with HMR) + ↓ +7. Build & Deploy (Production builds) +``` + +## Additional Resources + +- Backend Swagger API Documentation: `/api` endpoint (when running) +- React-Admin Documentation: https://marmelab.com/react-admin/ +- NestJS Documentation: https://docs.nestjs.com/ diff --git a/client/src/App.jsx b/client/src/App.jsx index 8f2f775d..90f2ce79 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -148,13 +148,13 @@ const App = () => ( { name: 'grade_name', config: gradeName, icon: LabelIcon, menuGroup: 'settings' }, { name: 'attendance_name', config: attendanceName, icon: LabelIcon, menuGroup: 'settings' }, { name: 'att_grade_effect', config: attGradeEffect, icon: CalculateIcon, menuGroup: 'settings' }, - p => isAdmin(p) && { name: 'student_by_year', config: resourceEntityGuesser, icon: PermContactCalendarIcon, menuGroup: 'admin' }, - p => isAdmin(p) && { name: 'grade_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin' }, - p => isAdmin(p) && { name: 'abs_count_effect_by_user', config: resourceEntityGuesser, icon: AdminPanelSettingsIcon, menuGroup: 'admin' }, ]; return ( <> {buildResources(adminResources, permissions)} + + + {/* student resource has a nested route so stays inline */} } /> diff --git a/docker-compose.override.yml b/docker-compose.override.yml deleted file mode 100644 index 1a8e8d98..00000000 --- a/docker-compose.override.yml +++ /dev/null @@ -1,53 +0,0 @@ -version: "3" -name: react-admin-nestjs-dev -services: - client: - container_name: ran-client-dev - build: - target: development - environment: - PORT: 3000 - REACT_APP_API_URL: http://localhost:3001 - ports: - - "3000:3000" - - "24678:24678" - healthcheck: - test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"] - interval: 10s - timeout: 5s - start_period: 60s - retries: 3 - volumes: - - ./client:/app - - ./client/node_modules:/app/node_modules - networks: - - private-network - - server: - container_name: ran-server-dev - build: - target: development - command: sh -c "yarn typeorm:run && yarn start:dev" - ports: - - "3001:3000" - volumes: - - ./server:/app - - ./server/node_modules:/app/node_modules - networks: - - private-network - - database: - container_name: ran-database-dev - ports: - - "3306:3306" - - phpmyadmin: - container_name: ran-phpmyadmin-dev - profiles: [tools] - ports: - - "8080:80" - networks: - - private-network - -networks: - private-network: From cf18fe353d5458c01c5352df514effa157252dc6 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 18:46:07 +0000 Subject: [PATCH 26/37] fix: restore student menu order and swagger config - App.jsx: split adminResources into preStudentResources and postStudentResources so student (with nested route) is declared between lesson and student_klass, restoring the original data-group menu order - main.ts: pass explicit swagger title/description/tag to bootstrapNraApplication instead of relying on package.json name --- client/src/App.jsx | 16 ++++++++++------ server/src/main.ts | 6 +++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index 90f2ce79..b425b559 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -126,11 +126,15 @@ const App = () => ( <> ); } - const adminResources = [ + // student has a nested route so cannot go through buildResources; it sits between + // lesson and student_klass to preserve the original data-group menu order. + const preStudentResources = [ { name: 'teacher', config: teacher, icon: BadgeIcon, menuGroup: 'data' }, { name: 'klass_type', config: klassType, icon: CategoryIcon, menuGroup: 'data' }, { name: 'klass', config: klass, icon: SupervisedUserCircleIcon, menuGroup: 'data' }, { name: 'lesson', config: lesson, icon: SchoolIcon, menuGroup: 'data' }, + ]; + const postStudentResources = [ { name: 'student_klass', config: studentKlass, icon: WorkspacesIcon, menuGroup: 'data' }, p => (isTransportation(p) || isAdmin(p)) && { name: 'transportation', config: transportation, icon: DirectionsBusIcon, menuGroup: 'data' }, p => (isAbsenceType(p) || isAdmin(p)) && { name: 'absence_type', config: absenceType, icon: CelebrationIcon, menuGroup: 'data' }, @@ -151,14 +155,14 @@ const App = () => ( ]; return ( <> - {buildResources(adminResources, permissions)} - - - - {/* student resource has a nested route so stays inline */} + {buildResources(preStudentResources, permissions)} } /> + {buildResources(postStudentResources, permissions)} + + + {CommonSettingsResources()} {CommonAdminResources({ permissions })} diff --git a/server/src/main.ts b/server/src/main.ts index bad702d0..58e00613 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -2,4 +2,8 @@ import '@shared/config/crud.config'; import { AppModule } from 'src/app.module'; import { bootstrapNraApplication } from '@shared/utils/bootstrap.util'; -bootstrapNraApplication(AppModule); +bootstrapNraApplication(AppModule, { + swaggerTitle: 'react-admin-nestjs', + swaggerDescription: 'Demo website description', + swaggerTag: 'demo', +}); From 3e85ed6e0e99d5d34363d058b5cca936c6180286 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 18:50:10 +0000 Subject: [PATCH 27/37] refactor: revert App.jsx to flat inline Resources buildResources DSL adds more complexity than it removes here: - student needs nested route (can't use DSL) - 3 admin resources need recordRepresentation (can't use DSL) - splits a simple sequential list into two arrays + inline elements The original flat style is cleaner and easier to read. --- client/src/App.jsx | 53 +++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index b425b559..0dde49d2 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -1,5 +1,4 @@ import { Resource, CustomRoutes } from 'react-admin'; -import { buildResources } from '@shared/components/app/buildResources'; import { Route } from 'react-router-dom'; import { blue, purple } from '@mui/material/colors'; @@ -126,44 +125,36 @@ const App = () => ( <> ); } - // student has a nested route so cannot go through buildResources; it sits between - // lesson and student_klass to preserve the original data-group menu order. - const preStudentResources = [ - { name: 'teacher', config: teacher, icon: BadgeIcon, menuGroup: 'data' }, - { name: 'klass_type', config: klassType, icon: CategoryIcon, menuGroup: 'data' }, - { name: 'klass', config: klass, icon: SupervisedUserCircleIcon, menuGroup: 'data' }, - { name: 'lesson', config: lesson, icon: SchoolIcon, menuGroup: 'data' }, - ]; - const postStudentResources = [ - { name: 'student_klass', config: studentKlass, icon: WorkspacesIcon, menuGroup: 'data' }, - p => (isTransportation(p) || isAdmin(p)) && { name: 'transportation', config: transportation, icon: DirectionsBusIcon, menuGroup: 'data' }, - p => (isAbsenceType(p) || isAdmin(p)) && { name: 'absence_type', config: absenceType, icon: CelebrationIcon, menuGroup: 'data' }, - { name: 'att_report_with_report_month', config: attReportWithReportMonth, icon: ViewListIcon, menuGroup: 'data' }, - { name: 'grade', config: grade, icon: GradingIcon, menuGroup: 'data' }, - { name: 'known_absence', config: knownAbsence, icon: PlaylistRemoveIcon, menuGroup: 'data' }, - { name: 'student_klass_report', config: studentKlassesReport, icon: GroupWorkIcon, menuGroup: 'report' }, - { name: 'teacher_report_status', config: teacherReportStatus, icon: RuleIcon, menuGroup: 'report' }, - { name: 'teacher_grade_report_status', config: teacherGradeReportStatus, icon: RuleIcon, menuGroup: 'report' }, - { name: 'teacher_salary_report', config: teacherSalaryReport, icon: LocalAtmIcon, menuGroup: 'report' }, - p => isAdmin(p) && { name: 'student_percent_report', config: studentPercentReport, icon: SummarizeIcon, menuGroup: 'report' }, - { name: 'report_month', config: reportMonth, icon: DateRangeIcon, menuGroup: 'settings' }, - p => isUploadedFiles(p) && { name: 'uploaded_file', config: uploadedFile, icon: UploadFileIcon, menuGroup: 'settings' }, - { name: 'att_report', config: attReport, icon: ViewListIcon, menuGroup: 'settings' }, - { name: 'grade_name', config: gradeName, icon: LabelIcon, menuGroup: 'settings' }, - { name: 'attendance_name', config: attendanceName, icon: LabelIcon, menuGroup: 'settings' }, - { name: 'att_grade_effect', config: attGradeEffect, icon: CalculateIcon, menuGroup: 'settings' }, - ]; return ( <> - {buildResources(preStudentResources, permissions)} + + + + } /> - {buildResources(postStudentResources, permissions)} + + {(isTransportation(permissions) || isAdmin(permissions)) && } + {(isAbsenceType(permissions) || isAdmin(permissions)) && } + + + + + + + + {isAdmin(permissions) && } + + {CommonSettingsResources()} + {isUploadedFiles(permissions) && } + + + + - {CommonSettingsResources()} {CommonAdminResources({ permissions })} {isLessonSignature(permissions) && <> From 4585c09924f62d9d32de0a7e009832e9b0baf5fc Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 18:59:58 +0000 Subject: [PATCH 28/37] fix: use anonymous volumes for node_modules in override template Host bind-mounts (./client/node_modules:/app/node_modules) break when the host directory doesn't exist (Docker creates a root-owned empty dir that blocks yarn install) and fail on non-Linux hosts with native modules. Anonymous volumes (/app/node_modules) let Docker own the directory, matching the documented strategy in AGENTS.md. --- docker-compose.override.yml.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index 1a8e8d98..7ca15516 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -19,7 +19,7 @@ services: retries: 3 volumes: - ./client:/app - - ./client/node_modules:/app/node_modules + - /app/node_modules networks: - private-network @@ -32,7 +32,7 @@ services: - "3001:3000" volumes: - ./server:/app - - ./server/node_modules:/app/node_modules + - /app/node_modules networks: - private-network From d79b8edbdc13514804cc1b7d9ca8c4fc16fd4ca5 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 19:23:37 +0000 Subject: [PATCH 29/37] fix: restore caddy/elknet external:false in override template (needed to override base file's external:true) --- docker-compose.override.yml.template | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index 7ca15516..8f1c5641 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -51,3 +51,7 @@ services: networks: private-network: + caddy: + external: false + elknet: + external: false From 1ee59ca87248f765f3f6948926c5306cef14d14f Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 19:25:17 +0000 Subject: [PATCH 30/37] fix: revert to host bind-mount for node_modules (Dockerfile dev stage relies on host-mounted deps) --- docker-compose.override.yml.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template index 8f1c5641..ac2b47db 100644 --- a/docker-compose.override.yml.template +++ b/docker-compose.override.yml.template @@ -19,7 +19,7 @@ services: retries: 3 volumes: - ./client:/app - - /app/node_modules + - ./client/node_modules:/app/node_modules networks: - private-network @@ -32,7 +32,7 @@ services: - "3001:3000" volumes: - ./server:/app - - /app/node_modules + - ./server/node_modules:/app/node_modules networks: - private-network From 370c5603f80e2622e87d615c2cb0f7696cbae636 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 19:28:41 +0000 Subject: [PATCH 31/37] chore: update nra-server submodule (reflect-metadata migration fix) --- server/shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared b/server/shared index 4e5bdadc..134e5e1e 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit 4e5bdadc935d2dc3d943704ce2eeb53b1710ec79 +Subproject commit 134e5e1e3949c1c40a2cc629c62f7d824b01a01c From bed99b612b0fa761a1a90d646554d46f22e9eb61 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 19:34:14 +0000 Subject: [PATCH 32/37] chore: update nra-server submodule (AuditLog explicit column types) --- server/shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared b/server/shared index 134e5e1e..d6e26bd6 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit 134e5e1e3949c1c40a2cc629c62f7d824b01a01c +Subproject commit d6e26bd6ce4a0a07ee7c169c0bf421b706c766e7 From 037b628858a57fbe00c7a6dfabf760fdb85c4347 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 19:35:40 +0000 Subject: [PATCH 33/37] chore: update nra-server (boolean column fix) --- server/shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shared b/server/shared index d6e26bd6..35e4814b 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit d6e26bd6ce4a0a07ee7c169c0bf421b706c766e7 +Subproject commit 35e4814b176faa81fac00d3b4d5a9d2189fd0358 From 6011ab63d7aaa654dc3da271fb51a6fe58c72174 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 19:40:42 +0000 Subject: [PATCH 34/37] fix: remove --transpile-only from typeorm:cli so emitDecoratorMetadata works for column type inference --- server/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/package.json b/server/package.json index efcee350..9f7c0928 100644 --- a/server/package.json +++ b/server/package.json @@ -19,7 +19,7 @@ "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json", - "typeorm:cli": "ts-node --transpile-only -r tsconfig-paths/register ./node_modules/typeorm/cli -d shared/config/migration.config.ts", + "typeorm:cli": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli -d shared/config/migration.config.ts", "typeorm:cli-js": "typeorm -d dist/shared/config/migration.config.js", "typeorm:cli-no-d": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli", "typeorm:run": "npm run typeorm:cli -- migration:run", From e02e7e9d46d2abc3a3530d9ea61936cdca6b0aca Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 10 May 2026 19:42:52 +0000 Subject: [PATCH 35/37] fix: add --project tsconfig.json to ts-node in typeorm:cli for proper decorator metadata --- server/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/package.json b/server/package.json index 9f7c0928..ed402d3e 100644 --- a/server/package.json +++ b/server/package.json @@ -19,7 +19,7 @@ "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json", - "typeorm:cli": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli -d shared/config/migration.config.ts", + "typeorm:cli": "ts-node --project tsconfig.json -r tsconfig-paths/register ./node_modules/typeorm/cli -d shared/config/migration.config.ts", "typeorm:cli-js": "typeorm -d dist/shared/config/migration.config.js", "typeorm:cli-no-d": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli", "typeorm:run": "npm run typeorm:cli -- migration:run", From cb51314c7141716d672b6920cfd65f2e8b1a9568 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 17 May 2026 19:49:34 +0000 Subject: [PATCH 36/37] test: add GET / endpoint e2e test --- server/test/app.e2e-spec.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/test/app.e2e-spec.ts b/server/test/app.e2e-spec.ts index 605a1f08..708bd0f6 100644 --- a/server/test/app.e2e-spec.ts +++ b/server/test/app.e2e-spec.ts @@ -28,4 +28,13 @@ describe('AppController (e2e)', () => { expect(dataSource.options.type).toBe('sqlite'); expect((dataSource.options as any).database).toBe(':memory:'); }); + + it('GET / should return 200 with Hello World message', () => { + return request(app.getHttpServer()) + .get('/') + .expect(200) + .expect((res) => { + expect(res.text).toContain('Hello World!'); + }); + }); }); From 7e430ce23345b4a749c91ce94fb4937cd57c22b2 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Sun, 17 May 2026 20:00:44 +0000 Subject: [PATCH 37/37] test: use shared e2e factory, align jest-e2e config --- server/shared | 2 +- server/test/app.e2e-spec.ts | 40 ++----------------------------------- server/test/jest-e2e.json | 25 +++++++++++++++++------ server/test/setup-tests.ts | 12 +++++++++++ 4 files changed, 34 insertions(+), 45 deletions(-) create mode 100644 server/test/setup-tests.ts diff --git a/server/shared b/server/shared index 35e4814b..ef761f09 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit 35e4814b176faa81fac00d3b4d5a9d2189fd0358 +Subproject commit ef761f09e0798d6eefc337cc3ea27991b92f4268 diff --git a/server/test/app.e2e-spec.ts b/server/test/app.e2e-spec.ts index 708bd0f6..b342c5f5 100644 --- a/server/test/app.e2e-spec.ts +++ b/server/test/app.e2e-spec.ts @@ -1,40 +1,4 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; import { AppModule } from 'src/app.module'; -import { DataSource } from 'typeorm'; +import { createSharedAppE2eTests } from '@shared/utils/testing/e2e/app-e2e.shared'; -describe('AppController (e2e)', () => { - let app: INestApplication; - let dataSource: DataSource; - - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - - dataSource = moduleFixture.get(DataSource); - }); - - afterEach(async () => { - await app.close(); - }); - - it('should use SQLite in-memory database for E2E tests', () => { - expect(dataSource).toBeDefined(); - expect(dataSource.options.type).toBe('sqlite'); - expect((dataSource.options as any).database).toBe(':memory:'); - }); - - it('GET / should return 200 with Hello World message', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect((res) => { - expect(res.text).toContain('Hello World!'); - }); - }); -}); +createSharedAppE2eTests(AppModule); diff --git a/server/test/jest-e2e.json b/server/test/jest-e2e.json index 915e569a..18c9331a 100644 --- a/server/test/jest-e2e.json +++ b/server/test/jest-e2e.json @@ -1,15 +1,28 @@ { - "moduleFileExtensions": ["js", "json", "ts", "tsx", "jsx"], - "rootDir": "..", + "moduleFileExtensions": [ + "js", + "json", + "ts", + "tsx", + "jsx" + ], + "rootDir": ".", "testEnvironment": "node", "testRegex": ".e2e-spec.ts$", "transform": { "^.+\\.(t|j)sx?$": "ts-jest" }, "forceExit": true, + "detectOpenHandles": true, + "maxWorkers": 1, "moduleNameMapper": { - "^src/(.*)$": "/src/$1", - "^@shared/(.*)$": "/shared/$1" + "^src/(.*)$": "/../src/$1", + "^@shared/(.*)$": "/../shared/$1" }, - "setupFiles": ["/test/setup-e2e.ts"] -} + "modulePaths": [ + "/../" + ], + "setupFilesAfterEnv": [ + "/setup-tests.ts" + ] +} \ No newline at end of file diff --git a/server/test/setup-tests.ts b/server/test/setup-tests.ts new file mode 100644 index 00000000..262f4d2a --- /dev/null +++ b/server/test/setup-tests.ts @@ -0,0 +1,12 @@ +// Global test setup for e2e tests +jest.setTimeout(10000); + +process.env.NODE_ENV = 'test'; +process.env.JWT_SECRET = 'test-secret-key-for-e2e-tests'; +process.env.JWT_EXPIRES_IN = '1h'; + +process.on('unhandledRejection', (reason) => { + console.warn('Unhandled promise rejection:', reason); +}); + +process.setMaxListeners(20);