Skip to content

Commit a5c951e

Browse files
maparentclaude
andcommitted
Add Vitest integration tests for website group invitation functions
Tests createGroup, createGroupInvitation, and acceptGroupInvitation end-to-end against the local Supabase instance. Also fixes a bug where createGroupInvitation was JSON.stringify-ing the JSONB payload, causing accept_group_invitation to silently return false. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 38045c8 commit a5c951e

4 files changed

Lines changed: 648 additions & 57 deletions

File tree

apps/website/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"start": "next start",
1212
"lint": "eslint .",
1313
"lint:fix": "eslint . --fix",
14-
"check-types": "tsc --noEmit --skipLibCheck"
14+
"check-types": "tsc --noEmit --skipLibCheck",
15+
"test:integration": "vitest run --config vitest.integration.config.ts",
16+
"test:integration:nodb": "vitest run --config vitest.integration.config.ts --tags-filter '!database'"
1517
},
1618
"dependencies": {
1719
"@repo/database": "workspace:*",
@@ -36,6 +38,8 @@
3638
},
3739
"devDependencies": {
3840
"@repo/eslint-config": "workspace:*",
41+
"dotenv": "^16.0.0",
42+
"vitest": "^4.0.0",
3943
"@repo/tailwind-config": "workspace:*",
4044
"@repo/types": "workspace:*",
4145
"@repo/typescript-config": "workspace:*",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import dotenv from "dotenv";
2+
import path from "path";
3+
4+
dotenv.config({
5+
path: path.resolve(__dirname, "../../../packages/database/.env.local"),
6+
});
7+
8+
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY =
9+
process.env.SUPABASE_PUBLISHABLE_KEY;
10+
process.env.NEXT_PUBLIC_SUPABASE_URL = process.env.SUPABASE_URL;
11+
12+
if (process.env.SUPABASE_URL?.includes("supabase.co")) {
13+
throw new Error(
14+
"Integration tests must not run against production Supabase. Check SUPABASE_URL.",
15+
);
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { defineConfig } from "vitest/config";
2+
import path from "path";
3+
4+
export default defineConfig({
5+
test: {
6+
environment: "node",
7+
include: ["test/integration/**/*.test.ts"],
8+
exclude: ["scripts/**"],
9+
setupFiles: ["test/setup.integration.ts"],
10+
sequence: { concurrent: false },
11+
pool: "forks",
12+
maxWorkers: 1,
13+
tags: [
14+
{
15+
name: "database",
16+
description: "Tests requiring the database",
17+
},
18+
],
19+
},
20+
resolve: {
21+
alias: {
22+
"~": path.resolve(__dirname, "app"),
23+
},
24+
},
25+
});

0 commit comments

Comments
 (0)