Skip to content

Commit

Permalink
test: fix flakiness (again) by hardcoding created dates (#1604)
Browse files Browse the repository at this point in the history
* test: fix flakiness (again) by hardcoding created dates

instead of using relative dates, which may behave differently in
different machines (like CI/CD)

* test: assign date strings to constants for clarity
  • Loading branch information
karrui authored Apr 9, 2021
1 parent 437e16e commit 7a60f4b
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4719,7 +4719,6 @@ describe('admin-form.routes', () => {

it('should return 200 with stream of encrypted responses between given query.startDate and query.endDate', async () => {
// Arrange
const now = new Date()
const submissions = await Promise.all(
times(5, (count) =>
createSubmission({
Expand All @@ -4730,13 +4729,15 @@ describe('admin-form.routes', () => {
['fieldId1', `some.attachment.url.${count}`],
['fieldId2', `some.other.attachment.url.${count}`],
]),
created: now,
}),
),
)
// Set 2 submissions to be submitted 3-4 days ago.
submissions[2].created = subDays(now, 3)
submissions[4].created = subDays(now, 4)

const startDateStr = '2020-02-03'
const endDateStr = '2020-02-04'
// Set 2 submissions to be submitted with specific date
submissions[2].created = new Date(startDateStr)
submissions[4].created = new Date(endDateStr)
await submissions[2].save()
await submissions[4].save()
const expectedSubmissionIds = [
Expand All @@ -4748,8 +4749,8 @@ describe('admin-form.routes', () => {
const response = await request
.get(`/${defaultForm._id}/adminform/submissions/download`)
.query({
startDate: format(subDays(now, 4), 'yyyy-MM-dd'),
endDate: format(subDays(now, 3), 'yyyy-MM-dd'),
startDate: startDateStr,
endDate: endDateStr,
})
.buffer()
.parse((res, cb) => {
Expand Down

0 comments on commit 7a60f4b

Please sign in to comment.