Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions apps/backend/src/__tests__/cards.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Fastify, { type FastifyInstance } from 'fastify';
import { describe, it, expect, beforeEach, vi } from 'vitest';

Check failure on line 2 in apps/backend/src/__tests__/cards.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

`fastify` import should occur before import of `vitest`

Check failure on line 2 in apps/backend/src/__tests__/cards.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

There should be at least one empty line between import groups
import Fastify from 'fastify';

import { cardRoutes } from '../routes/cards.js';

import type { PrismaClient } from '@prisma/client';

const USER_ID = 'user-123';
const CARD_ID = 'card-abc';
// Must be valid UUIDs — createCardSchema and updateCardSchema use z.string().uuid()
Expand Down Expand Up @@ -40,18 +43,18 @@
},
$transaction: vi.fn(),
};

Check warning on line 46 in apps/backend/src/__tests__/cards.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
// Re-wire $transaction before every test so that it executes the callback
// against the same mock client, preserving existing per-operation mocks.
function wireTransaction() {
function wireTransaction(): void {
mockPrisma.$transaction.mockImplementation(
async (callback: (tx: typeof mockPrisma) => Promise<unknown>) => callback(mockPrisma),
);

Check warning on line 52 in apps/backend/src/__tests__/cards.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
}

async function buildApp() {
async function buildApp():Promise<FastifyInstance> {
const app = Fastify({ logger: false });
app.decorate('prisma', mockPrisma);
app.decorate('prisma', mockPrisma as unknown as PrismaClient);
app.decorate('authenticate', async (request: any) => {
request.user = { id: USER_ID };
});
Expand Down
10 changes: 6 additions & 4 deletions apps/backend/src/__tests__/profiles.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Fastify, { type FastifyInstance } from 'fastify';
import { describe, it, expect, beforeEach, vi } from 'vitest';

Check failure on line 2 in apps/backend/src/__tests__/profiles.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

`fastify` import should occur before import of `vitest`

Check failure on line 2 in apps/backend/src/__tests__/profiles.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

There should be at least one empty line between import groups
import Fastify from 'fastify';

Check failure on line 3 in apps/backend/src/__tests__/profiles.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

There should be at least one empty line between import groups
import { profileRoutes } from '../routes/profiles.js';

import type { PrismaClient } from '@prisma/client';

const mockUser = {
Expand All @@ -20,15 +22,15 @@
providerId: 'gh-123',
};

const mockPrisma: Pick<PrismaClient, 'user'> = {
const mockPrisma = {
user: {
findUnique: vi.fn(),
findFirst: vi.fn(),
update: vi.fn(),
} as unknown as PrismaClient['user'],
},
};

Check warning on line 31 in apps/backend/src/__tests__/profiles.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function

async function buildApp() {
async function buildApp():Promise<FastifyInstance> {
const app = Fastify();
app.decorate('prisma', mockPrisma as unknown as PrismaClient);
app.decorate('authenticate', async (request: any) => {
Expand Down
5 changes: 3 additions & 2 deletions apps/backend/src/__tests__/validateEnv.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, it, expect, vi, afterEach } from 'vitest';

Check failure on line 1 in apps/backend/src/__tests__/validateEnv.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

There should be at least one empty line between import groups

import { validateEnv } from '../utils/validateEnv.js';

// ── helpers ──────────────────────────────────────────────────────────────────
Expand All @@ -7,9 +8,9 @@
* Replaces process.exit with a throwing stub for the duration of the test so
* that a failing validateEnv() call does not terminate the test process.
* Returns the spy so callers can assert the exit code.
*/

Check warning on line 11 in apps/backend/src/__tests__/validateEnv.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
function stubExit() {
return vi.spyOn(process, 'exit').mockImplementation((code?: number | string) => {
function stubExit(): ReturnType<typeof vi.spyOn> {
return vi.spyOn(process, 'exit').mockImplementation((code?: number | string | null) => {
throw new Error(`process.exit(${code})`);
}) as unknown as ReturnType<typeof vi.spyOn>;
}
Expand Down
Loading