Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 56a56e590e | |||
| 9a6188b2ae | |||
| fea0585a75 | |||
| 820b1d8d84 | |||
| 48b524ef84 | |||
| e602e83642 | |||
| ac8562ea51 | |||
| b1c4e9a0ce | |||
| 413ebaeaee | |||
| f27efebd82 | |||
| 30ea4e4e86 | |||
| 75cb6ed29d | |||
| fa13ed86c9 | |||
| 66e574d5ec | |||
| a9138cfbe4 |
@@ -52,13 +52,14 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and push CI base image
|
- name: Build and push CI base image
|
||||||
run: |
|
run: |
|
||||||
|
WORKSPACE_DIR="$GITHUB_WORKSPACE"
|
||||||
|
# Build with multiple tags
|
||||||
docker build \
|
docker build \
|
||||||
--file Dockerfile.ci-base \
|
--context "$WORKSPACE_DIR" \
|
||||||
|
--file "$WORKSPACE_DIR/Dockerfile.ci-base" \
|
||||||
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:latest \
|
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:latest \
|
||||||
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:playwright-${{ steps.meta.outputs.playwright_version }} \
|
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:playwright-${{ steps.meta.outputs.playwright_version }} \
|
||||||
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:${{ github.sha }} \
|
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/ci-base:${{ github.sha }} \
|
||||||
--push \
|
|
||||||
.
|
|
||||||
|
|
||||||
- name: Clean up
|
- name: Clean up
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ jobs:
|
|||||||
container:
|
container:
|
||||||
image: docker.notsosm.art/euchre-camp/ci-base:latest
|
image: docker.notsosm.art/euchre-camp/ci-base:latest
|
||||||
options: --user root
|
options: --user root
|
||||||
env:
|
|
||||||
DATABASE_URL: postgresql://user:pass@localhost:5432/dummy
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -27,6 +25,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Generate Prisma client
|
- name: Generate Prisma client
|
||||||
run: bun x prisma generate
|
run: bun x prisma generate
|
||||||
|
env:
|
||||||
|
DATABASE_URL: postgresql://user:pass@localhost:5432/dummy
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: bun test src/__tests__/unit/ src/__tests__/*.test.tsx src/__tests__/auth-simple.test.ts
|
run: bun test src/__tests__/unit/ src/__tests__/*.test.tsx src/__tests__/auth-simple.test.ts
|
||||||
@@ -37,9 +37,6 @@ jobs:
|
|||||||
container:
|
container:
|
||||||
image: docker.notsosm.art/euchre-camp/ci-base:latest
|
image: docker.notsosm.art/euchre-camp/ci-base:latest
|
||||||
options: --user root
|
options: --user root
|
||||||
volumes:
|
|
||||||
- /apps:/apps
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -61,12 +58,15 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Docker image for PR
|
- name: Build Docker image for PR
|
||||||
run: |
|
run: |
|
||||||
|
WORKSPACE_DIR="$GITHUB_WORKSPACE"
|
||||||
IMAGE_TAG="pr-${{ steps.info.outputs.pr_number }}-${{ steps.info.outputs.short_sha }}"
|
IMAGE_TAG="pr-${{ steps.info.outputs.pr_number }}-${{ steps.info.outputs.short_sha }}"
|
||||||
docker build \
|
docker build \
|
||||||
|
--context "$WORKSPACE_DIR" \
|
||||||
|
--file "$WORKSPACE_DIR/Dockerfile" \
|
||||||
--target runner \
|
--target runner \
|
||||||
--build-arg GIT_COMMIT=$GITHUB_SHA \
|
--build-arg GIT_COMMIT=$GITHUB_SHA \
|
||||||
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG} \
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG} \
|
||||||
.
|
"$WORKSPACE_DIR"
|
||||||
|
|
||||||
- name: Update CI site compose and restart
|
- name: Update CI site compose and restart
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -110,11 +110,14 @@ jobs:
|
|||||||
- name: Build test-capable image
|
- name: Build test-capable image
|
||||||
if: steps.commit.outputs.committed == 'true'
|
if: steps.commit.outputs.committed == 'true'
|
||||||
run: |
|
run: |
|
||||||
|
WORKSPACE_DIR="$GITHUB_WORKSPACE"
|
||||||
docker build \
|
docker build \
|
||||||
|
--context "$WORKSPACE_DIR" \
|
||||||
|
--file "$WORKSPACE_DIR/Dockerfile" \
|
||||||
--target test-runner \
|
--target test-runner \
|
||||||
--build-arg GIT_COMMIT=${{ github.sha }} \
|
--build-arg GIT_COMMIT=${{ github.sha }} \
|
||||||
-t ${{ env.IMAGE_NAME }}-test:${{ steps.version.outputs.new_version }} \
|
-t ${{ env.IMAGE_NAME }}-test:${{ steps.version.outputs.new_version }} \
|
||||||
.
|
"$WORKSPACE_DIR"
|
||||||
|
|
||||||
- name: Run tests inside test-capable container
|
- name: Run tests inside test-capable container
|
||||||
if: steps.commit.outputs.committed == 'true'
|
if: steps.commit.outputs.committed == 'true'
|
||||||
@@ -127,12 +130,15 @@ jobs:
|
|||||||
- name: Build production image
|
- name: Build production image
|
||||||
if: steps.commit.outputs.committed == 'true'
|
if: steps.commit.outputs.committed == 'true'
|
||||||
run: |
|
run: |
|
||||||
|
WORKSPACE_DIR="$GITHUB_WORKSPACE"
|
||||||
docker build \
|
docker build \
|
||||||
|
--context "$WORKSPACE_DIR" \
|
||||||
|
--file "$WORKSPACE_DIR/Dockerfile" \
|
||||||
--target runner \
|
--target runner \
|
||||||
--build-arg GIT_COMMIT=${{ github.sha }} \
|
--build-arg GIT_COMMIT=${{ github.sha }} \
|
||||||
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.new_version }} \
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.new_version }} \
|
||||||
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
|
||||||
.
|
"$WORKSPACE_DIR"
|
||||||
|
|
||||||
- name: Push Docker images
|
- name: Push Docker images
|
||||||
if: steps.commit.outputs.committed == 'true'
|
if: steps.commit.outputs.committed == 'true'
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ describe('getSession', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('returns null when an error occurs', async () => {
|
it('returns null when an error occurs', async () => {
|
||||||
mockFetch.mockRejectedValue(new Error('Network error'))
|
mockFetch.mockImplementation(async () => {
|
||||||
|
throw new Error('Network error')
|
||||||
|
})
|
||||||
|
|
||||||
const result = await getSession()
|
const result = await getSession()
|
||||||
|
|
||||||
|
|||||||
@@ -3,37 +3,17 @@
|
|||||||
* Tests the allowTies field is properly saved when updating tournaments
|
* Tests the allowTies field is properly saved when updating tournaments
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, mock, beforeEach,} from 'bun:test';
|
import { describe, it, expect, mock, beforeEach, afterAll } 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 userFindUniqueMock = mock(async () => ({
|
const canManageTournamentMock = mock(async () => ({ allowed: true }));
|
||||||
id: 'admin-1',
|
const canDeleteTournamentMock = mock(async () => ({ allowed: true }));
|
||||||
email: 'admin@example.com',
|
|
||||||
role: 'club_admin',
|
|
||||||
emailVerified: false,
|
|
||||||
name: null,
|
|
||||||
image: null,
|
|
||||||
playerId: null,
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Mock auth-simple to return a valid session
|
// Mock prisma first
|
||||||
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,
|
||||||
@@ -41,6 +21,17 @@ mock.module('@/lib/prisma', () => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Mock the permissions module
|
||||||
|
mock.module('@/lib/permissions', () => ({
|
||||||
|
canManageTournament: canManageTournamentMock,
|
||||||
|
canDeleteTournament: canDeleteTournamentMock,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Cleanup after all tests in this file
|
||||||
|
afterAll(() => {
|
||||||
|
mock.restore('module');
|
||||||
|
});
|
||||||
|
|
||||||
// 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';
|
||||||
@@ -50,7 +41,8 @@ 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();
|
||||||
userFindUniqueMock.mockClear();
|
canManageTournamentMock.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