fix: mount /apps and docker socket in PR workflow build-and-deploy-ci job #41
@@ -8,12 +8,32 @@ import { describe, it, expect, mock, beforeEach,} from 'bun:test';
|
|||||||
// Create mock functions at module level
|
// Create mock functions at module level
|
||||||
const eventFindUniqueMock = mock(async () => ({}));
|
const eventFindUniqueMock = mock(async () => ({}));
|
||||||
const eventUpdateMock = mock(async () => ({}));
|
const eventUpdateMock = mock(async () => ({}));
|
||||||
const canManageTournamentMock = mock(async () => ({ allowed: true }));
|
const userFindUniqueMock = mock(async () => ({
|
||||||
const canDeleteTournamentMock = mock(async () => ({ allowed: true }));
|
id: 'admin-1',
|
||||||
|
email: 'admin@example.com',
|
||||||
|
role: 'club_admin',
|
||||||
|
emailVerified: false,
|
||||||
|
name: null,
|
||||||
|
image: null,
|
||||||
|
playerId: null,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
}));
|
||||||
|
|
||||||
// Mock prisma first
|
// Mock auth-simple to return a valid session
|
||||||
|
mock.module('@/lib/auth-simple', () => ({
|
||||||
|
getSession: mock(async () => ({
|
||||||
|
user: { id: 'admin-1', email: 'admin@example.com' },
|
||||||
|
session: { token: 'test', expiresAt: new Date() }
|
||||||
|
})),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock prisma with user and event
|
||||||
mock.module('@/lib/prisma', () => ({
|
mock.module('@/lib/prisma', () => ({
|
||||||
prisma: {
|
prisma: {
|
||||||
|
user: {
|
||||||
|
findUnique: userFindUniqueMock,
|
||||||
|
},
|
||||||
event: {
|
event: {
|
||||||
findUnique: eventFindUniqueMock,
|
findUnique: eventFindUniqueMock,
|
||||||
update: eventUpdateMock,
|
update: eventUpdateMock,
|
||||||
@@ -21,12 +41,6 @@ mock.module('@/lib/prisma', () => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock the permissions module
|
|
||||||
mock.module('@/lib/permissions', () => ({
|
|
||||||
canManageTournament: canManageTournamentMock,
|
|
||||||
canDeleteTournament: canDeleteTournamentMock,
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Import the route handler after mocking
|
// Import the route handler after mocking
|
||||||
import { PUT } from '@/app/api/tournaments/[id]/route';
|
import { PUT } from '@/app/api/tournaments/[id]/route';
|
||||||
import { prisma } from '@/lib/prisma';
|
import { prisma } from '@/lib/prisma';
|
||||||
@@ -36,8 +50,7 @@ describe('Tournament Update API', () => {
|
|||||||
// Clear all mock history before each test
|
// Clear all mock history before each test
|
||||||
eventFindUniqueMock.mockClear();
|
eventFindUniqueMock.mockClear();
|
||||||
eventUpdateMock.mockClear();
|
eventUpdateMock.mockClear();
|
||||||
canManageTournamentMock.mockClear();
|
userFindUniqueMock.mockClear();
|
||||||
canDeleteTournamentMock.mockClear();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update allowTies field when provided', async () => {
|
it('should update allowTies field when provided', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user