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:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
|
||||
import { describe, it, expect, vi, beforeEach, MockedFunction } from 'vitest'
|
||||
import { render, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import EditTournamentForm from '@/components/EditTournamentForm'
|
||||
|
||||
@@ -18,7 +18,8 @@ vi.mock('next/link', () => ({
|
||||
}))
|
||||
|
||||
// Mock fetch
|
||||
global.fetch = vi.fn()
|
||||
const mockFetch = vi.fn()
|
||||
global.fetch = mockFetch as MockedFunction<typeof global.fetch>
|
||||
|
||||
const mockTournament = {
|
||||
id: 1,
|
||||
@@ -65,10 +66,10 @@ describe('EditTournamentForm', () => {
|
||||
|
||||
it('submits form with updated data', async () => {
|
||||
const user = userEvent.setup()
|
||||
;(global.fetch as any).mockResolvedValueOnce({
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({ success: true }),
|
||||
})
|
||||
} as Response)
|
||||
|
||||
render(<EditTournamentForm tournament={mockTournament} />)
|
||||
|
||||
@@ -80,7 +81,7 @@ describe('EditTournamentForm', () => {
|
||||
await user.click(submitButton)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(global.fetch).toHaveBeenCalledWith(
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
'/api/tournaments/1',
|
||||
expect.objectContaining({
|
||||
method: 'PUT',
|
||||
@@ -92,10 +93,10 @@ describe('EditTournamentForm', () => {
|
||||
|
||||
it('shows error message on failed submission', async () => {
|
||||
const user = userEvent.setup()
|
||||
;(global.fetch as any).mockResolvedValueOnce({
|
||||
mockFetch.mockResolvedValueOnce({
|
||||
ok: false,
|
||||
json: async () => ({ error: 'Failed to update tournament' }),
|
||||
})
|
||||
} as Response)
|
||||
|
||||
render(<EditTournamentForm tournament={mockTournament} />)
|
||||
|
||||
@@ -109,14 +110,14 @@ describe('EditTournamentForm', () => {
|
||||
|
||||
it('disables submit button while loading', async () => {
|
||||
const user = userEvent.setup()
|
||||
;(global.fetch as any).mockImplementation(
|
||||
mockFetch.mockImplementation(
|
||||
() =>
|
||||
new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve({
|
||||
ok: true,
|
||||
json: async () => ({ success: true }),
|
||||
})
|
||||
} as Response)
|
||||
}, 100)
|
||||
})
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user