-
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
#4079 - Queue Monitoring - Schedulers Refactor (Part 6) #4177
Changes from 4 commits
588818a
e324481
285ebed
35566c3
f4a6350
070e1db
2d333e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,8 @@ import { | |
ApplicationChangesReportHeaders, | ||
APPLICATION_CHANGES_DATE_TIME_FORMAT, | ||
} from "@sims/integrations/esdc-integration"; | ||
import MockDate from "mockdate"; | ||
import * as dayjs from "dayjs"; | ||
|
||
describe( | ||
describeProcessorRootTest(QueueNames.ApplicationChangesReportIntegration), | ||
|
@@ -49,6 +51,7 @@ describe( | |
let sftpClientMock: DeepMocked<Client>; | ||
let auditUser: User; | ||
let sharedStudent: Student; | ||
let expectedFileName: string; | ||
|
||
beforeAll(async () => { | ||
const { nestApplication, dataSource, sshClientMock } = | ||
|
@@ -70,6 +73,10 @@ describe( | |
}, | ||
{ previousDateChangedReportedAssessment: { id: null } }, | ||
); | ||
// Mock the current date. | ||
const now = new Date(); | ||
MockDate.set(now); | ||
expectedFileName = `DPBC.EDU.APPCHANGES.${formatFileNameDate(now)}.csv`; | ||
}); | ||
|
||
it("Should generate application changes report and update the reported date when there is one or more application changes which are not reported.", async () => { | ||
|
@@ -89,16 +96,14 @@ describe( | |
const mockedJob = mockBullJob<void>(); | ||
|
||
// Act | ||
const processingResult = await processor.processApplicationChanges( | ||
mockedJob.job, | ||
); | ||
const result = await processor.processQueue(mockedJob.job); | ||
|
||
// Assert | ||
// Assert process result. | ||
expect(processingResult).toContain("Process finalized with success."); | ||
expect(processingResult).toContain("Applications reported: 2"); | ||
expect( | ||
mockedJob.containLogMessages(["Found 2 application changes."]), | ||
).toBe(true); | ||
expect(result).toStrictEqual([ | ||
"Applications reported: 2", | ||
`Uploaded file name: ${expectedFileName}`, | ||
]); | ||
const uploadedFile = getUploadedFile(sftpClientMock); | ||
const expectedFirstRecord = getExpectedApplicationChangesCSVRecord( | ||
firstApplication, | ||
|
@@ -176,16 +181,13 @@ describe( | |
const mockedJob = mockBullJob<void>(); | ||
|
||
// Act | ||
const processingResult = await processor.processApplicationChanges( | ||
mockedJob.job, | ||
); | ||
const result = await processor.processQueue(mockedJob.job); | ||
// Assert | ||
// Assert process result. | ||
expect(processingResult).toContain("Process finalized with success."); | ||
expect(processingResult).toContain("Applications reported: 1"); | ||
expect( | ||
mockedJob.containLogMessages(["Found 1 application changes."]), | ||
).toBe(true); | ||
expect(result).toStrictEqual([ | ||
"Applications reported: 1", | ||
`Uploaded file name: ${expectedFileName}`, | ||
]); | ||
const uploadedFile = getUploadedFile(sftpClientMock); | ||
const expectedFirstRecord = getExpectedApplicationChangesCSVRecord( | ||
application, | ||
|
@@ -226,16 +228,19 @@ describe( | |
const mockedJob = mockBullJob<void>(); | ||
|
||
// Act | ||
const processingResult = await processor.processApplicationChanges( | ||
mockedJob.job, | ||
); | ||
const result = await processor.processQueue(mockedJob.job); | ||
|
||
// Assert | ||
// Assert process result. | ||
expect(processingResult).toContain("Process finalized with success."); | ||
expect(processingResult).toContain("Applications reported: 0"); | ||
expect(result).toStrictEqual([ | ||
"Applications reported: 0", | ||
`Uploaded file name: ${expectedFileName}`, | ||
]); | ||
expect( | ||
mockedJob.containLogMessages([ | ||
"Retrieving all application changes which were not reported already.", | ||
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. Very minor: maybe it could be rephrased to: "Retrieving all application changes that have not yet been reported." 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. Updated as suggested. |
||
"Found 0 application changes.", | ||
`Application changes report with file name ${expectedFileName} has been uploaded successfully.`, | ||
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. 👍 |
||
"Report date update not required as no application changes are reported.", | ||
]), | ||
).toBe(true); | ||
|
@@ -397,5 +402,14 @@ describe( | |
newOffering.studyEndDate, | ||
].join(","); | ||
} | ||
|
||
/** | ||
* Format date to be used in file name. | ||
* @param date date. | ||
* @returns file name date format. | ||
*/ | ||
function formatFileNameDate(date: Date): string { | ||
return dayjs(date).format("YYYY-MM-DD_HH.mm.ss"); | ||
} | ||
}, | ||
); |
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.
👍