diff --git a/client/shared b/client/shared index ad804305..9276a7ea 160000 --- a/client/shared +++ b/client/shared @@ -1 +1 @@ -Subproject commit ad804305f2403e37d03c153da1b757a58cda996d +Subproject commit 9276a7eaa68f99fd88152dd7c845ae0ecf574899 diff --git a/server/helpers/endpoints.env b/server/helpers/endpoints.env new file mode 100644 index 00000000..123ccd5c --- /dev/null +++ b/server/helpers/endpoints.env @@ -0,0 +1 @@ +ENDPOINTS="user att_report att_report_with_report_month grade klass klass_type known_absence lesson student_klass student teacher text student_klass_report student_base_klass student_speciality audit_log import_file report_group report_group_session yemot_call mail_address recieved_mail page report_month teacher_report_status teacher_grade_report_status text_by_user student_percent_report att_report_and_grade student_global_report image student_by_year payment_track teacher_salary_report known_absence_with_report_month grade_name attendance_name att_grade_effect grade_effect_by_user abs_count_effect_by_user lesson_klass_name transportation absence_type uploaded_file" diff --git a/server/helpers/test-all-endpoints.sh b/server/helpers/test-all-endpoints.sh deleted file mode 100755 index eefa5e58..00000000 --- a/server/helpers/test-all-endpoints.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -# Test script for all entity endpoints -# This script tests GET requests to all registered entities in entities.module.ts - -# Backend URL -BACKEND_URL="${BACKEND_URL:-http://localhost:3001}" - -# Admin credentials (should be provided via environment variables) -# Default values are for the template .env.template file -USERNAME="${ADMIN_USER%%:*}" -PASSWORD="${ADMIN_USER#*:}" - -# Fallback to defaults if ADMIN_USER is not set (for backward compatibility) -if [ -z "$USERNAME" ]; then - USERNAME="${USERNAME:-admin_user}" - PASSWORD="${PASSWORD:-admin_password}" -fi - -echo "============================================" -echo "API Endpoints Test - $(date)" -echo "============================================" -echo "" - -# Login and get cookies -echo "Logging in..." -LOGIN_RESPONSE=$(curl -X POST -H "Content-Type: application/json" \ - -d "{\"username\":\"$USERNAME\",\"password\":\"$PASSWORD\"}" \ - -c /tmp/cookies.txt -s "$BACKEND_URL/auth/login") - -if echo "$LOGIN_RESPONSE" | grep -q "true"; then - echo "✓ Login successful" -else - echo "✗ Login failed: $LOGIN_RESPONSE" - exit 1 -fi - -echo "" -echo "Testing entity endpoints..." -echo "" - -# List of all entity endpoints (convert camelCase to snake_case) -# Note: "recieved_mail" spelling is intentional - matches entity name in codebase -ENDPOINTS="user att_report att_report_with_report_month grade klass klass_type known_absence lesson student_klass student teacher text student_klass_report student_base_klass student_speciality audit_log import_file report_group report_group_session yemot_call mail_address recieved_mail page report_month teacher_report_status teacher_grade_report_status text_by_user student_percent_report att_report_and_grade student_global_report image student_by_year payment_track teacher_salary_report known_absence_with_report_month grade_name attendance_name att_grade_effect grade_effect_by_user abs_count_effect_by_user lesson_klass_name" - -# Track results -PASSED=0 -FAILED=0 -ERRORS="" - -# Test each endpoint -for ENDPOINT in $ENDPOINTS; do - printf "Testing %-40s ... " "$ENDPOINT" - - HTTP_CODE=$(curl -b /tmp/cookies.txt -s -o /tmp/response.json -w "%{http_code}" "$BACKEND_URL/$ENDPOINT") - - if [ "$HTTP_CODE" = "200" ]; then - echo "✓ OK (HTTP $HTTP_CODE)" - PASSED=$((PASSED + 1)) - else - echo "✗ FAILED (HTTP $HTTP_CODE)" - FAILED=$((FAILED + 1)) - - # Save error details - ERRORS="$ERRORS -======================================== -Endpoint: $ENDPOINT -HTTP Code: $HTTP_CODE -Response: $(cat /tmp/response.json) -" - fi -done - -echo "" -echo "============================================" -echo "Summary:" -echo " Passed: $PASSED" -echo " Failed: $FAILED" -echo "============================================" - -if [ $FAILED -gt 0 ]; then - echo "" - echo "Error details:" - echo "$ERRORS" -fi - -exit $FAILED \ No newline at end of file diff --git a/server/shared b/server/shared index becee2b3..2f339e04 160000 --- a/server/shared +++ b/server/shared @@ -1 +1 @@ -Subproject commit becee2b3d6ab8c9a13f1fdc1a07a66ad1d0daaca +Subproject commit 2f339e04741a7c1f3ab976c1c4a6e352125c1cbe diff --git a/server/src/entity-modules/__tests__/absenceType.config.spec.ts b/server/src/entity-modules/__tests__/absenceType.config.spec.ts new file mode 100644 index 00000000..49f2f985 --- /dev/null +++ b/server/src/entity-modules/__tests__/absenceType.config.spec.ts @@ -0,0 +1,11 @@ +import { AbsenceType } from 'src/db/entities/AbsenceType.entity'; +import { createEntityConfigTests } from '@shared/utils/testing/entity-config-tester'; +import config from '../absenceType.config'; + +createEntityConfigTests('AbsenceTypeConfig', config, { + entity: AbsenceType, + expectedExportHeaders: { + count: 4, + first: { value: 'name', label: 'סוג חיסור' }, + }, +}); diff --git a/server/src/entity-modules/__tests__/known-absence.config.spec.ts b/server/src/entity-modules/__tests__/known-absence.config.spec.ts new file mode 100644 index 00000000..4dfa0f6c --- /dev/null +++ b/server/src/entity-modules/__tests__/known-absence.config.spec.ts @@ -0,0 +1,21 @@ +import { KnownAbsence } from 'src/db/entities/KnownAbsence.entity'; +import { createEntityConfigTests } from '@shared/utils/testing/entity-config-tester'; +import config from '../known-absence.config'; + +createEntityConfigTests('KnownAbsenceConfig', config, { + entity: KnownAbsence, + expectedJoins: { + student: { eager: false }, + lesson: { eager: false }, + klass: { eager: false }, + absenceType: { eager: false }, + }, + expectedExportJoins: { + student: { eager: true }, + absenceType: { eager: true }, + }, + expectedExportHeaders: { + count: 11, + first: { value: 'student.name', label: 'תלמידה' }, + }, +}); diff --git a/server/src/entity-modules/__tests__/lesson.config.spec.ts b/server/src/entity-modules/__tests__/lesson.config.spec.ts new file mode 100644 index 00000000..80fb9c95 --- /dev/null +++ b/server/src/entity-modules/__tests__/lesson.config.spec.ts @@ -0,0 +1,19 @@ +import { Lesson } from 'src/db/entities/Lesson.entity'; +import { createEntityConfigTests } from '@shared/utils/testing/entity-config-tester'; +import config from '../lesson.config'; + +createEntityConfigTests('LessonConfig', config, { + entity: Lesson, + expectedJoins: { + teacher: { eager: false }, + lessonKlassName: { eager: false }, + }, + expectedExportJoins: { + teacher: { eager: true }, + lessonKlassName: { eager: true }, + }, + expectedExportHeaders: { + count: 7, + first: { value: 'key', label: 'מזהה' }, + }, +}); diff --git a/server/src/entity-modules/__tests__/report-group-session.config.spec.ts b/server/src/entity-modules/__tests__/report-group-session.config.spec.ts new file mode 100644 index 00000000..d523c54c --- /dev/null +++ b/server/src/entity-modules/__tests__/report-group-session.config.spec.ts @@ -0,0 +1,12 @@ +import { ReportGroupSession } from 'src/db/entities/ReportGroupSession.entity'; +import { createEntityConfigTests } from '@shared/utils/testing/entity-config-tester'; +import config from '../report-group-session.config'; + +createEntityConfigTests('ReportGroupSessionConfig', config, { + entity: ReportGroupSession, + expectedJoins: { + reportGroup: { eager: false }, + attReports: { eager: false }, + grades: { eager: false }, + }, +}); diff --git a/server/src/entity-modules/__tests__/report-group.config.spec.ts b/server/src/entity-modules/__tests__/report-group.config.spec.ts new file mode 100644 index 00000000..eb2c6a1e --- /dev/null +++ b/server/src/entity-modules/__tests__/report-group.config.spec.ts @@ -0,0 +1,23 @@ +import { ReportGroup } from 'src/db/entities/ReportGroup.entity'; +import { createEntityConfigTests } from '@shared/utils/testing/entity-config-tester'; +import config from '../report-group.config'; + +createEntityConfigTests('ReportGroupConfig', config, { + entity: ReportGroup, + expectedJoins: { + teacher: { eager: false }, + lesson: { eager: false }, + klass: { eager: false }, + sessions: { eager: false }, + }, + expectedExportJoins: { + teacher: { eager: true }, + lesson: { eager: true }, + klass: { eager: true }, + sessions: { eager: true }, + }, + expectedExportHeaders: { + count: 8, + first: { value: 'name', label: 'שם' }, + }, +}); diff --git a/server/src/entity-modules/__tests__/student-klass-report.config.spec.ts b/server/src/entity-modules/__tests__/student-klass-report.config.spec.ts new file mode 100644 index 00000000..28493dbf --- /dev/null +++ b/server/src/entity-modules/__tests__/student-klass-report.config.spec.ts @@ -0,0 +1,17 @@ +import { StudentKlassReport } from 'src/db/view-entities/StudentKlassReport.entity'; +import { createEntityConfigTests } from '@shared/utils/testing/entity-config-tester'; +import config from '../student-klass-report.config'; + +createEntityConfigTests('StudentKlassReportConfig', config, { + entity: StudentKlassReport, + expectedJoins: { + student: { eager: false }, + }, + expectedExportJoins: { + student: { eager: true }, + }, + expectedExportHeaders: { + count: 10, + first: { value: 'student.tz', label: 'תז' }, + }, +}); diff --git a/server/src/entity-modules/__tests__/teacher-grade-report-status.config.spec.ts b/server/src/entity-modules/__tests__/teacher-grade-report-status.config.spec.ts new file mode 100644 index 00000000..b24626ba --- /dev/null +++ b/server/src/entity-modules/__tests__/teacher-grade-report-status.config.spec.ts @@ -0,0 +1,11 @@ +import { TeacherGradeReportStatus } from 'src/db/view-entities/TeacherGradeReportStatus.entity'; +import { createEntityConfigTests } from '@shared/utils/testing/entity-config-tester'; +import config from '../teacher-grade-report-status.config'; + +createEntityConfigTests('TeacherGradeReportStatusConfig', config, { + entity: TeacherGradeReportStatus, + expectedExportHeaders: { + count: 4, + first: { value: 'teacherName', label: 'מורה' }, + }, +}); diff --git a/server/src/entity-modules/__tests__/teacher-salary-report.config.spec.ts b/server/src/entity-modules/__tests__/teacher-salary-report.config.spec.ts new file mode 100644 index 00000000..901c43bb --- /dev/null +++ b/server/src/entity-modules/__tests__/teacher-salary-report.config.spec.ts @@ -0,0 +1,23 @@ +import { TeacherSalaryReport } from 'src/db/view-entities/TeacherSalaryReport.entity'; +import { createEntityConfigTests } from '@shared/utils/testing/entity-config-tester'; +import config from '../teacher-salary-report.config'; + +createEntityConfigTests('TeacherSalaryReportConfig', config, { + entity: TeacherSalaryReport, + expectedJoins: { + teacher: {}, + lesson: {}, + klass: {}, + reportMonth: {}, + }, + expectedExportJoins: { + teacher: { eager: true }, + klass: { eager: true }, + lesson: { eager: true }, + reportMonth: { eager: true }, + }, + expectedExportHeaders: { + count: 6, + first: { value: 'teacher.name', label: 'שם המורה' }, + }, +}); diff --git a/server/src/entity-modules/__tests__/transportation.config.spec.ts b/server/src/entity-modules/__tests__/transportation.config.spec.ts new file mode 100644 index 00000000..b953fded --- /dev/null +++ b/server/src/entity-modules/__tests__/transportation.config.spec.ts @@ -0,0 +1,11 @@ +import { Transportation } from 'src/db/entities/Transportation.entity'; +import { createEntityConfigTests } from '@shared/utils/testing/entity-config-tester'; +import config from '../transportation.config'; + +createEntityConfigTests('TransportationConfig', config, { + entity: Transportation, + expectedExportHeaders: { + count: 4, + first: { value: 'key', label: 'שילוט' }, + }, +}); diff --git a/server/test/app.e2e-spec.ts b/server/test/app.e2e-spec.ts index fd834eb6..715c07bc 100644 --- a/server/test/app.e2e-spec.ts +++ b/server/test/app.e2e-spec.ts @@ -27,7 +27,7 @@ describe('AppController (e2e)', () => { return request(app.getHttpServer()) .get('/') .expect(200) - .expect('Hello World!'); + .expect(/^Hello World! Server started at /); }); it('should use SQLite in-memory database for E2E tests', () => {