-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate to prisma 2, and manual deploy to Heroku (#82)
* expose database port in the docker config * migrate prisma datamodel to prisma schema by introspection and manual schema edit prisma-upgrade does not seem to work correctly for now * upgrade packages, remove prisma1, install prisma client, and generate * store prisma 1 generated graphql as a legacy * fix minor bugs in the prisma schema * migrate core code to test for graphql user query comment out most of the unmigrated code to avoid tsc errors * clean * add missing application level phoenix secret * fix all tests * migrate all application code within SDL * fix github actions dev workflow * unify all prisma client instances to one module * fix jest tests running some async call, being unable to terminate due to multiple prisma instances not disconnecting * reset database to start fresh * enable graphql playground in production * fix postbuild script * fix github actions prod workflow * fix scripts, and separate dockerfiles into prod and dev dev docker image does prisma migrate deploy before starting
- Loading branch information
Showing
53 changed files
with
4,014 additions
and
3,742 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
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 |
---|---|---|
|
@@ -4,19 +4,18 @@ env.config(); | |
import gql from "graphql-tag"; | ||
import moment from "moment"; | ||
import { createTestServerWithUserLoggedIn } from "./utils/server"; | ||
import { Room, User } from "../src/generated/prisma-client"; | ||
import { User } from "@prisma/client"; | ||
import { createTestClient } from "apollo-server-testing"; | ||
import { createUser, deleteUser, deleteUsers } from "./utils/users"; | ||
import { createRoom, deleteRoom } from "./utils/rooms"; | ||
import { createUser, deleteUsers, TestUserInfo } from "./utils/users"; | ||
import { createRoom, deleteRooms, TestRoomInfo } from "./utils/rooms"; | ||
import { | ||
createBooking, | ||
deleteBooking, | ||
deleteBookings, | ||
TestBookingInfo, | ||
} from "./utils/bookings"; | ||
import { GraphQLResponse } from "apollo-server-types"; | ||
|
||
const testUserInfo: User = { | ||
id: undefined, | ||
const testUserInfo: TestUserInfo = { | ||
username: "test123", | ||
email: "[email protected]", | ||
image_url: "http://url", | ||
|
@@ -27,8 +26,7 @@ const testUserInfo: User = { | |
role: "USER", | ||
}; | ||
|
||
const testUserInfo1: User = { | ||
id: undefined, | ||
const testUserInfo1: TestUserInfo = { | ||
username: "test234", | ||
email: "[email protected]", | ||
image_url: "http://url234", | ||
|
@@ -39,8 +37,7 @@ const testUserInfo1: User = { | |
role: "USER", | ||
}; | ||
|
||
const testRoomInfo: Room = { | ||
id: "", | ||
const testRoomInfo: TestRoomInfo = { | ||
number: "123", | ||
name: "test", | ||
}; | ||
|
@@ -72,6 +69,18 @@ const testInvalidBookingVariables = { | |
remark: "Hi", | ||
}; | ||
|
||
beforeAll(async () => { | ||
await deleteBookings(); | ||
await deleteRooms(); | ||
await deleteUsers(); | ||
}); | ||
|
||
afterEach(async () => { | ||
await deleteBookings(); | ||
await deleteRooms(); | ||
await deleteUsers(); | ||
}); | ||
|
||
describe("Booking queries", () => { | ||
test("can query all bookings", async () => { | ||
// Create user in the database | ||
|
@@ -110,17 +119,12 @@ describe("Booking queries", () => { | |
room: { | ||
number: testRoomInfo.number, | ||
}, | ||
start: testBookingInfo.start.toISOString(), | ||
end: testBookingInfo.end.toISOString(), | ||
start: testBookingInfo.start, | ||
end: testBookingInfo.end, | ||
remark: testBookingInfo.remark, | ||
}, | ||
], | ||
}); | ||
|
||
// Cleanup after test | ||
await deleteBooking(booking); | ||
await deleteRoom(room); | ||
await deleteUser(user); | ||
}); | ||
}); | ||
|
||
|
@@ -160,10 +164,6 @@ describe("Booking validation", () => { | |
}); | ||
|
||
expect(response.data).toEqual({ createBooking: null }); | ||
|
||
await deleteBooking(booking); | ||
await deleteRoom(room); | ||
await deleteUser(user); | ||
}); | ||
}); | ||
|
||
|
@@ -198,8 +198,8 @@ describe("Booking mutations", () => { | |
const testUpdatedBookingInfo = { | ||
id: booking.id, | ||
room: testBookingInfo.room, | ||
start: booking.start, | ||
end: booking.end, | ||
start: booking.start.toISOString(), | ||
end: booking.end.toISOString(), | ||
remark: "HelloWorld", | ||
}; | ||
const result: GraphQLResponse = await client.mutate({ | ||
|
@@ -212,10 +212,6 @@ describe("Booking mutations", () => { | |
remark: testUpdatedBookingInfo.remark, | ||
}, | ||
}); | ||
|
||
await deleteBooking(booking); | ||
await deleteRoom(room); | ||
await deleteUser(user); | ||
}); | ||
|
||
test("do not allow to change other user's bookings", async () => { | ||
|
@@ -249,8 +245,8 @@ describe("Booking mutations", () => { | |
const testUpdatedBookingInfo = { | ||
id: booking.id, | ||
room: "123", | ||
start: booking.start, | ||
end: booking.end, | ||
start: booking.start.toISOString(), | ||
end: booking.end.toString(), | ||
remark: "HelloWorld", | ||
}; | ||
|
||
|
@@ -259,9 +255,6 @@ describe("Booking mutations", () => { | |
variables: testUpdatedBookingInfo, | ||
}); | ||
expect(result.errors[0].message).toEqual("Not Authorised!"); | ||
await deleteBooking(booking); | ||
await deleteRoom(room); | ||
await deleteUsers(user, user1); | ||
}); | ||
|
||
test("allow users to delete their own bookings", async () => { | ||
|
@@ -287,8 +280,6 @@ describe("Booking mutations", () => { | |
id: booking.id, | ||
}, | ||
}); | ||
await deleteRoom(room); | ||
await deleteUser(user); | ||
}); | ||
|
||
test("do not allow users to delete other user's own bookings", async () => { | ||
|
@@ -311,8 +302,5 @@ describe("Booking mutations", () => { | |
variables: { id: booking.id }, | ||
}); | ||
expect(result.errors[0].message).toEqual("Not Authorised!"); | ||
await deleteBooking(booking); | ||
await deleteRoom(room); | ||
await deleteUsers(user, user1); | ||
}); | ||
}); |
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,9 +4,9 @@ env.config(); | |
import gql from "graphql-tag"; | ||
import { GraphQLResponse } from "apollo-server-types"; | ||
import { createTestServerWithUserLoggedIn } from "../utils/server"; | ||
import { Event, User, Comment } from "../../src/generated/prisma-client"; | ||
import { Event, User, Comment } from "@prisma/client"; | ||
import { createTestClient } from "apollo-server-testing"; | ||
import { createUser, deleteUsers } from "../utils/users"; | ||
import { createUser, deleteUsers, TestUserInfo } from "../utils/users"; | ||
import { | ||
createEvent, | ||
deleteEvents, | ||
|
@@ -16,9 +16,9 @@ import { | |
retrieveEventComments, | ||
RetrieveEventCommentsInfo, | ||
} from "../utils/events"; | ||
import { deleteComments } from "../utils/comments"; | ||
|
||
const testUserInfo: User = { | ||
id: undefined, | ||
const testUserInfo: TestUserInfo = { | ||
username: "test123", | ||
email: "[email protected]", | ||
image_url: "http://url", | ||
|
@@ -29,8 +29,7 @@ const testUserInfo: User = { | |
role: "USER", | ||
}; | ||
|
||
const testUserInfo1: User = { | ||
id: undefined, | ||
const testUserInfo1: TestUserInfo = { | ||
username: "test234", | ||
email: "[email protected]", | ||
image_url: "http://url234", | ||
|
@@ -53,6 +52,12 @@ const testEventInfo: TestEventInfo = { | |
|
||
beforeAll(async () => await deleteUsers()); | ||
|
||
afterEach(async () => { | ||
await deleteEvents(); | ||
await deleteComments(); | ||
await deleteUsers(); | ||
}); | ||
|
||
describe("event comment creation", () => { | ||
test("should be able to create a new comment for an event", async () => { | ||
const testUser: User = await createUser(testUserInfo); | ||
|
@@ -88,8 +93,6 @@ describe("event comment creation", () => { | |
user: { id: testUser.id }, | ||
event: { id: testEvent.id }, | ||
}); | ||
await deleteEvents(); | ||
await deleteUsers(); | ||
}); | ||
}); | ||
|
||
|
@@ -125,12 +128,11 @@ describe("event comment deletion", () => { | |
variables: { id: testComment.id }, | ||
}); | ||
|
||
expect(deleteComment.id).toEqual(testComment.id); | ||
|
||
const eventInfo: RetrieveEventCommentsInfo = { event_id: testEvent.id }; | ||
const testEventComments: Comment[] = await retrieveEventComments(eventInfo); | ||
expect(testEventComments).toEqual([]); | ||
|
||
await deleteEvents(); | ||
await deleteUsers(); | ||
}); | ||
}); | ||
|
||
|
@@ -168,8 +170,5 @@ describe("invalid event comment deletion", () => { | |
}); | ||
|
||
expect(response.errors[0].message).toEqual("Not Authorised!"); | ||
|
||
await deleteEvents(); | ||
await deleteUsers(); | ||
}); | ||
}); |
Oops, something went wrong.