fixed failing tests

This commit is contained in:
Erza Bytyci
2026-05-25 12:25:58 +00:00
parent 4bd48253cf
commit 836420e8e0
3 changed files with 7 additions and 4 deletions
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -1,7 +1,8 @@
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import { DB } from "@/backend/db"; import { DB } from "@/backend/db";
import { withAuth } from "@/backend/middleware/withAuth";
export async function GET() { export const GET = withAuth(async () => {
try { try {
const { rows } = await DB.pool(` const { rows } = await DB.pool(`
SELECT SELECT
@@ -29,4 +30,4 @@ export async function GET() {
{ status: 500 } { status: 500 }
); );
} }
} });
@@ -9,6 +9,7 @@ describe("GET /api/exercises/multichoice/:id", () => {
useTestDatabase(); useTestDatabase();
let exercise; let exercise;
let user;
async function setupExercise() { async function setupExercise() {
// Create a base exercise entry // Create a base exercise entry
@@ -56,11 +57,12 @@ describe("GET /api/exercises/multichoice/:id", () => {
beforeEach(async () => { beforeEach(async () => {
// Set up the exercise and store it for use in tests // Set up the exercise and store it for use in tests
user = await TestFactory.user();
exercise = await setupExercise(); exercise = await setupExercise();
}); });
const getRequest = async (id) => { const getRequest = async (id) => {
const { mockGet } = useTestRequest(); const { mockGet } = useTestRequest(user);
const request = mockGet(`/api/exercises/multichoice/${id}`); const request = mockGet(`/api/exercises/multichoice/${id}`);
const response = await GET(request, { params: { id } }); const response = await GET(request, { params: { id } });
const result = await response.json(); const result = await response.json();