From b0aaffbecfb30c58abfcf48cf83fc43aa35181c8 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Mon, 30 Mar 2026 22:58:33 -0700 Subject: [PATCH] chore: fix linting errors in tests and api routes --- src/__tests__/e2e/csv-upload-deduplication.test.ts | 2 +- src/__tests__/e2e/tournament-admin-permissions.test.ts | 7 +++---- src/__tests__/unit/tournament-permissions.test.ts | 4 +++- src/app/api/users/[id]/route.ts | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/__tests__/e2e/csv-upload-deduplication.test.ts b/src/__tests__/e2e/csv-upload-deduplication.test.ts index accd889..252a0b8 100644 --- a/src/__tests__/e2e/csv-upload-deduplication.test.ts +++ b/src/__tests__/e2e/csv-upload-deduplication.test.ts @@ -13,7 +13,7 @@ const prisma = new PrismaClient(); test.describe('CSV Upload Player Deduplication', () => { let testTournamentId: number; - let testPlayerIds: number[] = []; + const testPlayerIds: number[] = []; test.beforeAll(async () => { // Create a test tournament diff --git a/src/__tests__/e2e/tournament-admin-permissions.test.ts b/src/__tests__/e2e/tournament-admin-permissions.test.ts index 24b5d1f..8bf126b 100644 --- a/src/__tests__/e2e/tournament-admin-permissions.test.ts +++ b/src/__tests__/e2e/tournament-admin-permissions.test.ts @@ -13,13 +13,12 @@ const prisma = new PrismaClient(); test.describe('Tournament Admin Permissions', () => { let tournamentId: number; let tournamentAdminEmail: string; - let tournamentAdminPassword: string; + test.beforeAll(async () => { // Create a test tournament admin user const timestamp = Date.now(); tournamentAdminEmail = `tour-admin-${timestamp}@example.com`; - tournamentAdminPassword = 'TourAdmin123!'; // Create user via API (simulating registration) // Note: In a real scenario, we'd use the auth API, but for this test @@ -66,7 +65,7 @@ test.describe('Tournament Admin Permissions', () => { await prisma.$disconnect(); }); - test('tournament_admin can access tournament detail page', async ({ page }) => { + test('tournament_admin can access tournament detail page', async () => { // Note: This test would require authentication setup // For now, we'll verify the permission logic works correctly // by checking the canManageTournament function directly @@ -84,7 +83,7 @@ test.describe('Tournament Admin Permissions', () => { test.skip(true, 'Authentication setup required for full e2e test'); }); - test('tournament_admin cannot access other users tournaments', async ({ page }) => { + test('tournament_admin cannot access other users tournaments', async () => { // Create another user's tournament const otherUser = await prisma.user.create({ data: { diff --git a/src/__tests__/unit/tournament-permissions.test.ts b/src/__tests__/unit/tournament-permissions.test.ts index 9a54fee..e818be2 100644 --- a/src/__tests__/unit/tournament-permissions.test.ts +++ b/src/__tests__/unit/tournament-permissions.test.ts @@ -6,7 +6,7 @@ */ import { describe, test, expect, vi, beforeEach } from 'vitest'; -import { canManageTournament, ownsTournament, hasRole, getManageableTournaments } from '@/lib/permissions'; +import { canManageTournament, ownsTournament, getManageableTournaments } from '@/lib/permissions'; import { getSession } from '@/lib/auth-simple'; import { prisma } from '@/lib/prisma'; import type { User, Event } from '@prisma/client'; @@ -53,6 +53,8 @@ const createMockTournament = (id: number, ownerId: string | null): Event => ({ status: 'planned', maxParticipants: null, ownerId, + targetScore: null, + allowTies: false, createdAt: new Date(), updatedAt: new Date(), }); diff --git a/src/app/api/users/[id]/route.ts b/src/app/api/users/[id]/route.ts index fcb3345..e8ce157 100644 --- a/src/app/api/users/[id]/route.ts +++ b/src/app/api/users/[id]/route.ts @@ -1,7 +1,7 @@ import { NextRequest, NextResponse } from 'next/server'; import { prisma } from '@/lib/prisma'; import { getSession } from '@/lib/auth-simple'; -import { hasRole, canEditUserProfiles } from '@/lib/permissions'; +import { canEditUserProfiles } from '@/lib/permissions'; export async function GET( request: NextRequest, @@ -91,7 +91,7 @@ export async function PATCH( } // Update the user's name and the associated player's name if it exists - const updateData: any = { name: trimmedName }; + const updateData: Record = { name: trimmedName }; if (user.player) { // Also update the player name if the user has an associated player