Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella committed Jun 16, 2024
1 parent 4fc814f commit 7a5db60
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 23 deletions.
3 changes: 2 additions & 1 deletion apps/web/public/locales/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,5 +262,6 @@
"upcomingEventsEmptyStateDescription": "When you schedule events, they will appear here.",
"pastEventsEmptyStateTitle": "No Past Events",
"pastEventsEmptyStateDescription": "When you schedule events, they will appear here.",
"activePollCount": "{{activePollCount}} Live"
"activePollCount": "{{activePollCount}} Live",
"createPoll": "Create poll"
}
2 changes: 0 additions & 2 deletions apps/web/src/app/[locale]/(admin)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React from "react";
import { MobileNavigation } from "@/app/[locale]/(admin)/mobile-navigation";
import { Sidebar } from "@/app/[locale]/(admin)/sidebar";
import { LogoLink } from "@/app/components/logo-link";
import { SquircleClipPath } from "@/app/components/squircle";

export default async function Layout({
children,
Expand All @@ -13,7 +12,6 @@ export default async function Layout({
}) {
return (
<div className="flex flex-col pb-16 md:pb-0">
<SquircleClipPath />
<div
className={cn(
"fixed inset-y-0 z-50 hidden w-72 shrink-0 flex-col gap-y-4 overflow-y-auto p-6 py-5 md:flex",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/create-poll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const CreatePoll: React.FunctionComponent = () => {
className="w-full"
variant="primary"
>
<Trans i18nKey="create" />
<Trans i18nKey="createPoll" defaults="Create poll" />
</Button>
</div>
</form>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/tests/authentication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test.describe.serial(() => {

await page.getByRole("button", { name: "Continue", exact: true }).click();

await page.waitForURL("/polls");
await page.waitForURL("/");
});
});

Expand Down Expand Up @@ -121,7 +121,7 @@ test.describe.serial(() => {

await page.getByRole("button", { name: "Continue", exact: true }).click();

await page.waitForURL("/polls");
await page.waitForURL("/");

await expect(page.getByText("Test User")).toBeVisible();
});
Expand All @@ -141,7 +141,7 @@ test.describe.serial(() => {

await page.getByRole("button", { name: "Continue", exact: true }).click();

await page.waitForURL("/polls");
await page.waitForURL("/");

await expect(page.getByText("Test User")).toBeVisible();
});
Expand All @@ -161,7 +161,7 @@ test.describe.serial(() => {

await page.getByRole("button", { name: "Continue", exact: true }).click();

await page.waitForURL("/polls");
await page.waitForURL("/");

await expect(page.getByText("Test User")).toBeVisible();
});
Expand Down
10 changes: 5 additions & 5 deletions apps/web/tests/create-delete-poll.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ test.describe.serial(() => {

await expect(page.getByTestId("poll-title")).toHaveText("Monthly Meetup");

// const { email } = await mailServer.captureOne("[email protected]", {
// wait: 5000,
// });
const { email } = await mailServer.captureOne("[email protected]", {
wait: 5000,
});

// expect(email.headers.subject).toBe("Let's find a date for Monthly Meetup");
expect(email.headers.subject).toBe("Let's find a date for Monthly Meetup");
});

// delete the poll we just created
Expand All @@ -41,6 +41,6 @@ test.describe.serial(() => {

deletePollDialog.getByRole("button", { name: "delete" }).click();

await expect(page).toHaveURL("/polls");
await expect(page).toHaveURL("/");
});
});
1 change: 1 addition & 0 deletions packages/backend/trpc/routers/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const dashboard = router({
where: {
userId: ctx.user.id,
status: "live",
deleted: false, // TODO (Luke Vella) [2024-06-16]: We should add deleted/cancelled to the status enum
},
});

Expand Down
1 change: 0 additions & 1 deletion packages/backend/trpc/routers/polls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const polls = router({
return await prisma.poll.findMany({
where: {
userId: ctx.user.id,
deleted: false,
status: input.status === "all" ? undefined : input.status,
},
orderBy: [
Expand Down
32 changes: 23 additions & 9 deletions packages/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import { PrismaClient } from "@rallly/database";
import { PrismaClient } from "@prisma/client";

export * from "@prisma/client";
const prismaClientSingleton = () => {
return new PrismaClient().$extends({
query: {
poll: {
findMany: ({ args, query }) => {
if (args.where?.deleted === undefined) {
args.where = { ...args.where, deleted: false };
}

declare global {
// allow global `var` declarations
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined;
}
return query(args);
},
},
},
});
};

export const prisma = global.prisma || new PrismaClient();
declare const globalThis: {
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;

if (process.env.NODE_ENV !== "production") global.prisma = prisma;
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();

export { prisma };

if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;

0 comments on commit 7a5db60

Please sign in to comment.