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
195 changes: 0 additions & 195 deletions .github/workflows/ci.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/gssoc-discord-pin-reminder.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/unassign-unlinked-issues.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/welcome-first-time.yml

This file was deleted.

2 changes: 1 addition & 1 deletion apps/backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ model CardView {
viewerId String? @map("viewer_id") // null = anonymous web viewer
viewerIp String? @map("viewer_ip")
viewerAgent String? @map("viewer_agent")
source String @default("qr") // "qr" | "link" | "web" | "app"
source String @default("qr") // "qr" | "link" | "web" | "app" | "nfc"
createdAt DateTime @default(now()) @map("created_at")

card Card? @relation(fields: [cardId], references: [id], onDelete: SetNull)
Expand Down
59 changes: 43 additions & 16 deletions apps/backend/src/__tests__/analytics.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {

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

View workflow job for this annotation

GitHub Actions / backend-ci

There should be no empty line within import group
describe,
it,
expect,
Expand All @@ -7,13 +7,13 @@
vi,
} from 'vitest';

import Fastify, {

Check failure on line 10 in apps/backend/src/__tests__/analytics.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

`fastify` import should occur before import of `vitest`
type FastifyInstance,
} from 'fastify';

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

import { analyticsRoutes } from '../routes/analytics';

Check failure on line 16 in apps/backend/src/__tests__/analytics.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

`../routes/analytics` import should occur before type import of `@prisma/client`

// ─── Shared mock data ────────────────────────────────────────────────────────

Expand All @@ -34,7 +34,7 @@

// ─── App factory ─────────────────────────────────────────────────────────────

let mockJwtVerify = vi.fn();

Check failure on line 37 in apps/backend/src/__tests__/analytics.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

'mockJwtVerify' is never reassigned. Use 'const' instead

async function buildApp(): Promise<FastifyInstance> {
const app = Fastify({
Expand Down Expand Up @@ -157,22 +157,39 @@
]
);

prismaMock.cardView.groupBy.mockResolvedValue(
[
{
viewerId:
'u1',
viewerIp:
null,
},
{
viewerId:
'u2',
viewerIp:
null,
},
]
);
prismaMock.cardView.groupBy
.mockResolvedValueOnce(
[
{
viewerId:
'u1',
viewerIp:
null,
},
{
viewerId:
'u2',
viewerIp:
null,
},
]
)
.mockResolvedValueOnce(
[
{
source: 'qr',
_count: { id: 80 },
},
{
source: 'link',
_count: { id: 15 },
},
{
source: 'nfc',
_count: { id: 5 },
},
]
);

const res =
await app.inject(
Expand All @@ -188,7 +205,7 @@

expect(
res.statusCode
).toBe(200);

Check failure on line 208 in apps/backend/src/__tests__/analytics.test.ts

View workflow job for this annotation

GitHub Actions / backend-ci

src/__tests__/analytics.test.ts > Analytics API > GET /api/analytics/overview > 200 — returns analytics overview

AssertionError: expected 500 to be 200 // Object.is equality - Expected + Received - 200 + 500 ❯ src/__tests__/analytics.test.ts:208:15

const body =
res.json();
Expand All @@ -214,6 +231,16 @@
).toHaveLength(
1
);

expect(
body.viewsBySource
).toMatchObject(
{
qr: 80,
link: 15,
nfc: 5,
}
);
}
);

Expand Down
7 changes: 4 additions & 3 deletions apps/backend/src/__tests__/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { describe, it, expect, vi } from 'vitest';
import { buildApp } from '../app';

process.env.NODE_ENV = 'test';
process.env.JWT_SECRET ||= 'test-jwt-secret';
process.env.ENCRYPTION_KEY ||= 'test-encryption-key';
process.env.JWT_SECRET = 'test-jwt-secret-that-is-long-enough-for-testing';
process.env.ENCRYPTION_KEY = 'test-encryption-key-that-is-exactly-32-chars!!';
process.env.PUBLIC_APP_URL = 'http://localhost:5173';

describe('GET /health', () => {
it('should return status ok', async () => {
Expand Down Expand Up @@ -36,4 +37,4 @@ describe('request logging hook', () => {

await app.close();
});
});
});
Loading
Loading