From a6f5d5a914804a35c6acc886c77445c296f32160 Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Wed, 4 Feb 2026 16:46:26 -0800 Subject: [PATCH 01/13] Update application creator to not null --- ...oller.applicationChangeRequest.e2e-spec.ts | 3 +++ .../application/application.service.ts | 2 ++ ...6185-SetApplicationCreatorFromStudentId.ts | 24 +++++++++++++++++++ .../Rollback-set-creator-from-student-id.sql | 9 +++++++ .../Set-creator-from-student-id.sql | 20 ++++++++++++++++ 5 files changed, 58 insertions(+) create mode 100644 sources/packages/backend/apps/db-migrations/src/migrations/1770252146185-SetApplicationCreatorFromStudentId.ts create mode 100644 sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql create mode 100644 sources/packages/backend/apps/db-migrations/src/sql/Applications/Set-creator-from-student-id.sql diff --git a/sources/packages/backend/apps/api/src/route-controllers/application/_tests_/application.students.controller.applicationChangeRequest.e2e-spec.ts b/sources/packages/backend/apps/api/src/route-controllers/application/_tests_/application.students.controller.applicationChangeRequest.e2e-spec.ts index 82213cff91..6c1cd1a1a7 100644 --- a/sources/packages/backend/apps/api/src/route-controllers/application/_tests_/application.students.controller.applicationChangeRequest.e2e-spec.ts +++ b/sources/packages/backend/apps/api/src/route-controllers/application/_tests_/application.students.controller.applicationChangeRequest.e2e-spec.ts @@ -135,6 +135,7 @@ describe("ApplicationStudentsController(e2e)-applicationChangeRequest", () => { applicationEditStatus: true, applicationEditStatusUpdatedOn: true, applicationEditStatusUpdatedBy: { id: true }, + creator: { id: true }, currentAssessment: { id: true, studentAssessmentStatus: true, @@ -152,6 +153,7 @@ describe("ApplicationStudentsController(e2e)-applicationChangeRequest", () => { precedingApplication: true, student: true, applicationEditStatusUpdatedBy: true, + creator: true, currentAssessment: { offering: true, studentAppeal: true, @@ -180,6 +182,7 @@ describe("ApplicationStudentsController(e2e)-applicationChangeRequest", () => { applicationEditStatus: ApplicationEditStatus.ChangeInProgress, applicationEditStatusUpdatedOn: now, applicationEditStatusUpdatedBy: { id: student.user.id }, + creator: { id: student.user.id }, currentAssessment: { id: expect.any(Number), studentAssessmentStatus: StudentAssessmentStatus.Submitted, diff --git a/sources/packages/backend/apps/api/src/services/application/application.service.ts b/sources/packages/backend/apps/api/src/services/application/application.service.ts index ee0361c704..c777d96037 100644 --- a/sources/packages/backend/apps/api/src/services/application/application.service.ts +++ b/sources/packages/backend/apps/api/src/services/application/application.service.ts @@ -515,6 +515,8 @@ export class ApplicationService extends RecordDataModelService { transactionalEntityManager, ); + // Set the creator to the student. + newApplication.creator = auditUser; newApplication.modifier = auditUser; newApplication.updatedAt = now; newApplication.studentAssessments = [originalAssessment]; diff --git a/sources/packages/backend/apps/db-migrations/src/migrations/1770252146185-SetApplicationCreatorFromStudentId.ts b/sources/packages/backend/apps/db-migrations/src/migrations/1770252146185-SetApplicationCreatorFromStudentId.ts new file mode 100644 index 0000000000..dd3be990e0 --- /dev/null +++ b/sources/packages/backend/apps/db-migrations/src/migrations/1770252146185-SetApplicationCreatorFromStudentId.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; +import { getSQLFileData } from "../utilities/sqlLoader"; + +/** + * Migration to set the creator field for applications using the mapped user ID from the student ID. + * This ensures all applications have a non-null creator field that references the student who created/submitted them. + * This addresses the first acceptance criterion of ticket #5154. + */ +export class SetApplicationCreatorFromStudentId1770252146185 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + getSQLFileData("Set-creator-from-student-id.sql", "Applications"), + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + getSQLFileData( + "Rollback-set-creator-from-student-id.sql", + "Applications", + ), + ); + } +} diff --git a/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql new file mode 100644 index 0000000000..aba8b26b2d --- /dev/null +++ b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql @@ -0,0 +1,9 @@ +/* + Since there is no way to know the records that were affect by the migration we are leaving the creator field as is and only rolling back + the alter column to allow nulls. + */ +-- Rollback the creator field to allow NULLs again. +ALTER TABLE + sims.applications +ALTER COLUMN + creator_id DROP NOT NULL; \ No newline at end of file diff --git a/sources/packages/backend/apps/db-migrations/src/sql/Applications/Set-creator-from-student-id.sql b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Set-creator-from-student-id.sql new file mode 100644 index 0000000000..8bb3652b29 --- /dev/null +++ b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Set-creator-from-student-id.sql @@ -0,0 +1,20 @@ +-- Set the creator field for applications using the mapped user ID from the student ID. +-- This migration handles application change requests and other applications that were created with a NULL creator. +-- The creator is set to the student's user ID from the student table. +UPDATE + sims.applications +SET + creator = s.user_id +FROM + sims.students s +WHERE + sims.applications.student_id = s.id + AND sims.applications.creator IS NULL; + +-- Alter the creator field to NOT NULL after setting the values. +ALTER TABLE + sims.applications +ALTER COLUMN + creator +SET + NOT NULL; \ No newline at end of file From 9ce787a09e02caf6e8249d61fd63395a68b21bb8 Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Wed, 4 Feb 2026 17:12:50 -0800 Subject: [PATCH 02/13] Update application.ts --- .../backend/libs/test-utils/src/factories/application.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sources/packages/backend/libs/test-utils/src/factories/application.ts b/sources/packages/backend/libs/test-utils/src/factories/application.ts index 86b9c1d425..3bb4b9dec5 100644 --- a/sources/packages/backend/libs/test-utils/src/factories/application.ts +++ b/sources/packages/backend/libs/test-utils/src/factories/application.ts @@ -38,6 +38,7 @@ import { createFakeStudent } from "./student"; export function createFakeApplication( relations?: { + auditUser?: User; student?: Student; programYear?: ProgramYear; currentStudentAssessment?: StudentAssessment; @@ -91,6 +92,8 @@ export function createFakeApplication( options?.initialValue?.applicationEditStatusUpdatedOn ?? now; application.applicationEditStatusUpdatedBy = relations?.applicationEditStatusUpdatedBy; + application.creator = + options?.initialValue?.creator ?? relations?.auditUser ?? createFakeUser(); return application; } @@ -331,6 +334,7 @@ export async function saveFakeApplication( const fakeApplication = createFakeApplication( { student: savedStudent, + auditUser: savedUser, location: relations?.institutionLocation, programYear: relations?.programYear, applicationException: relations?.applicationException, From 1f02ec9ba6376c15dabd9193ed4d6b55725780b3 Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Wed, 4 Feb 2026 17:33:44 -0800 Subject: [PATCH 03/13] Update application.service.ts --- .../apps/api/src/services/application/application.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sources/packages/backend/apps/api/src/services/application/application.service.ts b/sources/packages/backend/apps/api/src/services/application/application.service.ts index c777d96037..cb0be4237a 100644 --- a/sources/packages/backend/apps/api/src/services/application/application.service.ts +++ b/sources/packages/backend/apps/api/src/services/application/application.service.ts @@ -493,6 +493,7 @@ export class ApplicationService extends RecordDataModelService { ApplicationEditStatus.ChangeInProgress; newApplication.applicationEditStatusUpdatedOn = now; newApplication.applicationEditStatusUpdatedBy = auditUser; + newApplication.creator = auditUser; // While editing an application, a new application record is created and a new // assessment record is also created to be the used as a "current Assessment" record. // The application and the assessment records have a DB relationship and the @@ -515,8 +516,6 @@ export class ApplicationService extends RecordDataModelService { transactionalEntityManager, ); - // Set the creator to the student. - newApplication.creator = auditUser; newApplication.modifier = auditUser; newApplication.updatedAt = now; newApplication.studentAssessments = [originalAssessment]; From 81d2345ee07eb622326d3e47f20a8b9b8871464d Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Thu, 5 Feb 2026 14:15:01 -0800 Subject: [PATCH 04/13] Fix e2e test --- .vscode/launch.json | 24 +++++++++++++++++++ .../application/application.service.ts | 6 +++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 41d5f885e6..9f6cc7807a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -291,6 +291,30 @@ "ENVIRONMENT": "test", "TZ": "UTC" } + }, + { + "type": "node", + "request": "launch", + "name": "API (npm) - Selected test name", + "cwd": "${workspaceFolder}/sources/packages/backend", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run", + "test:e2e:api:local", + "--", + "--runInBand", + "--runTestsByPath", + "${file}", + "--testNamePattern", + "${selectedText}" + ], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "disableOptimisticBPs": true, + "env": { + "ENVIRONMENT": "test", + "TZ": "UTC" + } } ] } diff --git a/sources/packages/backend/apps/api/src/services/application/application.service.ts b/sources/packages/backend/apps/api/src/services/application/application.service.ts index cb0be4237a..d21c45b498 100644 --- a/sources/packages/backend/apps/api/src/services/application/application.service.ts +++ b/sources/packages/backend/apps/api/src/services/application/application.service.ts @@ -298,6 +298,7 @@ export class ApplicationService extends RecordDataModelService { associatedFiles, ); newApplication.location = institutionLocation; + newApplication.creator = auditUser; // While editing an application, a new application record is created and a new // assessment record is also created to be the used as a "current Assessment" record. // The application and the assessment records have a DB relationship and the @@ -319,8 +320,6 @@ export class ApplicationService extends RecordDataModelService { auditUserId, transactionalEntityManager, ); - - newApplication.creator = auditUser; newApplication.studentAssessments = [originalAssessment]; newApplication.currentAssessment = originalAssessment; @@ -492,6 +491,7 @@ export class ApplicationService extends RecordDataModelService { newApplication.applicationEditStatus = ApplicationEditStatus.ChangeInProgress; newApplication.applicationEditStatusUpdatedOn = now; + newApplication.applicationEditStatusUpdatedBy = auditUser; newApplication.creator = auditUser; // While editing an application, a new application record is created and a new @@ -1122,6 +1122,7 @@ export class ApplicationService extends RecordDataModelService { "studentAppeal.id", "versions.id", "versions.applicationEditStatus", + "creator.id", ]) .innerJoin("application.programYear", "programYear") .leftJoin("application.location", "location") @@ -1143,6 +1144,7 @@ export class ApplicationService extends RecordDataModelService { .leftJoin("currentAssessment.studentAppeal", "studentAppeal") .leftJoin("application.studentFiles", "studentFiles") .leftJoin("studentFiles.studentFile", "studentFile") + .leftJoin("application.creator", "creator") .where("application.student.id = :studentId", { studentId }) .andWhere("programYear.active = true"); if (status) { From 7674537802ef6a18adb1043f07ad4ab158598efd Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Thu, 5 Feb 2026 14:24:29 -0800 Subject: [PATCH 05/13] Update application.service.ts --- .../apps/api/src/services/application/application.service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/sources/packages/backend/apps/api/src/services/application/application.service.ts b/sources/packages/backend/apps/api/src/services/application/application.service.ts index d21c45b498..de5590045d 100644 --- a/sources/packages/backend/apps/api/src/services/application/application.service.ts +++ b/sources/packages/backend/apps/api/src/services/application/application.service.ts @@ -1122,7 +1122,6 @@ export class ApplicationService extends RecordDataModelService { "studentAppeal.id", "versions.id", "versions.applicationEditStatus", - "creator.id", ]) .innerJoin("application.programYear", "programYear") .leftJoin("application.location", "location") @@ -1144,7 +1143,6 @@ export class ApplicationService extends RecordDataModelService { .leftJoin("currentAssessment.studentAppeal", "studentAppeal") .leftJoin("application.studentFiles", "studentFiles") .leftJoin("studentFiles.studentFile", "studentFile") - .leftJoin("application.creator", "creator") .where("application.student.id = :studentId", { studentId }) .andWhere("programYear.active = true"); if (status) { From b135196382c8df3ec718c51a05b96c22604de52e Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Thu, 5 Feb 2026 15:18:26 -0800 Subject: [PATCH 06/13] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../sql/Applications/Rollback-set-creator-from-student-id.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql index aba8b26b2d..a24222fadc 100644 --- a/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql +++ b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql @@ -6,4 +6,4 @@ ALTER TABLE sims.applications ALTER COLUMN - creator_id DROP NOT NULL; \ No newline at end of file + creator DROP NOT NULL; \ No newline at end of file From 895ea731dc71445c7e319d616047201473788723 Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Thu, 5 Feb 2026 15:18:36 -0800 Subject: [PATCH 07/13] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../sql/Applications/Rollback-set-creator-from-student-id.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql index a24222fadc..26454ae0f2 100644 --- a/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql +++ b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Rollback-set-creator-from-student-id.sql @@ -1,5 +1,5 @@ /* - Since there is no way to know the records that were affect by the migration we are leaving the creator field as is and only rolling back + Since there is no way to know the records that were affected by the migration we are leaving the creator field as is and only rolling back the alter column to allow nulls. */ -- Rollback the creator field to allow NULLs again. From 6795e4d72f15f5c537e72f74a31f584457ab2317 Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Thu, 5 Feb 2026 16:09:04 -0800 Subject: [PATCH 08/13] enable e2e tests in the test explorer --- sources/packages/backend/jest-unit-tests.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/packages/backend/jest-unit-tests.json b/sources/packages/backend/jest-unit-tests.json index fc9891c928..5dca708181 100644 --- a/sources/packages/backend/jest-unit-tests.json +++ b/sources/packages/backend/jest-unit-tests.json @@ -5,7 +5,10 @@ "ts" ], "rootDir": ".", - "testRegex": ".*\\.spec\\.ts$", + "testRegex": ".*\\.(?:e2e-)?spec\\.ts$", + "setupFiles": [ + "/env-setup.js" + ], "transform": { "^.+\\.(t|j)s$": "ts-jest" }, From d5c5fa89da1a186abe7ce46f7bbe917596a446ed Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Fri, 6 Feb 2026 09:51:55 -0800 Subject: [PATCH 09/13] Fix jest test explorer --- sims.code-workspace | 85 ++++++++++--------- sources/packages/backend/jest-e2e-tests.json | 52 ++++++++++++ sources/packages/backend/jest-unit-tests.json | 5 +- sources/packages/backend/package.json | 3 +- 4 files changed, 102 insertions(+), 43 deletions(-) create mode 100644 sources/packages/backend/jest-e2e-tests.json diff --git a/sims.code-workspace b/sims.code-workspace index 33cf529057..65539608df 100644 --- a/sims.code-workspace +++ b/sims.code-workspace @@ -2,32 +2,32 @@ "folders": [ { "name": "Web UI", - "path": "./sources/packages/web" + "path": "./sources/packages/web", }, { "name": "Backend", - "path": "./sources/packages/backend" + "path": "./sources/packages/backend", }, { "name": "Forms", - "path": "./sources/packages/forms" + "path": "./sources/packages/forms", }, { "name": "DevOps", - "path": "./devops" + "path": "./devops", }, { "name": "Load Tests", - "path": "./sources/packages/load-test" + "path": "./sources/packages/load-test", }, { "name": "Sources", - "path": "./sources" + "path": "./sources", }, { "name": "All", - "path": "." - } + "path": ".", + }, ], "extensions": { "recommendations": [ @@ -40,8 +40,8 @@ "adpyke.vscode-sql-formatter", "redhat.vscode-yaml", "mongodb.mongodb-vscode", - "sonarsource.sonarlint-vscode" - ] + "sonarsource.sonarlint-vscode", + ], }, "tasks": { "version": "2.0.0", @@ -51,83 +51,83 @@ "type": "shell", "command": "make deploy-camunda-definitions", "options": { - "cwd": "${workspaceFolder:Sources}" + "cwd": "${workspaceFolder:Sources}", }, - "problemMatcher": [] + "problemMatcher": [], }, { "label": "Deploy Form Definitions", "type": "shell", "command": "make deploy-form-definitions", "options": { - "cwd": "${workspaceFolder:Sources}" + "cwd": "${workspaceFolder:Sources}", }, - "problemMatcher": [] + "problemMatcher": [], }, { "label": "Database - Run Migrations", "type": "shell", "command": "npm run migration:run", "options": { - "cwd": "${workspaceFolder:Backend}" + "cwd": "${workspaceFolder:Backend}", }, - "problemMatcher": [] + "problemMatcher": [], }, { "label": "Database - Clean E2E Test DB", "type": "shell", "command": "npm run db:seed:test:clean", "options": { - "cwd": "${workspaceFolder:Backend}" + "cwd": "${workspaceFolder:Backend}", }, - "problemMatcher": [] + "problemMatcher": [], }, { "label": "Database - Reset for API E2E Tests", "type": "shell", "command": "npm run db:seed:test:clean && npm run test:e2e:api:seed", "options": { - "cwd": "${workspaceFolder:Backend}" + "cwd": "${workspaceFolder:Backend}", }, - "problemMatcher": [] + "problemMatcher": [], }, { "label": "Database - Reset for Queue-consumers E2E Tests", "type": "shell", "command": "npm run db:seed:test:clean && npm run test:e2e:queue-consumers:seed", "options": { - "cwd": "${workspaceFolder:Backend}" + "cwd": "${workspaceFolder:Backend}", }, - "problemMatcher": [] + "problemMatcher": [], }, { "label": "View Outdated Web Packages", "type": "shell", "command": "npm outdated", "options": { - "cwd": "${workspaceFolder:Web UI}" + "cwd": "${workspaceFolder:Web UI}", }, - "problemMatcher": [] + "problemMatcher": [], }, { "label": "View Outdated Backend Packages", "type": "shell", "command": "npm outdated", "options": { - "cwd": "${workspaceFolder:Backend}" + "cwd": "${workspaceFolder:Backend}", }, - "problemMatcher": [] + "problemMatcher": [], }, { "label": "View Outdated Forms Packages", "type": "shell", "command": "npm outdated", "options": { - "cwd": "${workspaceFolder:Forms}" + "cwd": "${workspaceFolder:Forms}", }, - "problemMatcher": [] - } - ] + "problemMatcher": [], + }, + ], }, "settings": { "eslint.workingDirectories": [{ "mode": "auto" }], @@ -135,7 +135,7 @@ "**/bin": true, "**/obj": true, "**/dist": true, - "**/node_modules": true + "**/node_modules": true, }, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, @@ -145,8 +145,8 @@ "editor.codeActionsOnSave": { "source.addMissingImports": "explicit", "source.fixAll.eslint": "explicit", - "source.removeUnusedImports": "always" - } + "source.removeUnusedImports": "always", + }, }, "typescript.preferences.importModuleSpecifier": "non-relative", "cSpell.words": [ @@ -238,14 +238,23 @@ "unparse", "VALD", "WTHD", - "Zeebe" + "Zeebe", ], "[json]": { - "editor.defaultFormatter": "vscode.json-language-features" + "editor.defaultFormatter": "vscode.json-language-features", }, "[sql]": { - "editor.defaultFormatter": "adpyke.vscode-sql-formatter" + "editor.defaultFormatter": "adpyke.vscode-sql-formatter", }, - "sql-formatter.uppercase": true - } + "sql-formatter.uppercase": true, + "jest.disabledWorkspaceFolders": [ + "Web UI", + "Forms", + "DevOps", + "Load Tests", + "Sources", + "All", + ], + "jest.jestCommandLine": "npm run test:e2e:watch --", + }, } diff --git a/sources/packages/backend/jest-e2e-tests.json b/sources/packages/backend/jest-e2e-tests.json new file mode 100644 index 0000000000..5dca708181 --- /dev/null +++ b/sources/packages/backend/jest-e2e-tests.json @@ -0,0 +1,52 @@ +{ + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], + "rootDir": ".", + "testRegex": ".*\\.(?:e2e-)?spec\\.ts$", + "setupFiles": [ + "/env-setup.js" + ], + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "**/*.(t|j)s" + ], + "coveragePathIgnorePatterns": [ + "node_modules", + "db-migrations", + "backend/workflow", + "_tests_", + "main.ts", + ".module.ts", + "coverage", + "test-utils", + "testHelpers", + ".e2e-spec.ts", + ".models.ts", + ".model.ts", + ".dto.ts", + ".controller.ts", + ".mock.ts" + ], + "coverageDirectory": "../../tests/coverage/unit-tests", + "testEnvironment": "node", + "roots": [ + "/libs/", + "/apps/" + ], + "moduleNameMapper": { + "^@sims/sims-db(|/.*)$": "/libs/sims-db/src/$1", + "^@sims/services(|/.*)$": "/libs/services/src/$1", + "^@sims/utilities(|/.*)$": "/libs/utilities/src/$1", + "^@sims/test-utils(|/.*)$": "/libs/test-utils/src/$1", + "^@sims/integrations(|/.*)$": "/libs/integrations/src/$1", + "^@sims/auth(|/.*)$": "/libs/auth/src/$1" + }, + "transformIgnorePatterns": [ + "/node_modules/(?!@faker-js|uuid)" + ] +} \ No newline at end of file diff --git a/sources/packages/backend/jest-unit-tests.json b/sources/packages/backend/jest-unit-tests.json index 5dca708181..fc9891c928 100644 --- a/sources/packages/backend/jest-unit-tests.json +++ b/sources/packages/backend/jest-unit-tests.json @@ -5,10 +5,7 @@ "ts" ], "rootDir": ".", - "testRegex": ".*\\.(?:e2e-)?spec\\.ts$", - "setupFiles": [ - "/env-setup.js" - ], + "testRegex": ".*\\.spec\\.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" }, diff --git a/sources/packages/backend/package.json b/sources/packages/backend/package.json index 5f4d83fad5..255759275e 100644 --- a/sources/packages/backend/package.json +++ b/sources/packages/backend/package.json @@ -34,6 +34,7 @@ "test:e2e:queue-consumers:seed": "npm run db:seed:test filter=CreateCASDistributionAccounts", "test:e2e:queue-consumers": "npm run test:e2e:queue-consumers:seed && cross-env ENVIRONMENT=test jest --collect-coverage --verbose --config ./apps/queue-consumers/test/jest-e2e.json --runInBand --forceExit", "test:e2e:queue-consumers:local": "cross-env ENVIRONMENT=test TZ=UTC jest --verbose --config ./apps/queue-consumers/test/jest-e2e.json --runInBand --forceExit", + "test:e2e:watch": "jest --watch --config ./jest-e2e-tests.json", "migration": "ts-node -r tsconfig-paths/register --transpile-only apps/db-migrations/src/main.ts", "migration:run": "npm run migration run", "migration:list": "npm run migration list", @@ -137,4 +138,4 @@ "typescript-eslint": "^8.50.0", "webpack": "^5.104.1" } -} +} \ No newline at end of file From fd68e13a47bc4e4bdda396022f009ef880917bb6 Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Fri, 6 Feb 2026 09:56:47 -0800 Subject: [PATCH 10/13] Use already created e2e test config file --- sims.code-workspace | 2 +- sources/packages/backend/jest-e2e-tests.json | 52 -------------------- 2 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 sources/packages/backend/jest-e2e-tests.json diff --git a/sims.code-workspace b/sims.code-workspace index 65539608df..a81dc510bc 100644 --- a/sims.code-workspace +++ b/sims.code-workspace @@ -255,6 +255,6 @@ "Sources", "All", ], - "jest.jestCommandLine": "npm run test:e2e:watch --", + "jest.jestCommandLine": "npm run test:e2e:api:local --", }, } diff --git a/sources/packages/backend/jest-e2e-tests.json b/sources/packages/backend/jest-e2e-tests.json deleted file mode 100644 index 5dca708181..0000000000 --- a/sources/packages/backend/jest-e2e-tests.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": ".", - "testRegex": ".*\\.(?:e2e-)?spec\\.ts$", - "setupFiles": [ - "/env-setup.js" - ], - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coveragePathIgnorePatterns": [ - "node_modules", - "db-migrations", - "backend/workflow", - "_tests_", - "main.ts", - ".module.ts", - "coverage", - "test-utils", - "testHelpers", - ".e2e-spec.ts", - ".models.ts", - ".model.ts", - ".dto.ts", - ".controller.ts", - ".mock.ts" - ], - "coverageDirectory": "../../tests/coverage/unit-tests", - "testEnvironment": "node", - "roots": [ - "/libs/", - "/apps/" - ], - "moduleNameMapper": { - "^@sims/sims-db(|/.*)$": "/libs/sims-db/src/$1", - "^@sims/services(|/.*)$": "/libs/services/src/$1", - "^@sims/utilities(|/.*)$": "/libs/utilities/src/$1", - "^@sims/test-utils(|/.*)$": "/libs/test-utils/src/$1", - "^@sims/integrations(|/.*)$": "/libs/integrations/src/$1", - "^@sims/auth(|/.*)$": "/libs/auth/src/$1" - }, - "transformIgnorePatterns": [ - "/node_modules/(?!@faker-js|uuid)" - ] -} \ No newline at end of file From 3f6f52f93b48fb5d274aad9911e614621161da9c Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Fri, 6 Feb 2026 09:57:35 -0800 Subject: [PATCH 11/13] Update launch.json --- .vscode/launch.json | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 9f6cc7807a..41d5f885e6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -291,30 +291,6 @@ "ENVIRONMENT": "test", "TZ": "UTC" } - }, - { - "type": "node", - "request": "launch", - "name": "API (npm) - Selected test name", - "cwd": "${workspaceFolder}/sources/packages/backend", - "runtimeExecutable": "npm", - "runtimeArgs": [ - "run", - "test:e2e:api:local", - "--", - "--runInBand", - "--runTestsByPath", - "${file}", - "--testNamePattern", - "${selectedText}" - ], - "console": "integratedTerminal", - "internalConsoleOptions": "neverOpen", - "disableOptimisticBPs": true, - "env": { - "ENVIRONMENT": "test", - "TZ": "UTC" - } } ] } From a2e4895b34b8524f2a27f46cee7780892e964734 Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Fri, 6 Feb 2026 10:35:08 -0800 Subject: [PATCH 12/13] Update sims.code-workspace --- sims.code-workspace | 1 + 1 file changed, 1 insertion(+) diff --git a/sims.code-workspace b/sims.code-workspace index a81dc510bc..fcfd28b4a2 100644 --- a/sims.code-workspace +++ b/sims.code-workspace @@ -41,6 +41,7 @@ "redhat.vscode-yaml", "mongodb.mongodb-vscode", "sonarsource.sonarlint-vscode", + "orta.vscode-jest", ], }, "tasks": { From b7c3709f60503c1fa05a7b34eb7725744e6d1330 Mon Sep 17 00:00:00 2001 From: Tiago Graf Date: Fri, 6 Feb 2026 11:02:19 -0800 Subject: [PATCH 13/13] Update application.ts --- .../backend/libs/test-utils/src/factories/application.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sources/packages/backend/libs/test-utils/src/factories/application.ts b/sources/packages/backend/libs/test-utils/src/factories/application.ts index 3bb4b9dec5..741cd590d9 100644 --- a/sources/packages/backend/libs/test-utils/src/factories/application.ts +++ b/sources/packages/backend/libs/test-utils/src/factories/application.ts @@ -93,7 +93,9 @@ export function createFakeApplication( application.applicationEditStatusUpdatedBy = relations?.applicationEditStatusUpdatedBy; application.creator = - options?.initialValue?.creator ?? relations?.auditUser ?? createFakeUser(); + options?.initialValue?.creator ?? + relations?.auditUser ?? + application.student.user; return application; }