Skip to content

Commit

Permalink
SeedUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
jho44 committed Feb 24, 2024
1 parent 0c89052 commit 6a4c4ba
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 299 deletions.
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config: PlaywrightTestConfig = {
expect: {
timeout: 3000
},
timeout: 5000,
// timeout: 10000,
testDir: 'tests'
};

Expand Down
49 changes: 15 additions & 34 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,22 @@
import { PrismaClient } from '@prisma/client';
import {
createActiveSession,
createExpiredLink,
createFriendRequest,
createHouseholdConnection,
createHouseholdInvite,
createUserWithEmptyHousehold,
createUserWithKid,
createUserWithNothing,
deleteAllFriendRequests
} from './utils';
import SeedUtils from './utils';

export const prisma = new PrismaClient();
const prisma = new PrismaClient();

async function main() {
const now = new Date();
const expires = new Date();
expires.setHours(expires.getHours() + 1);

await deleteAllFriendRequests();

await createExpiredLink(1);

await Promise.all([1, 2].map(async (userInd) => await createUserWithNothing(now, userInd)));
await Promise.all(
[3, 4].map(async (userInd) => await createUserWithEmptyHousehold(now, userInd))
);
await Promise.all([2, 4, 6].map(async (userInd) => await createActiveSession(now, userInd)));

await createUserWithEmptyHousehold(now, 5);
await createUserWithKid(now, 6);

await createFriendRequest(4, 3);

await createHouseholdConnection(3, 5);

await createHouseholdInvite(5, 2);
const utils = new SeedUtils(new Date(), prisma);
await Promise.all([
utils.deleteAllFriendRequests(),
utils.createExpiredLink(1),
...[1, 2].map((userInd) => utils.createUserWithNothing(userInd)),
...[3, 4].map((userInd) => utils.createUserWithEmptyHousehold(userInd)),
...[2, 4, 6].map((userInd) => utils.createActiveSession(userInd)),
utils.createUserWithEmptyHousehold(5),
utils.createUserWithKid(6),
utils.createFriendRequest(4, 3),
utils.createHouseholdConnection(3, 5),
utils.createHouseholdInvite(5, 2)
]);
}

export async function run() {
Expand Down
Loading

0 comments on commit 6a4c4ba

Please sign in to comment.