-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Application Table/Export/Edit/View should display time in local …
…timezone (#3959) * fix: pass timezone to application csv export 3919 * fix: adjust paper apps to submit in local timezone 3919 * fix: match electronic on table and export 3919 * fix: seed a paper application * fix: pacific time migration 3919 * fix: address comments 3919 * fix: cleanup nits 3919
- Loading branch information
Showing
16 changed files
with
232 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
api/prisma/migrations/09_update_submission_date_on_applications/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- Paper applications were originally submitted as though they were in UTC, | ||
-- when they should have been submitted in Pacific (PST/PDT) and converted to UTC. | ||
-- Here we update the times to be in PST or PDT depending on when they were submitted | ||
-- and the yearly cycle of daylight savings. | ||
|
||
UPDATE applications | ||
SET submission_date = submission_date + '7 hours' | ||
WHERE submission_date IS NOT NULL | ||
AND submission_type = 'paper'; | ||
|
||
|
||
UPDATE applications | ||
SET submission_date = submission_date + '1 hours' | ||
WHERE submission_date IS NOT NULL | ||
AND submission_type = 'paper' | ||
AND (submission_date > '2024-03-10 09:00:00.000-00' | ||
OR (submission_date <= '2023-11-05 09:00:00.000-00' AND submission_date > '2023-03-12 09:00:00.000-00') | ||
OR (submission_date <= '2022-11-06 09:00:00.000-00' AND submission_date > '2022-03-13 09:00:00.000-00') | ||
OR (submission_date <= '2021-11-07 09:00:00.000-00' AND submission_date > '2021-03-14 09:00:00.000-00')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -559,4 +559,133 @@ describe('Testing application CSV export service', () => { | |
expect(readable).toContain(headerRow); | ||
expect(readable).toContain(firstApp); | ||
}); | ||
|
||
it('should build csv with submission date defaulted to PST', async () => { | ||
jest.useFakeTimers(); | ||
jest.setSystemTime(new Date('2024-01-01')); | ||
|
||
const requestingUser = { | ||
firstName: 'requesting fName', | ||
lastName: 'requesting lName', | ||
email: '[email protected]', | ||
jurisdictions: [{ id: 'juris id' }], | ||
} as unknown as User; | ||
|
||
const applications = mockApplicationSet(5, new Date()); | ||
prisma.applications.findMany = jest.fn().mockReturnValue(applications); | ||
prisma.listings.findUnique = jest.fn().mockResolvedValue({}); | ||
permissionService.canOrThrow = jest.fn().mockResolvedValue(true); | ||
|
||
service.maxHouseholdMembers = jest.fn().mockReturnValue(1); | ||
|
||
prisma.multiselectQuestions.findMany = jest.fn().mockReturnValue([ | ||
{ | ||
...mockMultiselectQuestion( | ||
0, | ||
new Date(), | ||
MultiselectQuestionsApplicationSectionEnum.preferences, | ||
), | ||
options: [ | ||
{ id: 1, text: 'text' }, | ||
{ id: 2, text: 'text', collectAddress: true }, | ||
], | ||
}, | ||
{ | ||
...mockMultiselectQuestion( | ||
1, | ||
new Date(), | ||
MultiselectQuestionsApplicationSectionEnum.programs, | ||
), | ||
options: [{ id: 1, text: 'text' }], | ||
}, | ||
]); | ||
|
||
service.unitTypeToReadable = jest.fn().mockReturnValue('Studio'); | ||
const exportResponse = await service.exportFile( | ||
{ user: requestingUser } as unknown as ExpressRequest, | ||
{} as unknown as Response, | ||
{ listingId: randomUUID() }, | ||
); | ||
|
||
const mockedStream = new PassThrough(); | ||
exportResponse.getStream().pipe(mockedStream); | ||
|
||
// In order to make sure the last expect statements are properly hit we need to wrap in a promise and resolve it | ||
const readable = await new Promise((resolve) => { | ||
mockedStream.on('data', async (d) => { | ||
const value = Buffer.from(d).toString(); | ||
mockedStream.end(); | ||
mockedStream.destroy(); | ||
resolve(value); | ||
}); | ||
}); | ||
|
||
expect(readable).toContain('PST'); | ||
}); | ||
|
||
it('should build csv with submission date in custom timezone', async () => { | ||
jest.useFakeTimers(); | ||
jest.setSystemTime(new Date('2024-01-01')); | ||
|
||
const requestingUser = { | ||
firstName: 'requesting fName', | ||
lastName: 'requesting lName', | ||
email: '[email protected]', | ||
jurisdictions: [{ id: 'juris id' }], | ||
} as unknown as User; | ||
|
||
const applications = mockApplicationSet(5, new Date()); | ||
prisma.applications.findMany = jest.fn().mockReturnValue(applications); | ||
prisma.listings.findUnique = jest.fn().mockResolvedValue({}); | ||
permissionService.canOrThrow = jest.fn().mockResolvedValue(true); | ||
|
||
service.maxHouseholdMembers = jest.fn().mockReturnValue(1); | ||
|
||
prisma.multiselectQuestions.findMany = jest.fn().mockReturnValue([ | ||
{ | ||
...mockMultiselectQuestion( | ||
0, | ||
new Date(), | ||
MultiselectQuestionsApplicationSectionEnum.preferences, | ||
), | ||
options: [ | ||
{ id: 1, text: 'text' }, | ||
{ id: 2, text: 'text', collectAddress: true }, | ||
], | ||
}, | ||
{ | ||
...mockMultiselectQuestion( | ||
1, | ||
new Date(), | ||
MultiselectQuestionsApplicationSectionEnum.programs, | ||
), | ||
options: [{ id: 1, text: 'text' }], | ||
}, | ||
]); | ||
|
||
service.unitTypeToReadable = jest.fn().mockReturnValue('Studio'); | ||
const exportResponse = await service.exportFile( | ||
{ user: requestingUser } as unknown as ExpressRequest, | ||
{} as unknown as Response, | ||
{ | ||
listingId: randomUUID(), | ||
timeZone: 'America/New_York', | ||
}, | ||
); | ||
|
||
const mockedStream = new PassThrough(); | ||
exportResponse.getStream().pipe(mockedStream); | ||
|
||
// In order to make sure the last expect statements are properly hit we need to wrap in a promise and resolve it | ||
const readable = await new Promise((resolve) => { | ||
mockedStream.on('data', async (d) => { | ||
const value = Buffer.from(d).toString(); | ||
mockedStream.end(); | ||
mockedStream.destroy(); | ||
resolve(value); | ||
}); | ||
}); | ||
|
||
expect(readable).toContain('EST'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.