-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
797 backend delete all code relating to event sign ups (#800)
* Remove all code related to event signups * Deleted event signup endpoint * Deleted SSE endpoint * Removed relevant endpoint tests * Remove EventReservation service methods and tests * Remove event reservations from firebase and subcollection * Note that `Event.max_occupancy` is kept as this could still be useful. * Also note that `FirestoreSubcollections.ts` was kept as this could be used in the future. * Also removed the event request for signup * Remove extra comments and generate swagger
- Loading branch information
1 parent
ea46d39
commit e275f84
Showing
11 changed files
with
6 additions
and
753 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,11 +1,6 @@ | ||
// credit https://plainenglish.io/blog/using-firestore-with-typescript-in-the-v9-sdk-cf36851bb099 | ||
import "dotenv/config" | ||
import firestore from "./Firestore" | ||
import { EventReservation } from "data-layer/models/firebase" | ||
|
||
const FirestoreSubcollections = { | ||
reservations: (eventId: string) => | ||
firestore.subcollection<EventReservation>("events", eventId, "reservations") | ||
} as const | ||
const FirestoreSubcollections = {} as const | ||
|
||
export default FirestoreSubcollections |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ import { | |
dateToFirestoreTimeStamp, | ||
removeUnderscoresFromTimestamp | ||
} from "data-layer/adapters/DateUtils" | ||
import { Event, EventReservation } from "data-layer/models/firebase" | ||
import { Event } from "data-layer/models/firebase" | ||
import FirestoreCollections from "data-layer/adapters/FirestoreCollections" | ||
import { Timestamp } from "firebase-admin/firestore" | ||
|
||
|
@@ -46,21 +46,6 @@ const futureEvent: Event = { | |
sign_up_end_date: Timestamp.fromDate(new Date(now.getUTCFullYear() + 1, 1, 1)) | ||
} | ||
|
||
const reservation1: EventReservation = { | ||
first_name: "John", | ||
last_name: "Appleseed", | ||
email: "[email protected]", | ||
is_member: true, | ||
timestamp: Timestamp.fromDate(startDate) | ||
} | ||
const reservation2: EventReservation = { | ||
first_name: "Jane", | ||
last_name: "Pearseed", | ||
email: "[email protected]", | ||
is_member: false, | ||
timestamp: Timestamp.fromDate(startDate) | ||
} | ||
|
||
describe("EventService integration tests", () => { | ||
afterEach(async () => { | ||
await cleanFirestore() | ||
|
@@ -160,151 +145,4 @@ describe("EventService integration tests", () => { | |
|
||
expect(fetchedEvent).toBe(undefined) | ||
}) | ||
|
||
it("Should delete an event and also all reservations", async () => { | ||
const newEvent = await eventService.createEvent(event1) | ||
const newReservation1 = await eventService.addReservation( | ||
newEvent.id, | ||
reservation1 | ||
) | ||
const newReservation2 = await eventService.addReservation( | ||
newEvent.id, | ||
reservation2 | ||
) | ||
|
||
await eventService.deleteEvent(newEvent.id) | ||
|
||
const fetchedReservation1 = await eventService.getReservationById( | ||
newEvent.id, | ||
newReservation1.id | ||
) | ||
expect(fetchedReservation1).toBe(undefined) | ||
const fetchedReservation2 = await eventService.getReservationById( | ||
newEvent.id, | ||
newReservation2.id | ||
) | ||
expect(fetchedReservation2).toBe(undefined) | ||
}) | ||
|
||
it("Should not delete other reservations when deleting an event document", async () => { | ||
const newEvent = await eventService.createEvent(event1) | ||
await eventService.addReservation(newEvent.id, reservation1) | ||
await eventService.addReservation(newEvent.id, reservation2) | ||
const newEvent2 = await eventService.createEvent(event2) | ||
const newReservation3 = await eventService.addReservation( | ||
newEvent2.id, | ||
reservation1 | ||
) | ||
const newReservation4 = await eventService.addReservation( | ||
newEvent2.id, | ||
reservation2 | ||
) | ||
|
||
await eventService.deleteEvent(newEvent.id) | ||
const fetchedReservation3 = await eventService.getReservationById( | ||
newEvent2.id, | ||
newReservation3.id | ||
) | ||
expect(fetchedReservation3).toEqual(reservation1) | ||
const fetchedReservation4 = await eventService.getReservationById( | ||
newEvent2.id, | ||
newReservation4.id | ||
) | ||
expect(fetchedReservation4).toEqual(reservation2) | ||
}) | ||
|
||
/** | ||
* Event reservation nested collection methods | ||
*/ | ||
describe("EventReservation integration tests", () => { | ||
it("Should be able to add a event reservation", async () => { | ||
const newEvent = await eventService.createEvent(event1) | ||
|
||
const reservation = await eventService.addReservation( | ||
newEvent.id, | ||
reservation1 | ||
) | ||
const fetchedReservation = await FirestoreCollections.events | ||
.doc(newEvent.id) | ||
.collection("reservations") // subject to place as a constant somewhere | ||
.doc(reservation.id) | ||
.get() | ||
expect(fetchedReservation.data()).toEqual(reservation1) | ||
}) | ||
|
||
it("Should be able to get an event reservation", async () => { | ||
const newEvent = await eventService.createEvent(event1) | ||
const reservation = await eventService.addReservation( | ||
newEvent.id, | ||
reservation1 | ||
) | ||
const fetchedReservation = await eventService.getReservationById( | ||
newEvent.id, | ||
reservation.id | ||
) | ||
expect(fetchedReservation).toEqual(reservation1) | ||
}) | ||
|
||
it("Should get the total count of active event reservations", async () => { | ||
// An older event shouldn't be counted. | ||
const oldEvent = await eventService.createEvent(event1) | ||
await eventService.addReservation(oldEvent.id, reservation1) | ||
// Should only count reservations for future events | ||
const newEvent = await eventService.createEvent(futureEvent) | ||
await eventService.addReservation(newEvent.id, reservation1) | ||
await eventService.addReservation(newEvent.id, reservation2) | ||
|
||
const eventCounts = await eventService.getActiveReservationsCount() | ||
expect(eventCounts).toStrictEqual({ [newEvent.id]: 2 }) | ||
}) | ||
|
||
it("Should get all event reservations", async () => { | ||
const newEvent = await eventService.createEvent(event1) | ||
await eventService.addReservation(newEvent.id, reservation1) | ||
await eventService.addReservation(newEvent.id, reservation2) | ||
const reservations = await eventService.getAllReservations(newEvent.id) | ||
expect(reservations.length).toBe(2) | ||
expect(reservations).toContainEqual(reservation1) | ||
expect(reservations).toContainEqual(reservation2) | ||
}) | ||
|
||
it("Should be able to update an event reservation", async () => { | ||
const newEvent = await eventService.createEvent(event1) | ||
|
||
const reservation = await eventService.addReservation( | ||
newEvent.id, | ||
reservation1 | ||
) | ||
|
||
await eventService.updateReservation(newEvent.id, reservation.id, { | ||
first_name: "Jan" | ||
}) | ||
|
||
const fetchedReservation = await FirestoreCollections.events | ||
.doc(newEvent.id) | ||
.collection("reservations") // subject to place as a constant somewhere | ||
.doc(reservation.id) | ||
.get() | ||
|
||
expect(fetchedReservation.data().first_name).toBe("Jan") | ||
}) | ||
|
||
it("Should be able to delete an event reservation", async () => { | ||
const newEvent = await eventService.createEvent(event1) | ||
|
||
const reservation = await eventService.addReservation( | ||
newEvent.id, | ||
reservation1 | ||
) | ||
|
||
await eventService.deleteReservation(newEvent.id, reservation.id) | ||
|
||
const fetchedReservation = await FirestoreCollections.events | ||
.doc(newEvent.id) | ||
.collection("reservations") // subject to place as a constant somewhere | ||
.doc(reservation.id) | ||
.get() | ||
expect(fetchedReservation.data()).toBe(undefined) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.