Prepare production branch: remove test files and add Dockerfile
- Remove all test files (__tests__, *.test.*, *.spec.*) - Remove Jest configuration files (jest.config.js, jest.setup.js) - Remove test-related scripts from package.json - Remove Jest dependencies from package.json - Add production Dockerfile for standalone Next.js app - Update tsconfig.json exclusions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,139 +0,0 @@
|
||||
import React from 'react'
|
||||
import { render, screen, waitFor, fireEvent } from '@testing-library/react'
|
||||
import { BibleReader } from '@/components/bible/reader'
|
||||
import { useStore } from '@/lib/store'
|
||||
|
||||
// Mock the store
|
||||
jest.mock('@/lib/store', () => ({
|
||||
useStore: jest.fn()
|
||||
}))
|
||||
|
||||
const mockUseStore = useStore as jest.MockedFunction<typeof useStore>
|
||||
|
||||
describe('BibleReader', () => {
|
||||
beforeEach(() => {
|
||||
mockUseStore.mockReturnValue({
|
||||
currentBook: 1,
|
||||
currentChapter: 1,
|
||||
user: null,
|
||||
theme: 'light',
|
||||
fontSize: 'medium',
|
||||
bookmarks: [],
|
||||
setUser: jest.fn(),
|
||||
setTheme: jest.fn(),
|
||||
setFontSize: jest.fn(),
|
||||
setCurrentBook: jest.fn(),
|
||||
setCurrentChapter: jest.fn(),
|
||||
addBookmark: jest.fn(),
|
||||
removeBookmark: jest.fn(),
|
||||
})
|
||||
|
||||
// Mock localStorage
|
||||
Object.defineProperty(window, 'localStorage', {
|
||||
value: {
|
||||
getItem: jest.fn(),
|
||||
setItem: jest.fn(),
|
||||
removeItem: jest.fn(),
|
||||
},
|
||||
writable: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('renders loading state initially', () => {
|
||||
// Mock fetch to delay response
|
||||
global.fetch = jest.fn(() => new Promise(() => {}))
|
||||
|
||||
render(<BibleReader />)
|
||||
|
||||
expect(screen.getByText(/Loading/i)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders verses correctly after loading', async () => {
|
||||
const mockChapterData = {
|
||||
chapter: {
|
||||
id: '1',
|
||||
bookName: 'Geneza',
|
||||
chapterNum: 1,
|
||||
verses: [
|
||||
{ id: '1', verseNum: 1, text: 'La început Dumnezeu a făcut cerurile și pământul.' },
|
||||
{ id: '2', verseNum: 2, text: 'Pământul era pustiu și gol.' },
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
global.fetch = jest.fn(() =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () => Promise.resolve(mockChapterData),
|
||||
})
|
||||
) as jest.Mock
|
||||
|
||||
render(<BibleReader />)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Geneza 1')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
expect(screen.getByText(/La început Dumnezeu a făcut/)).toBeInTheDocument()
|
||||
expect(screen.getByText(/Pământul era pustiu și gol/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows alert when trying to bookmark without authentication', async () => {
|
||||
const mockChapterData = {
|
||||
chapter: {
|
||||
id: '1',
|
||||
bookName: 'Geneza',
|
||||
chapterNum: 1,
|
||||
verses: [
|
||||
{ id: '1', verseNum: 1, text: 'La început Dumnezeu a făcut cerurile și pământul.' },
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
global.fetch = jest.fn(() =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () => Promise.resolve(mockChapterData),
|
||||
})
|
||||
) as jest.Mock
|
||||
|
||||
// Mock alert
|
||||
window.alert = jest.fn()
|
||||
|
||||
render(<BibleReader />)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/La început Dumnezeu a făcut/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
const verse = screen.getByText(/La început Dumnezeu a făcut/)
|
||||
fireEvent.click(verse)
|
||||
|
||||
expect(window.alert).toHaveBeenCalledWith('Trebuie să vă autentificați pentru a marca versete')
|
||||
})
|
||||
|
||||
it('renders navigation buttons', async () => {
|
||||
const mockChapterData = {
|
||||
chapter: {
|
||||
id: '1',
|
||||
bookName: 'Geneza',
|
||||
chapterNum: 1,
|
||||
verses: []
|
||||
}
|
||||
}
|
||||
|
||||
global.fetch = jest.fn(() =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () => Promise.resolve(mockChapterData),
|
||||
})
|
||||
) as jest.Mock
|
||||
|
||||
render(<BibleReader />)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('← Capitolul anterior')).toBeInTheDocument()
|
||||
expect(screen.getByText('Capitolul următor →')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,137 +0,0 @@
|
||||
import {
|
||||
userRegistrationSchema,
|
||||
userLoginSchema,
|
||||
chatMessageSchema,
|
||||
prayerRequestSchema,
|
||||
bookmarkSchema,
|
||||
searchSchema,
|
||||
chapterSchema
|
||||
} from '@/lib/validation'
|
||||
|
||||
describe('Validation Schemas', () => {
|
||||
describe('userRegistrationSchema', () => {
|
||||
it('should validate correct user registration data', () => {
|
||||
const validData = {
|
||||
email: 'test@example.com',
|
||||
password: 'Password123',
|
||||
name: 'Test User'
|
||||
}
|
||||
|
||||
const result = userRegistrationSchema.safeParse(validData)
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('should reject invalid email', () => {
|
||||
const invalidData = {
|
||||
email: 'invalid-email',
|
||||
password: 'Password123',
|
||||
name: 'Test User'
|
||||
}
|
||||
|
||||
const result = userRegistrationSchema.safeParse(invalidData)
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
|
||||
it('should reject weak password', () => {
|
||||
const invalidData = {
|
||||
email: 'test@example.com',
|
||||
password: 'weak',
|
||||
name: 'Test User'
|
||||
}
|
||||
|
||||
const result = userRegistrationSchema.safeParse(invalidData)
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('chatMessageSchema', () => {
|
||||
it('should validate correct chat message data', () => {
|
||||
const validData = {
|
||||
messages: [
|
||||
{ role: 'user', content: 'Hello' },
|
||||
{ role: 'assistant', content: 'Hi there!' }
|
||||
]
|
||||
}
|
||||
|
||||
const result = chatMessageSchema.safeParse(validData)
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('should reject empty messages array', () => {
|
||||
const invalidData = {
|
||||
messages: []
|
||||
}
|
||||
|
||||
const result = chatMessageSchema.safeParse(invalidData)
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('prayerRequestSchema', () => {
|
||||
it('should validate correct prayer request', () => {
|
||||
const validData = {
|
||||
content: 'Please pray for my family during this difficult time.',
|
||||
isAnonymous: true
|
||||
}
|
||||
|
||||
const result = prayerRequestSchema.safeParse(validData)
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('should reject too short prayer request', () => {
|
||||
const invalidData = {
|
||||
content: 'Short',
|
||||
isAnonymous: true
|
||||
}
|
||||
|
||||
const result = prayerRequestSchema.safeParse(invalidData)
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('searchSchema', () => {
|
||||
it('should validate correct search parameters', () => {
|
||||
const validData = {
|
||||
q: 'love',
|
||||
limit: 10
|
||||
}
|
||||
|
||||
const result = searchSchema.safeParse(validData)
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('should apply default limit', () => {
|
||||
const validData = {
|
||||
q: 'love'
|
||||
}
|
||||
|
||||
const result = searchSchema.safeParse(validData)
|
||||
expect(result.success).toBe(true)
|
||||
if (result.success) {
|
||||
expect(result.data.limit).toBe(10)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('chapterSchema', () => {
|
||||
it('should validate correct chapter parameters', () => {
|
||||
const validData = {
|
||||
book: 1,
|
||||
chapter: 1
|
||||
}
|
||||
|
||||
const result = chapterSchema.safeParse(validData)
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
it('should reject invalid book ID', () => {
|
||||
const invalidData = {
|
||||
book: 0,
|
||||
chapter: 1
|
||||
}
|
||||
|
||||
const result = chapterSchema.safeParse(invalidData)
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user