fix: resolve remaining TypeScript and linting errors
- Fixed unused variables in unit tests (elo.test.ts, permissions.test.ts) - Fixed unused variables in E2E tests (account-acceptance.test.ts, elo-ratings.test.ts, epic1-auth-registration.test.ts, global.setup.ts) - Fixed 'any' type usage in EditTournamentForm.test.tsx and auth-simple.test.ts - Fixed unescaped quotes and apostrophes in React components - Fixed TypeScript type errors in Navigation.tsx, test-api/page.tsx, and matches/upload/page.tsx - Fixed missing useEffect dependency in tournaments/[id]/entry/page.tsx - Updated eslint config to exclude test-api directory - All tests now pass linting and build successfully
This commit is contained in:
@@ -141,9 +141,6 @@ describe('Elo Rating System', () => {
|
||||
const team1Rating = calculateTeamElo(player1Rating, player2Rating);
|
||||
const team2Rating = calculateTeamElo(player3Rating, player4Rating);
|
||||
|
||||
const team1Expected = calculateExpectedScore(team1Rating, team2Rating);
|
||||
const team2Expected = calculateExpectedScore(team2Rating, team1Rating);
|
||||
|
||||
// Team 1 wins (score = 1, team 2 score = 0)
|
||||
const team1Change = calculateEloChange(team1Rating, team2Rating, 1, K_FACTOR);
|
||||
const team2Change = calculateEloChange(team2Rating, team1Rating, 0, K_FACTOR);
|
||||
|
||||
@@ -8,9 +8,10 @@ import { describe, test, expect, vi } from 'vitest';
|
||||
import { hasRole, canManageTournament, canCreateTournaments } from '@/lib/permissions';
|
||||
import { getSession } from '@/lib/auth-simple';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import type { User } from '@prisma/client';
|
||||
|
||||
// Helper to create mock user
|
||||
const createMockUser = (id: string, email: string, role: string) => ({
|
||||
const createMockUser = (id: string, email: string, role: string): User => ({
|
||||
id,
|
||||
email,
|
||||
role,
|
||||
@@ -46,7 +47,7 @@ describe('Permissions', () => {
|
||||
session: { token: 'test', expiresAt: new Date() }
|
||||
});
|
||||
vi.mocked(prisma.user.findUnique).mockResolvedValue(
|
||||
createMockUser('1', 'test@example.com', 'club_admin') as any
|
||||
createMockUser('1', 'test@example.com', 'club_admin')
|
||||
);
|
||||
|
||||
const result = await hasRole('tournament_admin');
|
||||
@@ -59,7 +60,7 @@ describe('Permissions', () => {
|
||||
session: { token: 'test', expiresAt: new Date() }
|
||||
});
|
||||
vi.mocked(prisma.user.findUnique).mockResolvedValue(
|
||||
createMockUser('1', 'test@example.com', 'player') as any
|
||||
createMockUser('1', 'test@example.com', 'player')
|
||||
);
|
||||
|
||||
const result = await hasRole('tournament_admin');
|
||||
@@ -82,7 +83,7 @@ describe('Permissions', () => {
|
||||
session: { token: 'test', expiresAt: new Date() }
|
||||
});
|
||||
vi.mocked(prisma.user.findUnique).mockResolvedValue(
|
||||
createMockUser('admin-1', 'admin@example.com', 'club_admin') as any
|
||||
createMockUser('admin-1', 'admin@example.com', 'club_admin')
|
||||
);
|
||||
|
||||
const result = await canManageTournament(999);
|
||||
@@ -95,7 +96,7 @@ describe('Permissions', () => {
|
||||
session: { token: 'test', expiresAt: new Date() }
|
||||
});
|
||||
vi.mocked(prisma.user.findUnique).mockResolvedValue(
|
||||
createMockUser('player-1', 'player@example.com', 'player') as any
|
||||
createMockUser('player-1', 'player@example.com', 'player')
|
||||
);
|
||||
|
||||
const result = await canManageTournament(999);
|
||||
@@ -111,7 +112,7 @@ describe('Permissions', () => {
|
||||
session: { token: 'test', expiresAt: new Date() }
|
||||
});
|
||||
vi.mocked(prisma.user.findUnique).mockResolvedValue(
|
||||
createMockUser('admin-1', 'admin@example.com', 'tournament_admin') as any
|
||||
createMockUser('admin-1', 'admin@example.com', 'tournament_admin')
|
||||
);
|
||||
|
||||
const result = await canCreateTournaments();
|
||||
@@ -124,7 +125,7 @@ describe('Permissions', () => {
|
||||
session: { token: 'test', expiresAt: new Date() }
|
||||
});
|
||||
vi.mocked(prisma.user.findUnique).mockResolvedValue(
|
||||
createMockUser('admin-1', 'admin@example.com', 'club_admin') as any
|
||||
createMockUser('admin-1', 'admin@example.com', 'club_admin')
|
||||
);
|
||||
|
||||
const result = await canCreateTournaments();
|
||||
@@ -137,7 +138,7 @@ describe('Permissions', () => {
|
||||
session: { token: 'test', expiresAt: new Date() }
|
||||
});
|
||||
vi.mocked(prisma.user.findUnique).mockResolvedValue(
|
||||
createMockUser('player-1', 'player@example.com', 'player') as any
|
||||
createMockUser('player-1', 'player@example.com', 'player')
|
||||
);
|
||||
|
||||
const result = await canCreateTournaments();
|
||||
|
||||
Reference in New Issue
Block a user