From df8e78f4b3cddfe65f35c5c0a7d28262cd4290c0 Mon Sep 17 00:00:00 2001 From: Joe Baker Date: Fri, 8 Nov 2024 10:19:37 +0000 Subject: [PATCH 1/5] chore: update e2e fixtures to sentence case --- apps/nextjs/tests-e2e/tests/sharing.test.ts | 4 ++-- apps/nextjs/tests-e2e/tests/sidebar.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/nextjs/tests-e2e/tests/sharing.test.ts b/apps/nextjs/tests-e2e/tests/sharing.test.ts index 6e0bdd046..b15ab5060 100644 --- a/apps/nextjs/tests-e2e/tests/sharing.test.ts +++ b/apps/nextjs/tests-e2e/tests/sharing.test.ts @@ -12,7 +12,7 @@ const checkPage = async (page: Page) => { await expect(banner).toContainText("Please check content carefully"); const keyStageSubjectTitle = page.getByTestId("key-stage-subject"); - await expect(keyStageSubjectTitle).toContainText("Key Stage 4"); + await expect(keyStageSubjectTitle).toContainText("Key stage 4"); await expect(keyStageSubjectTitle).toContainText("Computing"); await expect(page.locator("h1")).toContainText("Software Testing Techniques"); @@ -61,7 +61,7 @@ test("sharing a lesson", async ({ page, context, browser }) => { const modal = page.getByTestId("chat-share-dialog"); await expect(modal).toBeVisible(); - await expect(modal).toContainText("Share Chat"); + await expect(modal).toContainText("Share chat"); await modal.getByText("Create shareable link").click(); diff --git a/apps/nextjs/tests-e2e/tests/sidebar.test.ts b/apps/nextjs/tests-e2e/tests/sidebar.test.ts index 41bde008b..0220657ee 100644 --- a/apps/nextjs/tests-e2e/tests/sidebar.test.ts +++ b/apps/nextjs/tests-e2e/tests/sidebar.test.ts @@ -18,13 +18,13 @@ test( await page.getByTestId("sidebar-button").click(); const sidebar = page.getByTestId("sidebar"); expect(sidebar).toBeVisible(); - await sidebar.getByText("Software Testing Techniques").click(); + await sidebar.getByText("Software testing techniques").click(); }); await test.step("Lesson has loaded", async () => { await page.waitForURL(/\/aila\/.+/); await expect(page.locator("h1")).toContainText( - "Software Testing Techniques", + "Software testing techniques", ); }); }, From 4ddfa700be930bbdbf8744b0db743ade69d3efba Mon Sep 17 00:00:00 2001 From: Joe Baker Date: Fri, 8 Nov 2024 11:09:21 +0000 Subject: [PATCH 2/5] feat: add prisma health check --- packages/api/src/router/health.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/api/src/router/health.ts b/packages/api/src/router/health.ts index a7d4f910b..e07a8518c 100644 --- a/packages/api/src/router/health.ts +++ b/packages/api/src/router/health.ts @@ -1,7 +1,23 @@ +import { aiLogger } from "@oakai/logger"; + import { router, publicProcedure } from "../trpc"; +const log = aiLogger("prisma-health-check"); + export const healthRouter = router({ check: publicProcedure.query(() => { return "OK"; }), + prismaCheck: publicProcedure.query(async ({ ctx }) => { + try { + await ctx.prisma.prompt.count(); + return { status: "ok", message: "Prisma is connected" }; + } catch (error) { + log.error("Prisma health check failed", error); + throw new TRPCError({ + code: "INTERNAL_SERVER_ERROR", + message: "Prisma connection failed", + }); + } + }), }); From 4d995bc1f534b24daf672b8e7416fa022368de48 Mon Sep 17 00:00:00 2001 From: Joe Baker Date: Fri, 8 Nov 2024 11:16:24 +0000 Subject: [PATCH 3/5] chore: fix ai logger type --- packages/api/src/router/health.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/api/src/router/health.ts b/packages/api/src/router/health.ts index e07a8518c..14e585118 100644 --- a/packages/api/src/router/health.ts +++ b/packages/api/src/router/health.ts @@ -1,8 +1,9 @@ import { aiLogger } from "@oakai/logger"; +import { TRPCError } from "@trpc/server"; import { router, publicProcedure } from "../trpc"; -const log = aiLogger("prisma-health-check"); +const log = aiLogger("db"); export const healthRouter = router({ check: publicProcedure.query(() => { From caf47505cdbf28afd7e95a7166ed92d59f9ed6ee Mon Sep 17 00:00:00 2001 From: Joe Baker Date: Fri, 8 Nov 2024 12:33:44 +0000 Subject: [PATCH 4/5] chore: add check to public routes --- apps/nextjs/src/middlewares/auth.middleware.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/nextjs/src/middlewares/auth.middleware.ts b/apps/nextjs/src/middlewares/auth.middleware.ts index 361fea1e9..bd5d0edfb 100644 --- a/apps/nextjs/src/middlewares/auth.middleware.ts +++ b/apps/nextjs/src/middlewares/auth.middleware.ts @@ -22,6 +22,7 @@ const publicRoutes = [ "/api/health", "/aila/health", "/api/trpc/main/health.check", + "/api/trpc/main/health.prismaCheck", "/api/trpc/chat/chat.health.check", /** * The inngest route is protected using a signing key From 291db96539c00235dd084b5a1bc23f3ca923ff7e Mon Sep 17 00:00:00 2001 From: Joe Baker Date: Fri, 8 Nov 2024 14:32:34 +0000 Subject: [PATCH 5/5] Revert "chore: update e2e fixtures to sentence case" This reverts commit df8e78f4b3cddfe65f35c5c0a7d28262cd4290c0. --- apps/nextjs/tests-e2e/tests/sharing.test.ts | 4 ++-- apps/nextjs/tests-e2e/tests/sidebar.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/nextjs/tests-e2e/tests/sharing.test.ts b/apps/nextjs/tests-e2e/tests/sharing.test.ts index b15ab5060..6e0bdd046 100644 --- a/apps/nextjs/tests-e2e/tests/sharing.test.ts +++ b/apps/nextjs/tests-e2e/tests/sharing.test.ts @@ -12,7 +12,7 @@ const checkPage = async (page: Page) => { await expect(banner).toContainText("Please check content carefully"); const keyStageSubjectTitle = page.getByTestId("key-stage-subject"); - await expect(keyStageSubjectTitle).toContainText("Key stage 4"); + await expect(keyStageSubjectTitle).toContainText("Key Stage 4"); await expect(keyStageSubjectTitle).toContainText("Computing"); await expect(page.locator("h1")).toContainText("Software Testing Techniques"); @@ -61,7 +61,7 @@ test("sharing a lesson", async ({ page, context, browser }) => { const modal = page.getByTestId("chat-share-dialog"); await expect(modal).toBeVisible(); - await expect(modal).toContainText("Share chat"); + await expect(modal).toContainText("Share Chat"); await modal.getByText("Create shareable link").click(); diff --git a/apps/nextjs/tests-e2e/tests/sidebar.test.ts b/apps/nextjs/tests-e2e/tests/sidebar.test.ts index 0220657ee..41bde008b 100644 --- a/apps/nextjs/tests-e2e/tests/sidebar.test.ts +++ b/apps/nextjs/tests-e2e/tests/sidebar.test.ts @@ -18,13 +18,13 @@ test( await page.getByTestId("sidebar-button").click(); const sidebar = page.getByTestId("sidebar"); expect(sidebar).toBeVisible(); - await sidebar.getByText("Software testing techniques").click(); + await sidebar.getByText("Software Testing Techniques").click(); }); await test.step("Lesson has loaded", async () => { await page.waitForURL(/\/aila\/.+/); await expect(page.locator("h1")).toContainText( - "Software testing techniques", + "Software Testing Techniques", ); }); },