chore: fix linting errors in tests and api routes
This commit is contained in:
@@ -13,7 +13,7 @@ const prisma = new PrismaClient();
|
|||||||
|
|
||||||
test.describe('CSV Upload Player Deduplication', () => {
|
test.describe('CSV Upload Player Deduplication', () => {
|
||||||
let testTournamentId: number;
|
let testTournamentId: number;
|
||||||
let testPlayerIds: number[] = [];
|
const testPlayerIds: number[] = [];
|
||||||
|
|
||||||
test.beforeAll(async () => {
|
test.beforeAll(async () => {
|
||||||
// Create a test tournament
|
// Create a test tournament
|
||||||
|
|||||||
@@ -13,13 +13,12 @@ const prisma = new PrismaClient();
|
|||||||
test.describe('Tournament Admin Permissions', () => {
|
test.describe('Tournament Admin Permissions', () => {
|
||||||
let tournamentId: number;
|
let tournamentId: number;
|
||||||
let tournamentAdminEmail: string;
|
let tournamentAdminEmail: string;
|
||||||
let tournamentAdminPassword: string;
|
|
||||||
|
|
||||||
test.beforeAll(async () => {
|
test.beforeAll(async () => {
|
||||||
// Create a test tournament admin user
|
// Create a test tournament admin user
|
||||||
const timestamp = Date.now();
|
const timestamp = Date.now();
|
||||||
tournamentAdminEmail = `tour-admin-${timestamp}@example.com`;
|
tournamentAdminEmail = `tour-admin-${timestamp}@example.com`;
|
||||||
tournamentAdminPassword = 'TourAdmin123!';
|
|
||||||
|
|
||||||
// Create user via API (simulating registration)
|
// Create user via API (simulating registration)
|
||||||
// Note: In a real scenario, we'd use the auth API, but for this test
|
// 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();
|
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
|
// Note: This test would require authentication setup
|
||||||
// For now, we'll verify the permission logic works correctly
|
// For now, we'll verify the permission logic works correctly
|
||||||
// by checking the canManageTournament function directly
|
// 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.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
|
// Create another user's tournament
|
||||||
const otherUser = await prisma.user.create({
|
const otherUser = await prisma.user.create({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, test, expect, vi, beforeEach } from 'vitest';
|
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 { getSession } from '@/lib/auth-simple';
|
||||||
import { prisma } from '@/lib/prisma';
|
import { prisma } from '@/lib/prisma';
|
||||||
import type { User, Event } from '@prisma/client';
|
import type { User, Event } from '@prisma/client';
|
||||||
@@ -53,6 +53,8 @@ const createMockTournament = (id: number, ownerId: string | null): Event => ({
|
|||||||
status: 'planned',
|
status: 'planned',
|
||||||
maxParticipants: null,
|
maxParticipants: null,
|
||||||
ownerId,
|
ownerId,
|
||||||
|
targetScore: null,
|
||||||
|
allowTies: false,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
import { prisma } from '@/lib/prisma';
|
import { prisma } from '@/lib/prisma';
|
||||||
import { getSession } from '@/lib/auth-simple';
|
import { getSession } from '@/lib/auth-simple';
|
||||||
import { hasRole, canEditUserProfiles } from '@/lib/permissions';
|
import { canEditUserProfiles } from '@/lib/permissions';
|
||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: NextRequest,
|
request: NextRequest,
|
||||||
@@ -91,7 +91,7 @@ export async function PATCH(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the user's name and the associated player's name if it exists
|
// Update the user's name and the associated player's name if it exists
|
||||||
const updateData: any = { name: trimmedName };
|
const updateData: Record<string, unknown> = { name: trimmedName };
|
||||||
|
|
||||||
if (user.player) {
|
if (user.player) {
|
||||||
// Also update the player name if the user has an associated player
|
// Also update the player name if the user has an associated player
|
||||||
|
|||||||
Reference in New Issue
Block a user