-
Notifications
You must be signed in to change notification settings - Fork 5
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
Write events test suite #181
Closed
Closed
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
c12ac20
Add skeleton event tests
shravanhariharan2 ef89fa3
Add missing await to EventService::createEvent
shravanhariharan2 bc43ff9
Add rest of CRUD operation tests
shravanhariharan2 ce6dcb8
Add storage utils for mocking images to upload
shravanhariharan2 290c828
Add event feedback fakes
shravanhariharan2 159d169
Add empty file check for storage test utils
shravanhariharan2 bbaedc2
Refactor EventFactory to fake past, ongoing, and future events easily
shravanhariharan2 6a9b5ae
Remove unused validator in feedback
shravanhariharan2 74db6ba
Finish writing preliminary event tests
shravanhariharan2 d2fd439
Merge branch 'master' into tests/events
shravanhariharan2 8d7623d
Update tests/event.test.ts
shravanhariharan2 a264273
Refactor EventFactory fake methods
shravanhariharan2 caa4f92
Inline all error messages that are only used once
shravanhariharan2 a33bcd0
Fix small event test nits
shravanhariharan2 fcc0e4a
Merge branch 'master' into tests/events
shravanhariharan2 e56e157
Change controller params in test to match updated validation format
shravanhariharan2 cc6f83b
Move asserts next to data fetches
shravanhariharan2 8ef3ea1
Refactor EventFactory random time generation
shravanhariharan2 5b3fa0c
Merge branch 'master' into tests/events
shravanhariharan2 6e55d48
Switch to non-deprecated hexadecimal generation
shravanhariharan2 2f8c3b4
mocking with jest sucks
shravanhariharan2 2529a86
Add 'update event' tests
shravanhariharan2 28a55ca
Make event patches fields explicitly optional in validation (they wer…
shravanhariharan2 ede38bf
Allow mocked services to be injected into controllers
shravanhariharan2 539d35e
Remove redundant type
shravanhariharan2 18a952c
Switch mocking aws-sdk to StorageService using ts-mockito
shravanhariharan2 342dcb5
Merge branch 'master' into tests/events
shravanhariharan2 a70a68e
Move ts-mockito from dep to devDep
shravanhariharan2 cc1694b
Remove singleton behavior from ControllerFactory
shravanhariharan2 9b51a89
Move controllers/index.ts -> ControllerFactory.ts
shravanhariharan2 3ecb774
Move createEventFeedback from FeedbackFactory to EventFactory
shravanhariharan2 2c5ca2a
Move fakeOngoingEvent start duration forward 30 minutes
shravanhariharan2 a88706e
Tighten error handling to match constraint in test
shravanhariharan2 98023da
Lint
shravanhariharan2 298f5f3
Add get call to event cover test to ensure cover is persisted
shravanhariharan2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -101,6 +101,46 @@ describe('event CRUD operations', () => { | |
expect(eventsResponse.events).toHaveLength(1); | ||
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. Assert that the response is only the first event. |
||
expect(eventsResponse.events[0]).toStrictEqual(event1.getPublicEvent(true)); | ||
}); | ||
|
||
test('events can be updated by an admin', async () => { | ||
const conn = await DatabaseConnection.get(); | ||
const [event] = EventFactory.with({ attendanceCode: 'code' }); | ||
const [admin] = UserFactory.with({ accessType: UserAccessType.ADMIN }); | ||
|
||
await new PortalState() | ||
.createEvents([event]) | ||
.createUsers([admin]) | ||
.write(); | ||
|
||
const eventChanges = { | ||
title: 'new title', | ||
description: 'new description', | ||
}; | ||
|
||
const updateEventResponse = await ControllerFactory | ||
.event(conn) | ||
.updateEvent({ uuid: event.uuid }, { event: eventChanges }, admin); | ||
|
||
expect(updateEventResponse.event).toMatchObject({ ...event.getPublicEvent(), ...eventChanges }); | ||
}); | ||
|
||
test('event attendance code cannot be updated to a duplicate one', async () => { | ||
const conn = await DatabaseConnection.get(); | ||
const [event1] = EventFactory.with({ attendanceCode: 'code' }); | ||
const [event2] = EventFactory.with({ attendanceCode: 'another-code' }); | ||
const [admin] = UserFactory.with({ accessType: UserAccessType.ADMIN }); | ||
|
||
await new PortalState() | ||
.createEvents([event1, event2]) | ||
.createUsers([admin]) | ||
.write(); | ||
|
||
event1.attendanceCode = event2.attendanceCode; | ||
|
||
await expect( | ||
ControllerFactory.event(conn).updateEvent({ uuid: event1.uuid }, { event: event1 }, admin), | ||
).rejects.toThrow('Attendance code has already been used'); | ||
}); | ||
}); | ||
|
||
describe('event covers', () => { | ||
|
@@ -125,7 +165,7 @@ describe('event covers', () => { | |
}); | ||
|
||
test('rejects upload if file size too large', async () => { | ||
// TODO: implement once API wrappers exist (since multer validation can't be mocked with function calls) | ||
// TODO: implement once API wrappers exist (since multer validation can't be verified with function calls) | ||
}); | ||
}); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.