-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2322 - IER12 E2E Tests - Validate Multiple Files #2478
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { formatDate } from "@sims/utilities"; | ||
import { QueueProcessSummaryResult } from "../../../../../../../processors/models/processors.models"; | ||
|
||
/** | ||
|
@@ -14,6 +15,15 @@ export function numberToText( | |
return value.toString().padStart(options?.length ?? 10, "0"); | ||
} | ||
|
||
/** | ||
* Converts a date to its fixed date-only text format. | ||
* @param date date to be converted. | ||
* @returns converted data as a string formatted as YYYYMMDD. | ||
*/ | ||
export function dateToDateOnlyText(date: Date | string): string { | ||
return formatDate(date, "YYYYMMDD"); | ||
} | ||
|
||
/** | ||
* Get the success string messages when a file is uploaded with success. | ||
* @param timestamp file timestamp. | ||
|
@@ -25,12 +35,13 @@ export function numberToText( | |
export function getSuccessSummaryMessages( | ||
timestamp: string, | ||
options?: { | ||
institutionCode?: string; | ||
expectedRecords?: number; | ||
}, | ||
): QueueProcessSummaryResult { | ||
return { | ||
summary: [ | ||
`The uploaded file: ${process.env.INSTITUTION_REQUEST_FOLDER}\\ZZZY\\IER_012_${timestamp}.txt`, | ||
`The uploaded file: ${process.env.INSTITUTION_REQUEST_FOLDER}\\${options?.institutionCode}\\IER_012_${timestamp}.txt`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
`The number of records: ${options?.expectedRecords ?? 1}`, | ||
], | ||
} as QueueProcessSummaryResult; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,11 @@ export function createFakeEducationProgramOffering(relations?: { | |
institution?: Institution; | ||
institutionLocation?: InstitutionLocation; | ||
}): EducationProgramOffering { | ||
// Case an institution location is provided already associated with | ||
// an institution ensure that the relationship will be kept and | ||
// another institution will not be generated. | ||
const institution = | ||
relations?.institutionLocation?.institution ?? relations.institution; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
const offering = new EducationProgramOffering(); | ||
offering.name = faker.random.word(); | ||
offering.actualTuitionCosts = faker.random.number(1000); | ||
|
@@ -30,7 +35,7 @@ export function createFakeEducationProgramOffering(relations?: { | |
offering.educationProgram = | ||
relations?.program ?? | ||
createFakeEducationProgram({ | ||
institution: relations?.institution, | ||
institution, | ||
auditUser: relations.auditUser, | ||
}); | ||
offering.institutionLocation = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ export function createFakeInstitutionLocation( | |
count: 4, | ||
upcase: true, | ||
}); | ||
institutionLocation.hasIntegration = options?.initialValue?.hasIntegration; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did we miss this in the previous iterations? or why was this added now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was not needed till now. |
||
return institutionLocation; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,28 +41,43 @@ export function createSSHServiceMock( | |
} | ||
|
||
/** | ||
* Get the parameters provided to the put method of the SSH client that represents the | ||
* remote file path and the data that would be uploaded to the SFTP in a real scenario. | ||
* Get the parameters provided to the put method of the SSH client that | ||
* represents the data that would be uploaded to the SFTP in a real scenario. | ||
* @param sshClientMock SSH mocked client. | ||
* @returns file name and file content of the supposed-to-be uploaded file. | ||
*/ | ||
export function getUploadedFile( | ||
sshClientMock: DeepMocked<Client>, | ||
): UploadedFile { | ||
const uploadedFile = {} as UploadedFile; | ||
const [uploadedFile] = getUploadedFiles(sshClientMock); | ||
return uploadedFile; | ||
} | ||
|
||
/** | ||
* Get the parameters provided to the put method of the SSH client that represents the | ||
* remote file(s) path and the data that would be uploaded to the SFTP in a real scenario. | ||
* @param sshClientMock SSH mocked client. | ||
* @returns file(s) name and file(s) content of the supposed-to-be uploaded file(s). | ||
*/ | ||
export function getUploadedFiles( | ||
sshClientMock: DeepMocked<Client>, | ||
): UploadedFile[] { | ||
if (!sshClientMock.put.mock.calls.length) { | ||
throw new Error( | ||
"SSH client mock was not invoked which means that there was no attempt to upload a file.", | ||
); | ||
} | ||
const [[input, remoteFilePath]] = sshClientMock.put.mock.calls; | ||
if (input) { | ||
uploadedFile.fileLines = input.toString().split(END_OF_LINE); | ||
} | ||
if (remoteFilePath) { | ||
uploadedFile.remoteFilePath = remoteFilePath.toString(); | ||
} | ||
return uploadedFile; | ||
return sshClientMock.put.mock.calls.map((call) => { | ||
const uploadedFile = {} as UploadedFile; | ||
const [input, remoteFilePath] = call; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a show stopper, just a suggestion. I believe we can remove this const and pass it in the call itself. return sshClientMock.put.mock.calls.map(([input, remoteFilePath]) => { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can, I did the change and I am still not sure which one is cleaner from a code perspective. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. |
||
if (input) { | ||
uploadedFile.fileLines = input.toString().split(END_OF_LINE); | ||
} | ||
if (remoteFilePath) { | ||
uploadedFile.remoteFilePath = remoteFilePath.toString(); | ||
} | ||
return uploadedFile; | ||
}); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this method used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if I am following the question. This method was added in the previous PR and it is used in 18 places.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it