Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 48 additions & 38 deletions sims.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -40,8 +40,9 @@
"adpyke.vscode-sql-formatter",
"redhat.vscode-yaml",
"mongodb.mongodb-vscode",
"sonarsource.sonarlint-vscode"
]
"sonarsource.sonarlint-vscode",
"orta.vscode-jest",
],
},
"tasks": {
"version": "2.0.0",
Expand All @@ -51,91 +52,91 @@
"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" }],
"search.exclude": {
"**/bin": true,
"**/obj": true,
"**/dist": true,
"**/node_modules": true
"**/node_modules": true,
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
Expand All @@ -145,8 +146,8 @@
"editor.codeActionsOnSave": {
"source.addMissingImports": "explicit",
"source.fixAll.eslint": "explicit",
"source.removeUnusedImports": "always"
}
"source.removeUnusedImports": "always",
},
},
"typescript.preferences.importModuleSpecifier": "non-relative",
"cSpell.words": [
Expand Down Expand Up @@ -238,14 +239,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",
Comment on lines +251 to +256
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tool looks great. Thanks.

Image

"All",
],
"jest.jestCommandLine": "npm run test:e2e:api:local --",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes the text explorer recognize the e2e tests now, the draw back is that the unit tests are not present (we would need a combined config file if that was necessary)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why the whole file formatting changed, i'm assuming no one touched this file in a while

},
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ describe("ApplicationStudentsController(e2e)-applicationChangeRequest", () => {
applicationEditStatus: true,
applicationEditStatusUpdatedOn: true,
applicationEditStatusUpdatedBy: { id: true },
creator: { id: true },
currentAssessment: {
id: true,
studentAssessmentStatus: true,
Expand All @@ -152,6 +153,7 @@ describe("ApplicationStudentsController(e2e)-applicationChangeRequest", () => {
precedingApplication: true,
student: true,
applicationEditStatusUpdatedBy: true,
creator: true,
currentAssessment: {
offering: true,
studentAppeal: true,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export class ApplicationService extends RecordDataModelService<Application> {
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
Expand All @@ -319,8 +320,6 @@ export class ApplicationService extends RecordDataModelService<Application> {
auditUserId,
transactionalEntityManager,
);

newApplication.creator = auditUser;
newApplication.studentAssessments = [originalAssessment];
newApplication.currentAssessment = originalAssessment;

Expand Down Expand Up @@ -492,7 +491,9 @@ export class ApplicationService extends RecordDataModelService<Application> {
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
// 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<void> {
await queryRunner.query(
getSQLFileData("Set-creator-from-student-id.sql", "Applications"),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData(
"Rollback-set-creator-from-student-id.sql",
"Applications",
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
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.
ALTER TABLE
sims.applications
ALTER COLUMN
creator DROP NOT NULL;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { createFakeStudent } from "./student";

export function createFakeApplication(
relations?: {
auditUser?: User;
student?: Student;
programYear?: ProgramYear;
currentStudentAssessment?: StudentAssessment;
Expand Down Expand Up @@ -91,6 +92,10 @@ export function createFakeApplication(
options?.initialValue?.applicationEditStatusUpdatedOn ?? now;
application.applicationEditStatusUpdatedBy =
relations?.applicationEditStatusUpdatedBy;
application.creator =
options?.initialValue?.creator ??
relations?.auditUser ??
application.student.user;
return application;
}

Expand Down Expand Up @@ -331,6 +336,7 @@ export async function saveFakeApplication(
const fakeApplication = createFakeApplication(
{
student: savedStudent,
auditUser: savedUser,
location: relations?.institutionLocation,
programYear: relations?.programYear,
applicationException: relations?.applicationException,
Expand Down
3 changes: 2 additions & 1 deletion sources/packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -137,4 +138,4 @@
"typescript-eslint": "^8.50.0",
"webpack": "^5.104.1"
}
}
}
Loading