Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat(ci): add api vitest suite

Tin621c8613dbbb
diff --git a/apps/api/package.json b/apps/api/package.json
index 7a07e04aa..d3fffbd19 100644
--- a/apps/api/package.json
+++ b/apps/api/package.json
@@ -16,6 +16,8 @@
"dev": "tsx watch src/index.ts",
"build": "esbuild src/index.ts --bundle --platform=node --outdir=dist --format=esm --packages=external --external:fs --external:path --external:crypto --external:os --external:util --external:stream --external:buffer --external:events --external:url --external:querystring --external:http --external:https --external:net --external:tls --external:zlib",
"lint": "biome check --write .",
+ "test": "vitest run --config vitest.config.ts",
+ "test:watch": "vitest --config vitest.config.ts",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:studio": "drizzle-kit studio",
@@ -50,8 +52,10 @@
"@types/bcrypt": "^6.0.0",
"@types/node": "^25.3.5",
"@types/pg": "^8.18.0",
+ "@vitest/coverage-v8": "^4.1.2",
"esbuild": "0.27.4",
"tsx": "^4.21.0",
- "typescript": "^5.9.3"
+ "typescript": "^5.9.3",
+ "vitest": "^4.1.2"
}
}
diff --git a/apps/api/src/storage/s3.ts b/apps/api/src/storage/s3.ts
index 114dd22d9..7315cfa0a 100644
--- a/apps/api/src/storage/s3.ts
+++ b/apps/api/src/storage/s3.ts
@@ -80,12 +80,12 @@ function env(name: string) {
return process.env[name]?.trim() || "";
}
-function parseBoolean(value: string | undefined, fallback: boolean) {
+export function parseBoolean(value: string | undefined, fallback: boolean) {
if (value === undefined || value.trim() === "") return fallback;
return value.trim().toLowerCase() === "true";
}
-function parsePositiveInt(value: string | undefined, fallback: number) {
+export function parsePositiveInt(value: string | undefined, fallback: number) {
const parsed = Number.parseInt(value?.trim() || "", 10);
if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
return parsed;
@@ -157,7 +157,7 @@ function getClient(config: StorageConfig) {
return client;
}
-function sanitizePathSegment(value: string) {
+export function sanitizePathSegment(value: string) {
return (
value
.toLowerCase()
@@ -167,7 +167,7 @@ function sanitizePathSegment(value: string) {
);
}
-function getFileExtension(filename: string) {
+export function getFileExtension(filename: string) {
const normalized = filename.trim();
const extension = normalized.includes(".")
? normalized.split(".").pop() || ""
@@ -176,7 +176,7 @@ function getFileExtension(filename: string) {
return sanitizePathSegment(extension).slice(0, 12);
}
-function buildObjectKeyPrefix(
+export function buildObjectKeyPrefix(
context: Omit<TaskImageUploadContext, "filename" | "contentType">,
) {
const surfaceFolder =
@@ -193,7 +193,7 @@ function buildObjectKeyPrefix(
].join("/");
}
-function buildObjectKey(context: TaskImageUploadContext) {
+export function buildObjectKey(context: TaskImageUploadContext) {
const extension = getFileExtension(context.filename);
const objectKeyPrefix = buildObjectKeyPrefix(context);
const timestamp = Date.now();
diff --git a/apps/api/vitest.config.ts b/apps/api/vitest.config.ts
new file mode 100644
index 000000000..0e0a6884e
--- /dev/null
+++ b/apps/api/vitest.config.ts
@@ -0,0 +1,17 @@
+import { defineConfig } from "vitest/config";
+
+export default defineConfig({
+ test: {
+ environment: "node",
+ include: ["../../tests/api/**/*.test.ts"],
+ coverage: {
+ enabled: true,
+ provider: "v8",
+ reporter: ["text", "html"],
+ reportsDirectory: "./coverage",
+ },
+ },
+ esbuild: {
+ target: "node18",
+ },
+});
diff --git a/package.json b/package.json
index ec0a449de..840926fbf 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo lint",
+ "test": "turbo test",
"prepare": "husky"
},
"devDependencies": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c2f0c9dc2..3169c0b28 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -68,7 +68,7 @@ importers:
version: 3.1006.0
'@better-auth/api-key':
specifier: ^1.5.6
- version: 1.5.6(b93c0fa4af19a53259adb7e86275d5df)
+ version: 1.5.6(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected](46b0902e3e8b0d276ea46bc5945b26ec))
'@better-auth/drizzle-adapter':
specifier: ^1.5.6
@@ -101,7 +101,7 @@ importers:
version: 6.0.0
better-auth:
specifier: ^1.5.5
+ version: 1.5.6(46b0902e3e8b0d276ea46bc5945b26ec)
croner:
specifier: ^10.0.1
version: 10.0.1
@@ -139,6 +139,9 @@ importers:
'@types/pg':
specifier: ^8.18.0
version: 8.18.0
+ '@vitest/coverage-v8':
+ specifier: ^4.1.2
esbuild:
specifier: 0.27.3
version: 0.27.3
@@ -148,6 +151,9 @@ importers:
typescript:
specifier: ^5.9.3
version: 5.9.3
+ vitest:
+ specifier: ^4.1.2
apps/site:
dependencies:
@@ -220,7 +226,7 @@ importers:
'@better-auth/api-key':
specifier: ^1.5.6
- version: 1.5.6(8c683fd870746335c7796e5beb9adb75)
+ version: 1.5.6(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected](54da6cb23ac19ba43ca5911132c1cbce))
'@dnd-kit/core':
specifier: ^6.3.1
@@ -370,7 +376,7 @@ importers:
version: 19.0.0-beta-ebf51a3-20250411
better-auth:
specifier: ^1.5.6
+ version: 1.5.6(54da6cb23ac19ba43ca5911132c1cbce)
class-variance-authority:
specifier: ^0.7.1
version: 0.7.1
@@ -948,6 +954,10 @@ packages:
'@types/react':
optional: true
+ resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==}
+ engines: {node: '>=18'}
+
'@better-auth/[email protected]':
resolution: {integrity: sha512-jr3m4/caFxn9BuY9pGDJ4B1HP1Qoqmyd7heBHm4KUFel+a9Whe/euROgZ/L+o7mbmUdZtreneaU15dpn0tJZ5g==}
peerDependencies:
@@ -4014,6 +4024,9 @@ packages:
resolution: {integrity: sha512-/oJGukuH3D2+D+3H4JWLaAsJ/ji86dhRidzZ/Od7H/i8g+aCmvkeCc6Ni/f9uxGLSQVCRZkX2/lqEFG2BvWtlQ==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==}
+
resolution: {integrity: sha512-BgT2szDXnVypgpNxOK8aL5SGjUdaQbC++WZNjF1Qge3Og2+zhHj+RWhmehLhYyvQwqAmvezruVfOf8+3m74W+g==}
@@ -4023,6 +4036,9 @@ packages:
resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
+
resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==}
@@ -4111,6 +4127,44 @@ packages:
peerDependencies:
vite: ^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-sPK//PHO+kAkScb8XITeB1bf7fsk85Km7+rt4eeuRR3VS1/crD47cmV5wicisJmjNdfeokTZwjMk4Mj2d58Mgg==}
+ peerDependencies:
+ '@vitest/browser': 4.1.2
+ vitest: 4.1.2
+ peerDependenciesMeta:
+ '@vitest/browser':
+ optional: true
+
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-gbu+7B0YgUJ2nkdsRJrFFW6X7NTP44WlhiclHniUhxADQJH5Szt9mZ9hWnJPJ8YwOK5zUOSSlSvyzRf0u1DSBQ==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-Ize4iQtEALHDttPRCmN+FKqOl2vxTiNUhzobQFFt/BM1lRUTG7zRCLOykG/6Vo4E4hnUdfVLo5/eqKPukcWW7Q==}
+ peerDependencies:
+ msw: ^2.4.9
+ vite: ^6.0.0 || ^7.0.0 || ^8.0.0
+ peerDependenciesMeta:
+ msw:
+ optional: true
+ vite:
+ optional: true
+
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-dwQga8aejqeuB+TvXCMzSQemvV9hNEtDDpgUKDzOmNQayl2OG241PSWeJwKRH3CiC+sESrmoFd49rfnq7T4RnA==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-Gr+FQan34CdiYAwpGJmQG8PgkyFVmARK8/xSijia3eTFgVfpcpztWLuP6FttGNfPLJhaZVP/euvujeNYar36OQ==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-g7yfUmxYS4mNxk31qbOYsSt2F4m1E02LFqO53Xpzg3zKMhLAPZAjjfyl9e6z7HrW6LvUdTwAQR3HHfLjpko16A==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-DU4fBnbVCJGNBwVA6xSToNXrkZNSiw59H8tcuUspVMsBDBST4nfvsPsEHDHGtWRRnqBERBQu7TrTKskmjqTXKA==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-xw2/TiX82lQHA06cgbqRKFb5lCAy3axQ4H4SoUFhUsg+wztiet+co86IAMDtF6Vm1hc7J6j09oh/rgDn+JdKIQ==}
+
resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==}
hasBin: true
@@ -4173,10 +4227,17 @@ packages:
resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==}
+ resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==}
engines: {node: '>=4'}
+ resolution: {integrity: sha512-1fSfIwuDICFA4LKkCzRPO7F0hzFf0B7+Xqrl27ynQaa+Rh0e1Es0v6kWHPott3lU10AyAr7oKHa65OppjLn3Rg==}
+
resolution: {integrity: sha512-+gDffFXRW6sl/HCwbta7zK4uNqbPjv4YJEAdz7Vu+FLQHe77eZ4bvbJGi4hE0QPeJlMYMA3piXEr1UL3dAwx7Q==}
@@ -4404,6 +4465,10 @@ packages:
resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}
+ resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==}
engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}
@@ -4899,6 +4964,9 @@ packages:
resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==}
+
resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==}
engines: {node: '>= 0.4'}
@@ -4932,6 +5000,9 @@ packages:
resolution: {integrity: sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==}
+ resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
+
resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
engines: {node: '>= 0.6'}
@@ -4955,6 +5026,10 @@ packages:
resolution: {integrity: sha512-9Be3ZoN4LmYR90tUoVu2te2BsbzHfhJyfEiAVfz7N5/zv+jduIfLrV2xdQXOHbaD6KgpGdO9PRPM1Y4Q9QkPkA==}
engines: {node: ^18.19.0 || >=20.5.0}
+ resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==}
+ engines: {node: '>=12.0.0'}
+
resolution: {integrity: sha512-Ybv7bqtOgA914MLwaHWVFXMpMYeR1MQu/D+z2MaLYteqBsTIp9sY3AU7mGNLMJv8eLg8uQMpE20I+L2Lv49nSg==}
engines: {node: '>= 16'}
@@ -5182,6 +5257,10 @@ packages:
resolution: {integrity: sha512-DKKrynuQRne0PNpEbzuEdHlYOMksHSUI8Zc9Unei5gTsMNA2/vMpoMz/yKba50pejK56qj98qM0SjYxAKi13gQ==}
engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0}
+ resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
+ engines: {node: '>=8'}
+
resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==}
engines: {node: '>= 0.4'}
@@ -5225,6 +5304,9 @@ packages:
resolution: {integrity: sha512-jq9l1DM0zVIvsm3lv9Nw9nlJnMNPOcAtsbsgiUhWcFzPE99Gvo6yRTlszSLLYacMeQ6quHD6hMfId8crVHvexw==}
engines: {node: '>=16.9.0'}
+ resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==}
+
resolution: {integrity: sha512-qY60FjREgVZL03vJU6IfMV4GDjGBIoOyvuFdpBDIX9yTlDw0TjxVBQp+P8NvpdIXNJvfWBTNul7fsAQJq2FNpg==}
engines: {node: '>=14'}
@@ -5417,6 +5499,18 @@ packages:
resolution: {integrity: sha512-6B3tLtFqtQS4ekarvLVMZ+X+VlvQekbe4taUkf/rhVO3d/h0M2rfARm/pXLcPEsjjMsFgrFgSrhQIxcSVrBz8w==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==}
+ engines: {node: '>=8'}
+
+ resolution: {integrity: sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==}
+ engines: {node: '>=10'}
+
+ resolution: {integrity: sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==}
+ engines: {node: '>=8'}
+
resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==}
hasBin: true
@@ -5428,6 +5522,9 @@ packages:
resolution: {integrity: sha512-0TpaTfihd4QMNwrz/ob2Bp7X04yuxJkjRGi4aKmOqwhov54i6u79oCv7T+C7lo70MKH6BesI3vscD1yb/yzKXQ==}
+ resolution: {integrity: sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==}
+
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
@@ -5712,6 +5809,13 @@ packages:
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
+ resolution: {integrity: sha512-E3ZJh4J3S9KfwdjZhe2afj6R9lGIN5Pher1pF39UGrXRqq/VDaGVIGN13BjHd2u8B61hArAGOnso7nBOouW3TQ==}
+
+ resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==}
+ engines: {node: '>=10'}
+
resolution: {integrity: sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==}
hasBin: true
@@ -6063,6 +6167,9 @@ packages:
resolution: {integrity: sha512-EFVjAYfzWqWsBMRHPMAXLCDIJnpMhdWAqR7xG6M6a2cs6PMFpl/+Z20w9zDW4vkxOFfddegBKq9Rehd0bxWE7A==}
engines: {node: '>= 10'}
+ resolution: {integrity: sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==}
+
resolution: {integrity: sha512-4+/OFSqOjoyULo7eN7EA97DE0Xydj/PW5aIckxqQIoFjFwqXKuFCvXUJObyJfBF9Khu4RL/jlDRI9FPaMGfPnw==}
engines: {node: '>= 20'}
@@ -6682,6 +6789,9 @@ packages:
resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
+
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
@@ -6741,6 +6851,9 @@ packages:
resolution: {integrity: sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==}
engines: {node: '>= 0.6'}
+ resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
+
resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==}
engines: {node: '>= 0.8'}
@@ -6748,6 +6861,9 @@ packages:
resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==}
+ resolution: {integrity: sha512-zUMPtQ/HBY3/50VbpkupYHbRroTRZJPRLvreamgErJVys0ceuzMkD44J/QjqhHjOzK42GQ3QZIeFG1OYfOtKqQ==}
+
resolution: {integrity: sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==}
engines: {node: '>=18'}
@@ -6821,6 +6937,10 @@ packages:
babel-plugin-macros:
optional: true
+ resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
+ engines: {node: '>=8'}
+
resolution: {integrity: sha512-05PUHKSNE8ou2dwIxTngl4EzcnsCDZGJ/iCLtDflR/SHB/ny14rXc+qU5P4mG9JkusiV7EivzY9Mhm55AzAvCg==}
@@ -6874,6 +6994,9 @@ packages:
resolution: {integrity: sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==}
+ resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
+
resolution: {integrity: sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==}
engines: {node: '>=18'}
@@ -6886,6 +7009,10 @@ packages:
resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
engines: {node: '>=12.0.0'}
+ resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==}
+ engines: {node: '>=14.0.0'}
+
resolution: {integrity: sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ==}
@@ -7154,6 +7281,41 @@ packages:
yaml:
optional: true
+ resolution: {integrity: sha512-xjR1dMTVHlFLh98JE3i/f/WePqJsah4A0FK9cc8Ehp9Udk0AZk6ccpIZhh1qJ/yxVWRZ+Q54ocnD8TXmkhspGg==}
+ engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0}
+ hasBin: true
+ peerDependencies:
+ '@edge-runtime/vm': '*'
+ '@opentelemetry/api': ^1.9.0
+ '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0
+ '@vitest/browser-playwright': 4.1.2
+ '@vitest/browser-preview': 4.1.2
+ '@vitest/browser-webdriverio': 4.1.2
+ '@vitest/ui': 4.1.2
+ happy-dom: '*'
+ jsdom: '*'
+ vite: ^6.0.0 || ^7.0.0 || ^8.0.0
+ peerDependenciesMeta:
+ '@edge-runtime/vm':
+ optional: true
+ '@opentelemetry/api':
+ optional: true
+ '@types/node':
+ optional: true
+ '@vitest/browser-playwright':
+ optional: true
+ '@vitest/browser-preview':
+ optional: true
+ '@vitest/browser-webdriverio':
+ optional: true
+ '@vitest/ui':
+ optional: true
+ happy-dom:
+ optional: true
+ jsdom:
+ optional: true
+
resolution: {integrity: sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==}
@@ -7185,6 +7347,11 @@ packages:
engines: {node: ^16.13.0 || >=18.0.0}
hasBin: true
+ resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
+ engines: {node: '>=8'}
+ hasBin: true
+
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
engines: {node: '>=8'}
@@ -8088,18 +8255,20 @@ snapshots:
optionalDependencies:
'@types/react': 19.2.14
- '@better-auth/[email protected](8c683fd870746335c7796e5beb9adb75)':
+ '@bcoe/[email protected]': {}
+
dependencies:
'@better-auth/utils': 0.3.1
+ better-auth: 1.5.6(46b0902e3e8b0d276ea46bc5945b26ec)
zod: 4.3.6
- '@better-auth/[email protected](b93c0fa4af19a53259adb7e86275d5df)':
dependencies:
'@better-auth/utils': 0.3.1
+ better-auth: 1.5.6(54da6cb23ac19ba43ca5911132c1cbce)
zod: 4.3.6
@@ -8639,6 +8808,22 @@ snapshots:
optionalDependencies:
'@types/node': 25.2.3
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@inquirer/core': 10.3.2(@types/[email protected])
+ '@inquirer/type': 3.0.10(@types/[email protected])
+ optionalDependencies:
+ '@types/node': 25.4.0
+ optional: true
+
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@inquirer/core': 10.3.2(@types/[email protected])
+ '@inquirer/type': 3.0.10(@types/[email protected])
+ optionalDependencies:
+ '@types/node': 25.5.0
+ optional: true
+
dependencies:
'@inquirer/ansi': 1.0.2
@@ -8652,12 +8837,50 @@ snapshots:
optionalDependencies:
'@types/node': 25.2.3
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@inquirer/ansi': 1.0.2
+ '@inquirer/figures': 1.0.15
+ '@inquirer/type': 3.0.10(@types/[email protected])
+ cli-width: 4.1.0
+ mute-stream: 2.0.0
+ signal-exit: 4.1.0
+ wrap-ansi: 6.2.0
+ yoctocolors-cjs: 2.1.3
+ optionalDependencies:
+ '@types/node': 25.4.0
+ optional: true
+
+ '@inquirer/[email protected](@types/[email protected])':
+ dependencies:
+ '@inquirer/ansi': 1.0.2
+ '@inquirer/figures': 1.0.15
+ '@inquirer/type': 3.0.10(@types/[email protected])
+ cli-width: 4.1.0
+ mute-stream: 2.0.0
+ signal-exit: 4.1.0
+ wrap-ansi: 6.2.0
+ yoctocolors-cjs: 2.1.3
+ optionalDependencies:
+ '@types/node': 25.5.0
+ optional: true
+
'@inquirer/[email protected]': {}
optionalDependencies:
'@types/node': 25.2.3
+ '@inquirer/[email protected](@types/[email protected])':
+ optionalDependencies:
+ '@types/node': 25.4.0
+ optional: true
+
+ '@inquirer/[email protected](@types/[email protected])':
+ optionalDependencies:
+ '@types/node': 25.5.0
+ optional: true
+
'@jridgewell/[email protected]':
dependencies:
'@jridgewell/sourcemap-codec': 1.5.5
@@ -11964,6 +12187,11 @@ snapshots:
dependencies:
'@types/node': 25.4.0
+ '@types/[email protected]':
+ dependencies:
+ '@types/deep-eql': 4.0.2
+ assertion-error: 2.0.1
+
dependencies:
'@types/node': 25.5.0
@@ -11976,6 +12204,8 @@ snapshots:
dependencies:
'@types/ms': 2.1.0
+ '@types/[email protected]': {}
+
dependencies:
'@types/estree': 1.0.8
@@ -12071,6 +12301,72 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ '@bcoe/v8-coverage': 1.0.2
+ '@vitest/utils': 4.1.2
+ ast-v8-to-istanbul: 1.0.0
+ istanbul-lib-coverage: 3.2.2
+ istanbul-lib-report: 3.0.1
+ istanbul-reports: 3.2.0
+ magicast: 0.5.2
+ obug: 2.1.1
+ std-env: 4.0.0
+ tinyrainbow: 3.1.0
+
+ '@vitest/[email protected]':
+ dependencies:
+ '@standard-schema/spec': 1.1.0
+ '@types/chai': 5.2.3
+ '@vitest/spy': 4.1.2
+ '@vitest/utils': 4.1.2
+ chai: 6.2.2
+ tinyrainbow: 3.1.0
+
+ dependencies:
+ '@vitest/spy': 4.1.2
+ estree-walker: 3.0.3
+ magic-string: 0.30.21
+ optionalDependencies:
+ msw: 2.12.10(@types/[email protected])([email protected])
+
+ dependencies:
+ '@vitest/spy': 4.1.2
+ estree-walker: 3.0.3
+ magic-string: 0.30.21
+ optionalDependencies:
+ msw: 2.12.10(@types/[email protected])([email protected])
+ optional: true
+
+ '@vitest/[email protected]':
+ dependencies:
+ tinyrainbow: 3.1.0
+
+ '@vitest/[email protected]':
+ dependencies:
+ '@vitest/utils': 4.1.2
+ pathe: 2.0.3
+
+ '@vitest/[email protected]':
+ dependencies:
+ '@vitest/pretty-format': 4.1.2
+ '@vitest/utils': 4.1.2
+ magic-string: 0.30.21
+ pathe: 2.0.3
+
+ '@vitest/[email protected]': {}
+
+ '@vitest/[email protected]':
+ dependencies:
+ '@vitest/pretty-format': 4.1.2
+ convert-source-map: 2.0.0
+ tinyrainbow: 3.1.0
+
dependencies:
jsonparse: 1.3.1
@@ -12124,10 +12420,18 @@ snapshots:
+
dependencies:
tslib: 2.8.1
+ dependencies:
+ '@jridgewell/trace-mapping': 0.3.31
+ estree-walker: 3.0.3
+ js-tokens: 10.0.0
+
dependencies:
stubborn-fs: 2.0.0
@@ -12205,14 +12509,14 @@ snapshots:
+ [email protected](46b0902e3e8b0d276ea46bc5945b26ec):
dependencies:
'@better-auth/memory-adapter': 1.5.6(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
'@better-auth/utils': 0.3.1
'@better-fetch/fetch': 1.1.21
@@ -12225,29 +12529,30 @@ snapshots:
nanostores: 1.1.1
zod: 4.3.6
optionalDependencies:
drizzle-kit: 0.31.9
mongodb: 7.1.0
mysql2: 3.15.3
pg: 8.20.0
react: 19.2.4
react-dom: 19.2.4([email protected])
solid-js: 1.9.10
transitivePeerDependencies:
- '@cloudflare/workers-types'
- '@opentelemetry/api'
+ [email protected](54da6cb23ac19ba43ca5911132c1cbce):
dependencies:
'@better-auth/memory-adapter': 1.5.6(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])
'@better-auth/utils': 0.3.1
'@better-fetch/fetch': 1.1.21
@@ -12260,17 +12565,18 @@ snapshots:
nanostores: 1.1.1
zod: 4.3.6
optionalDependencies:
drizzle-kit: 0.31.9
mongodb: 7.1.0
mysql2: 3.15.3
pg: 8.20.0
react: 19.2.4
react-dom: 19.2.4([email protected])
solid-js: 1.9.10
transitivePeerDependencies:
- '@cloudflare/workers-types'
- '@opentelemetry/api'
@@ -12365,6 +12671,8 @@ snapshots:
+
@@ -12762,6 +13070,8 @@ snapshots:
+
dependencies:
es-errors: 1.3.0
@@ -12812,6 +13122,10 @@ snapshots:
+ dependencies:
+ '@types/estree': 1.0.8
+
@@ -12853,6 +13167,8 @@ snapshots:
strip-final-newline: 4.0.0
yoctocolors: 2.1.2
+
dependencies:
express: 5.2.1
@@ -13103,6 +13419,8 @@ snapshots:
+
@@ -13163,6 +13481,8 @@ snapshots:
+
dependencies:
'@selderee/plugin-htmlparser2': 0.11.0
@@ -13310,12 +13630,27 @@ snapshots:
+
+ dependencies:
+ istanbul-lib-coverage: 3.2.2
+ make-dir: 4.0.0
+ supports-color: 7.2.0
+
+ dependencies:
+ html-escaper: 2.0.2
+ istanbul-lib-report: 3.0.1
+
+
@@ -13524,6 +13859,16 @@ snapshots:
dependencies:
'@jridgewell/sourcemap-codec': 1.5.5
+ dependencies:
+ '@babel/parser': 7.29.0
+ '@babel/types': 7.29.0
+ source-map-js: 1.2.1
+
+ dependencies:
+ semver: 7.7.4
+
dependencies:
argparse: 2.0.1
@@ -13851,6 +14196,58 @@ snapshots:
transitivePeerDependencies:
- '@types/node'
+ dependencies:
+ '@inquirer/confirm': 5.1.21(@types/[email protected])
+ '@mswjs/interceptors': 0.41.3
+ '@open-draft/deferred-promise': 2.2.0
+ '@types/statuses': 2.0.6
+ cookie: 1.1.1
+ graphql: 16.12.0
+ headers-polyfill: 4.0.3
+ is-node-process: 1.2.0
+ outvariant: 1.4.3
+ path-to-regexp: 6.3.0
+ picocolors: 1.1.1
+ rettime: 0.10.1
+ statuses: 2.0.2
+ strict-event-emitter: 0.5.1
+ tough-cookie: 6.0.0
+ type-fest: 5.3.1
+ until-async: 3.0.2
+ yargs: 17.7.2
+ optionalDependencies:
+ typescript: 5.9.3
+ transitivePeerDependencies:
+ - '@types/node'
+ optional: true
+
+ dependencies:
+ '@inquirer/confirm': 5.1.21(@types/[email protected])
+ '@mswjs/interceptors': 0.41.3
+ '@open-draft/deferred-promise': 2.2.0
+ '@types/statuses': 2.0.6
+ cookie: 1.1.1
+ graphql: 16.12.0
+ headers-polyfill: 4.0.3
+ is-node-process: 1.2.0
+ outvariant: 1.4.3
+ path-to-regexp: 6.3.0
+ picocolors: 1.1.1
+ rettime: 0.10.1
+ statuses: 2.0.2
+ strict-event-emitter: 0.5.1
+ tough-cookie: 6.0.0
+ type-fest: 5.3.1
+ until-async: 3.0.2
+ yargs: 17.7.2
+ optionalDependencies:
+ typescript: 5.8.3
+ transitivePeerDependencies:
+ - '@types/node'
+ optional: true
+
@@ -14006,6 +14403,8 @@ snapshots:
+
dependencies:
'@octokit/app': 16.1.2
@@ -14986,6 +15385,8 @@ snapshots:
side-channel-map: 1.0.1
side-channel-weakmap: 1.0.2
+
@@ -15057,11 +15458,15 @@ snapshots:
optional: true
+
optional: true
+
@@ -15148,6 +15553,10 @@ snapshots:
client-only: 0.0.1
react: 19.2.4
+ dependencies:
+ has-flag: 4.0.0
+
@@ -15203,6 +15612,8 @@ snapshots:
+
@@ -15212,6 +15623,8 @@ snapshots:
fdir: 6.5.0([email protected])
picomatch: 4.0.3
+
dependencies:
'@popperjs/core': 2.11.8
@@ -15443,6 +15856,22 @@ snapshots:
'@types/unist': 3.0.3
vfile-message: 4.0.3
+ dependencies:
+ esbuild: 0.27.3
+ fdir: 6.5.0([email protected])
+ picomatch: 4.0.3
+ postcss: 8.5.8
+ rollup: 4.59.0
+ tinyglobby: 0.2.15
+ optionalDependencies:
+ '@types/node': 25.4.0
+ fsevents: 2.3.3
+ jiti: 2.6.1
+ lightningcss: 1.31.1
+ tsx: 4.21.0
+ yaml: 2.8.2
+
dependencies:
esbuild: 0.27.3
@@ -15459,6 +15888,63 @@ snapshots:
tsx: 4.21.0
yaml: 2.8.2
+ dependencies:
+ '@vitest/expect': 4.1.2
+ '@vitest/pretty-format': 4.1.2
+ '@vitest/runner': 4.1.2
+ '@vitest/snapshot': 4.1.2
+ '@vitest/spy': 4.1.2
+ '@vitest/utils': 4.1.2
+ es-module-lexer: 2.0.0
+ expect-type: 1.3.0
+ magic-string: 0.30.21
+ obug: 2.1.1
+ pathe: 2.0.3
+ picomatch: 4.0.3
+ std-env: 4.0.0
+ tinybench: 2.9.0
+ tinyexec: 1.0.4
+ tinyglobby: 0.2.15
+ tinyrainbow: 3.1.0
+ why-is-node-running: 2.3.0
+ optionalDependencies:
+ '@opentelemetry/api': 1.9.0
+ '@types/node': 25.4.0
+ transitivePeerDependencies:
+ - msw
+
+ dependencies:
+ '@vitest/expect': 4.1.2
+ '@vitest/pretty-format': 4.1.2
+ '@vitest/runner': 4.1.2
+ '@vitest/snapshot': 4.1.2
+ '@vitest/spy': 4.1.2
+ '@vitest/utils': 4.1.2
+ es-module-lexer: 2.0.0
+ expect-type: 1.3.0
+ magic-string: 0.30.21
+ obug: 2.1.1
+ pathe: 2.0.3
+ picomatch: 4.0.3
+ std-env: 4.0.0
+ tinybench: 2.9.0
+ tinyexec: 1.0.4
+ tinyglobby: 0.2.15
+ tinyrainbow: 3.1.0
+ why-is-node-running: 2.3.0
+ optionalDependencies:
+ '@opentelemetry/api': 1.9.0
+ '@types/node': 25.5.0
+ transitivePeerDependencies:
+ - msw
+ optional: true
+
@@ -15484,6 +15970,11 @@ snapshots:
dependencies:
isexe: 3.1.5
+ dependencies:
+ siginfo: 2.0.0
+ stackback: 0.0.2
+
dependencies:
ansi-styles: 4.3.0
diff --git a/tests/api/plugins/github/config.test.ts b/tests/api/plugins/github/config.test.ts
new file mode 100644
index 000000000..103c29241
--- /dev/null
+++ b/tests/api/plugins/github/config.test.ts
@@ -0,0 +1,49 @@
+import { describe, expect, it } from "vitest";
+import {
+ branchPatterns,
+ getDefaultConfig,
+ validateGitHubConfig,
+} from "../../../../apps/api/src/plugins/github/config";
+
+describe("github config", () => {
+ it("exposes the supported branch patterns", () => {
+ expect(branchPatterns).toContain("{slug}-{number}");
+ expect(branchPatterns).toContain("fix/{number}-{title}");
+ });
+
+ it("builds default config values", () => {
+ expect(getDefaultConfig("usekaneo", "kaneo", 42)).toEqual({
+ repositoryOwner: "usekaneo",
+ repositoryName: "kaneo",
+ installationId: 42,
+ branchPattern: "{slug}-{number}",
+ commentTaskLinkOnGitHubIssue: true,
+ statusTransitions: {
+ onBranchPush: "in-progress",
+ onPROpen: "in-review",
+ onPRMerge: "done",
+ },
+ });
+ });
+
+ it("validates valid config", async () => {
+ await expect(
+ validateGitHubConfig({
+ repositoryOwner: "usekaneo",
+ repositoryName: "kaneo",
+ installationId: 42,
+ branchPattern: "{slug}-{number}",
+ }),
+ ).resolves.toEqual({ valid: true });
+ });
+
+ it("reports validation errors for invalid config", async () => {
+ const result = await validateGitHubConfig({
+ repositoryOwner: "usekaneo",
+ installationId: "bad",
+ });
+
+ expect(result.valid).toBe(false);
+ expect(result.errors?.length).toBeGreaterThan(0);
+ });
+});
diff --git a/tests/api/plugins/github/utils/branch-matcher.test.ts b/tests/api/plugins/github/utils/branch-matcher.test.ts
new file mode 100644
index 000000000..3123c3dfe
--- /dev/null
+++ b/tests/api/plugins/github/utils/branch-matcher.test.ts
@@ -0,0 +1,135 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import type { GitHubConfig } from "../../../../../apps/api/src/plugins/github/config";
+import {
+ createBranchRegex,
+ extractTaskNumber,
+ extractTaskNumberFromBranch,
+ extractTaskNumberFromPRBody,
+ extractTaskNumberFromPRTitle,
+ generateBranchName,
+} from "../../../../../apps/api/src/plugins/github/utils/branch-matcher";
+
+const baseConfig: GitHubConfig = {
+ repositoryOwner: "kaneo",
+ repositoryName: "api",
+ installationId: 1,
+ branchPattern: "{slug}-{number}",
+};
+
+afterEach(() => {
+ vi.restoreAllMocks();
+});
+
+describe("generateBranchName", () => {
+ it("fills placeholders and slugifies the title", () => {
+ expect(
+ generateBranchName(
+ "feature/{slug}-{number}-{title}",
+ "KAN",
+ 42,
+ "Fix login: SSO + invites",
+ ),
+ ).toBe("feature/kan-42-fix-login-sso-invites");
+ });
+});
+
+describe("createBranchRegex", () => {
+ it("matches default patterns and optional suffixes", () => {
+ const regex = createBranchRegex("{slug}-{number}-{title}", "KAN");
+
+ expect(regex.test("kan-7-polish-sidebar")).toBe(true);
+ expect(regex.test("kan-7-polish-sidebar-part-2")).toBe(true);
+ expect(regex.test("ops-7-polish-sidebar")).toBe(false);
+ });
+});
+
+describe("extractTaskNumberFromBranch", () => {
+ it("uses the default branch pattern", () => {
+ expect(
+ extractTaskNumberFromBranch("kan-17-refine-search", baseConfig, "KAN"),
+ ).toBe(17);
+ });
+
+ it("supports custom regex patterns", () => {
+ expect(
+ extractTaskNumberFromBranch(
+ "feature/TASK-33",
+ {
+ ...baseConfig,
+ customBranchRegex: "TASK-(\\d+)",
+ },
+ "KAN",
+ ),
+ ).toBe(33);
+ });
+
+ it("returns null and logs when the custom regex is invalid", () => {
+ const consoleError = vi
+ .spyOn(console, "error")
+ .mockImplementation(() => undefined);
+
+ expect(
+ extractTaskNumberFromBranch(
+ "feature/TASK-33",
+ {
+ ...baseConfig,
+ customBranchRegex: "(",
+ },
+ "KAN",
+ ),
+ ).toBeNull();
+ expect(consoleError).toHaveBeenCalledOnce();
+ });
+});
+
+describe("extractTaskNumberFromPRTitle", () => {
+ it("recognizes supported title formats", () => {
+ expect(extractTaskNumberFromPRTitle("[12] Ship notifications")).toBe(12);
+ expect(extractTaskNumberFromPRTitle("Fix sidebar (#34)")).toBe(34);
+ expect(extractTaskNumberFromPRTitle("55: tidy auth flow")).toBe(55);
+ });
+});
+
+describe("extractTaskNumberFromPRBody", () => {
+ it("recognizes task references in the body", () => {
+ expect(extractTaskNumberFromPRBody("Closes #21")).toBe(21);
+ expect(extractTaskNumberFromPRBody("task: 77")).toBe(77);
+ expect(extractTaskNumberFromPRBody("No linked task")).toBeNull();
+ });
+});
+
+describe("extractTaskNumber", () => {
+ it("prefers the branch match before title and body", () => {
+ expect(
+ extractTaskNumber(
+ "kan-88-polish-editor",
+ "[12] Ship notifications",
+ "Closes #21",
+ baseConfig,
+ "KAN",
+ ),
+ ).toBe(88);
+ });
+
+ it("falls back to the title and then body", () => {
+ expect(
+ extractTaskNumber(
+ "misc-branch",
+ "[12] Ship notifications",
+ "Closes #21",
+ baseConfig,
+ "KAN",
+ ),
+ ).toBe(12);
+
+ expect(
+ extractTaskNumber(
+ "misc-branch",
+ undefined,
+ "Resolves task 21",
+ baseConfig,
+ "KAN",
+ ),
+ ).toBe(21);
+ });
+});
diff --git a/tests/api/plugins/github/utils/extract-priority.test.ts b/tests/api/plugins/github/utils/extract-priority.test.ts
new file mode 100644
index 000000000..32baa1242
--- /dev/null
+++ b/tests/api/plugins/github/utils/extract-priority.test.ts
@@ -0,0 +1,44 @@
+import { describe, expect, it } from "vitest";
+import {
+ extractIssuePriority,
+ extractIssueStatus,
+} from "../../../../../apps/api/src/plugins/github/utils/extract-priority";
+
+describe("extractIssuePriority", () => {
+ it("returns the first valid priority label", () => {
+ expect(
+ extractIssuePriority([
+ "type:bug",
+ { name: "priority:high" },
+ "priority:low",
+ ]),
+ ).toBe("high");
+ });
+
+ it("returns null for missing or malformed priority labels", () => {
+ expect(extractIssuePriority(undefined)).toBeNull();
+ expect(extractIssuePriority(["priority:critical"])).toBeNull();
+ expect(extractIssuePriority([{ name: "type:feature" }])).toBeNull();
+ });
+
+ it("treats case-sensitive malformed labels as invalid", () => {
+ expect(
+ extractIssuePriority(["Priority:high", "priority:URGENT"]),
+ ).toBeNull();
+ });
+});
+
+describe("extractIssueStatus", () => {
+ it("normalizes whitespace and casing", () => {
+ expect(
+ extractIssueStatus(["kind:feature", { name: "status: In-Review " }]),
+ ).toBe("in-review");
+ });
+
+ it("returns null for missing labels or invalid slugs", () => {
+ expect(extractIssueStatus(undefined)).toBeNull();
+ expect(extractIssueStatus([{ name: "priority:high" }])).toBeNull();
+ expect(extractIssueStatus(["status:Needs Review"])).toBeNull();
+ expect(extractIssueStatus(["status:review!"])).toBeNull();
+ });
+});
diff --git a/tests/api/plugins/github/utils/format.test.ts b/tests/api/plugins/github/utils/format.test.ts
new file mode 100644
index 000000000..5970ea345
--- /dev/null
+++ b/tests/api/plugins/github/utils/format.test.ts
@@ -0,0 +1,37 @@
+import { describe, expect, it } from "vitest";
+import {
+ formatIssueBody,
+ formatIssueTitle,
+ formatSyncComment,
+ formatTaskDescriptionFromIssue,
+ getLabelsForIssue,
+} from "../../../../../apps/api/src/plugins/github/utils/format";
+
+describe("github format helpers", () => {
+ it("returns the title unchanged", () => {
+ expect(formatIssueTitle("Ship notifications")).toBe("Ship notifications");
+ });
+
+ it("formats issue bodies with and without a description", () => {
+ expect(formatIssueBody(null, "task_123")).toBe("<sub>Task: task_123</sub>");
+ expect(formatIssueBody("Body text", "task_123")).toBe(`Body text
+
+---
+<sub>Task: task_123</sub>`);
+ });
+
+ it("formats sync comments and task descriptions", () => {
+ expect(formatSyncComment("task_123")).toBe("Task: task_123");
+ expect(formatTaskDescriptionFromIssue("Issue body")).toBe("Issue body");
+ expect(formatTaskDescriptionFromIssue(null)).toBe("");
+ });
+
+ it("builds labels while skipping no-priority", () => {
+ expect(getLabelsForIssue("high", "in-review")).toEqual([
+ "priority:high",
+ "status:in-review",
+ ]);
+ expect(getLabelsForIssue("no-priority", "done")).toEqual(["status:done"]);
+ expect(getLabelsForIssue(null, "planned")).toEqual(["status:planned"]);
+ });
+});
diff --git a/tests/api/plugins/github/utils/labels.test.ts b/tests/api/plugins/github/utils/labels.test.ts
new file mode 100644
index 000000000..8fc5cde6b
--- /dev/null
+++ b/tests/api/plugins/github/utils/labels.test.ts
@@ -0,0 +1,74 @@
+import { describe, expect, it, vi } from "vitest";
+import {
+ addLabelsToIssue,
+ ensureLabelsExist,
+ getLabelColor,
+ removeLabel,
+} from "../../../../../apps/api/src/plugins/github/utils/labels";
+
+function createOctokitMock() {
+ return {
+ rest: {
+ issues: {
+ getLabel: vi.fn(),
+ createLabel: vi.fn(),
+ addLabels: vi.fn(),
+ removeLabel: vi.fn(),
+ },
+ },
+ };
+}
+
+describe("github labels helpers", () => {
+ it("returns explicit and fallback colors", () => {
+ expect(getLabelColor("priority:urgent")).toBe("EF4444");
+ expect(getLabelColor("status:done")).toBe("10B981");
+ expect(getLabelColor("custom:label")).toBe("6B7280");
+ });
+
+ it("creates missing labels only when needed", async () => {
+ const octokit = createOctokitMock();
+ octokit.rest.issues.getLabel
+ .mockResolvedValueOnce({})
+ .mockRejectedValueOnce(new Error("missing"));
+
+ await ensureLabelsExist(octokit as never, "usekaneo", "kaneo", [
+ "status:done",
+ "priority:high",
+ ]);
+
+ expect(octokit.rest.issues.getLabel).toHaveBeenCalledTimes(2);
+ expect(octokit.rest.issues.createLabel).toHaveBeenCalledWith({
+ owner: "usekaneo",
+ repo: "kaneo",
+ name: "priority:high",
+ color: "F97316",
+ });
+ });
+
+ it("adds labels after ensuring they exist", async () => {
+ const octokit = createOctokitMock();
+ octokit.rest.issues.getLabel.mockResolvedValue({});
+
+ await addLabelsToIssue(octokit as never, "usekaneo", "kaneo", 12, [
+ "priority:low",
+ "status:done",
+ ]);
+
+ expect(octokit.rest.issues.addLabels).toHaveBeenCalledWith({
+ owner: "usekaneo",
+ repo: "kaneo",
+ issue_number: 12,
+ labels: ["priority:low", "status:done"],
+ });
+ });
+
+ it("swallows label removal errors", async () => {
+ const octokit = createOctokitMock();
+ octokit.rest.issues.removeLabel.mockRejectedValue(new Error("gone"));
+
+ await expect(
+ removeLabel(octokit as never, "usekaneo", "kaneo", 21, "status:done"),
+ ).resolves.toBeUndefined();
+ });
+});
diff --git a/tests/api/storage/s3.test.ts b/tests/api/storage/s3.test.ts
new file mode 100644
index 000000000..e037eb651
--- /dev/null
+++ b/tests/api/storage/s3.test.ts
@@ -0,0 +1,101 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import {
+ assertTaskImageKeyMatchesContext,
+ buildObjectKey,
+ buildObjectKeyPrefix,
+ getFileExtension,
+ isImageContentType,
+ parseBoolean,
+ parsePositiveInt,
+ sanitizePathSegment,
+ validateTaskAssetUploadInput,
+} from "../../../apps/api/src/storage/s3";
+
+describe("S3 helpers", () => {
+ const originalMaxSize = process.env.S3_MAX_IMAGE_UPLOAD_BYTES;
+
+ beforeEach(() => {
+ delete process.env.S3_MAX_IMAGE_UPLOAD_BYTES;
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ if (originalMaxSize === undefined) {
+ delete process.env.S3_MAX_IMAGE_UPLOAD_BYTES;
+ return;
+ }
+
+ process.env.S3_MAX_IMAGE_UPLOAD_BYTES = originalMaxSize;
+ });
+
+ it("recognizes allowed image content types case-insensitively", () => {
+ expect(isImageContentType("IMAGE/PNG")).toBe(true);
+ expect(isImageContentType("text/plain")).toBe(false);
+ });
+
+ it("parses booleans and positive integers with fallbacks", () => {
+ expect(parseBoolean(undefined, true)).toBe(true);
+ expect(parseBoolean(" false ", true)).toBe(false);
+ expect(parsePositiveInt("42", 10)).toBe(42);
+ expect(parsePositiveInt("0", 10)).toBe(10);
+ expect(parsePositiveInt("nope", 10)).toBe(10);
+ });
+
+ it("sanitizes path segments and extracts normalized extensions", () => {
+ expect(sanitizePathSegment(" Release Notes!!.PNG ")).toBe(
+ "release-notes-.png",
+ );
+ expect(sanitizePathSegment("")).toBe("file");
+ expect(getFileExtension("Screenshot.Final.PNG")).toBe("png");
+ expect(getFileExtension("README")).toBe("file");
+ });
+
+ it("builds stable key prefixes and keys", () => {
+ vi.spyOn(Date, "now").mockReturnValue(1_717_171_717_000);
+
+ const key = buildObjectKey({
+ workspaceId: "Workspace 1",
+ projectId: "Project 2",
+ taskId: "Task 3",
+ surface: "comment",
+ filename: "Sprint Plan Final!!.PNG",
+ contentType: "image/png",
+ });
+
+ expect(
+ buildObjectKeyPrefix({
+ workspaceId: "Workspace 1",
+ projectId: "Project 2",
+ taskId: "Task 3",
+ surface: "comment",
+ }),
+ ).toBe("workspace/workspace-1/project/project-2/task/task-3/comments");
+
+ expect(key).toMatch(
+ /^workspace\/workspace-1\/project\/project-2\/task\/task-3\/comments\/sprint-plan-final-1717171717000-[a-z0-9]+\.png$/,
+ );
+ expect(
+ assertTaskImageKeyMatchesContext(key, {
+ workspaceId: "Workspace 1",
+ projectId: "Project 2",
+ taskId: "Task 3",
+ surface: "comment",
+ }),
+ ).toBe(true);
+ });
+
+ it("validates upload size against the configured maximum", () => {
+ process.env.S3_MAX_IMAGE_UPLOAD_BYTES = "1024";
+
+ expect(() => validateTaskAssetUploadInput("", 10)).toThrow(
+ "A valid content type is required.",
+ );
+ expect(() => validateTaskAssetUploadInput("image/png", 0)).toThrow(
+ "Upload size must be greater than zero.",
+ );
+ expect(() => validateTaskAssetUploadInput("image/png", 2048)).toThrow(
+ "Upload exceeds the maximum upload size of 0MB.",
+ );
+ expect(() => validateTaskAssetUploadInput("image/png", 512)).not.toThrow();
+ });
+});
diff --git a/tests/api/utils/generate-demo-name.test.ts b/tests/api/utils/generate-demo-name.test.ts
new file mode 100644
index 000000000..67fcb0eb5
--- /dev/null
+++ b/tests/api/utils/generate-demo-name.test.ts
@@ -0,0 +1,22 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { generateDemoName } from "../../../apps/api/src/utils/generate-demo-name";
+
+afterEach(() => {
+ vi.restoreAllMocks();
+});
+
+describe("generateDemoName", () => {
+ it("returns an adjective-animal slug", () => {
+ vi.spyOn(Math, "random").mockReturnValueOnce(0).mockReturnValueOnce(0);
+
+ expect(generateDemoName()).toBe("fractious-monkfish");
+ });
+
+ it("stays hyphenated for later values too", () => {
+ vi.spyOn(Math, "random")
+ .mockReturnValueOnce(0.9999)
+ .mockReturnValueOnce(0.9999);
+
+ expect(generateDemoName()).toBe("dynamic-lion");
+ });
+});
diff --git a/tests/api/utils/openapi-spec.test.ts b/tests/api/utils/openapi-spec.test.ts
new file mode 100644
index 000000000..b989761f0
--- /dev/null
+++ b/tests/api/utils/openapi-spec.test.ts
@@ -0,0 +1,249 @@
+import { describe, expect, it } from "vitest";
+import {
+ dedupeOperationIds,
+ ensureOperationSummaries,
+ markOptionalSchemaFieldsNullable,
+ mergeOpenApiSpecs,
+ normalizeApiServerUrl,
+ normalizeEmptyRequiredArrays,
+ normalizeNullableSchemasForOpenApi30,
+ normalizeOrganizationAuthOperations,
+} from "../../../apps/api/src/utils/openapi-spec";
+
+describe("openapi spec helpers", () => {
+ it("normalizes API server urls", () => {
+ expect(normalizeApiServerUrl("https://api.kaneo.app")).toBe(
+ "https://api.kaneo.app/api",
+ );
+ expect(normalizeApiServerUrl("https://api.kaneo.app/api/")).toBe(
+ "https://api.kaneo.app/api",
+ );
+ });
+
+ it("normalizes organization auth operations and prunes components", () => {
+ const authSpec = {
+ paths: {
+ "/organization/list-members": {
+ get: {
+ operationId: "oldId",
+ summary: "Old summary",
+ responses: {
+ 200: {
+ content: {
+ "application/json": {
+ schema: { $ref: "#/components/schemas/MemberList" },
+ },
+ },
+ },
+ },
+ },
+ },
+ "/session/get": {
+ get: {
+ operationId: "ignored",
+ },
+ },
+ },
+ security: [{ bearerAuth: [] }],
+ components: {
+ securitySchemes: {
+ bearerAuth: { type: "http", scheme: "bearer" },
+ },
+ schemas: {
+ MemberList: {
+ type: "object",
+ properties: {
+ data: {
+ $ref: "#/components/schemas/Member",
+ },
+ },
+ },
+ Member: {
+ type: "object",
+ properties: {
+ id: { type: "string" },
+ },
+ },
+ Ignored: {
+ type: "object",
+ },
+ },
+ },
+ };
+
+ const normalized = normalizeOrganizationAuthOperations(authSpec);
+
+ expect(Object.keys(normalized.paths as Record<string, unknown>)).toEqual([
+ "/auth/organization/list-members",
+ ]);
+
+ const operation = (
+ normalized.paths as Record<
+ string,
+ Record<string, Record<string, unknown>>
+ >
+ )["/auth/organization/list-members"].get;
+
+ expect(operation.operationId).toBe("listOrganizationMembers");
+ expect(operation.summary).toBe("List Organization Members");
+ expect(operation.tags).toEqual(["Organization Management"]);
+
+ const schemaNames = Object.keys(
+ (
+ normalized.components as {
+ schemas?: Record<string, unknown>;
+ }
+ ).schemas || {},
+ );
+ expect(schemaNames).toEqual(["MemberList", "Member"]);
+ });
+
+ it("merges hono and auth specs", () => {
+ const merged = mergeOpenApiSpecs(
+ {
+ openapi: "3.1.0",
+ info: { title: "API" },
+ paths: { "/tasks": { get: { operationId: "getTasks" } } },
+ tags: [{ name: "Tasks" }],
+ components: {
+ schemas: { Task: { type: "object" } },
+ },
+ },
+ {
+ paths: { "/auth/session": { get: { operationId: "getSession" } } },
+ tags: [{ name: "Auth" }],
+ components: {
+ securitySchemes: { bearerAuth: { type: "http" } },
+ schemas: { Session: { type: "object" } },
+ },
+ },
+ );
+
+ expect(merged.openapi).toBe("3.1.0");
+ expect(Object.keys(merged.paths)).toEqual(["/tasks", "/auth/session"]);
+ expect(merged.tags).toEqual([{ name: "Tasks" }, { name: "Auth" }]);
+ expect(merged.components.schemas).toEqual({
+ Task: { type: "object" },
+ Session: { type: "object" },
+ });
+ expect(merged.components.securitySchemes).toEqual({
+ bearerAuth: { type: "http" },
+ });
+ });
+
+ it("dedupes operation ids using method and path", () => {
+ const spec = dedupeOperationIds({
+ paths: {
+ "/tasks": {
+ get: { operationId: "getTask" },
+ },
+ "/tasks/{id}": {
+ get: { operationId: "getTask" },
+ },
+ },
+ });
+
+ expect(
+ (spec.paths as Record<string, Record<string, { operationId: string }>>)[
+ "/tasks/{id}"
+ ].get.operationId,
+ ).toBe("getTask_get_tasks_id");
+ });
+
+ it("normalizes nullable schemas and empty required arrays", () => {
+ const spec = normalizeEmptyRequiredArrays(
+ normalizeNullableSchemasForOpenApi30({
+ components: {
+ schemas: {
+ Example: {
+ type: ["string", "null"],
+ required: [],
+ },
+ ExampleAnyOf: {
+ anyOf: [{ type: "null" }, { type: "number", minimum: 1 }],
+ },
+ },
+ },
+ }),
+ );
+
+ expect(
+ (
+ spec.components as {
+ schemas: Record<string, Record<string, unknown>>;
+ }
+ ).schemas.Example,
+ ).toEqual({
+ type: "string",
+ nullable: true,
+ });
+
+ expect(
+ (
+ spec.components as {
+ schemas: Record<string, Record<string, unknown>>;
+ }
+ ).schemas.ExampleAnyOf,
+ ).toEqual({
+ type: "number",
+ minimum: 1,
+ nullable: true,
+ });
+ });
+
+ it("marks optional schema fields nullable and fills missing summaries", () => {
+ const spec = ensureOperationSummaries(
+ markOptionalSchemaFieldsNullable({
+ paths: {
+ "/tasks": {
+ get: {
+ operationId: "listWorkspaceTasks",
+ },
+ },
+ },
+ components: {
+ schemas: {
+ Task: {
+ type: "object",
+ required: ["id"],
+ properties: {
+ id: { type: "string" },
+ title: { type: "string" },
+ estimate: { type: "number", nullable: true },
+ },
+ },
+ },
+ },
+ }),
+ );
+
+ expect(
+ (
+ spec.components as {
+ schemas: Record<
+ string,
+ { properties: Record<string, Record<string, unknown>> }
+ >;
+ }
+ ).schemas.Task.properties.title.nullable,
+ ).toBe(true);
+ expect(
+ (
+ spec.components as {
+ schemas: Record<
+ string,
+ { properties: Record<string, Record<string, unknown>> }
+ >;
+ }
+ ).schemas.Task.properties.id.nullable,
+ ).toBeUndefined();
+ expect(
+ (
+ spec.paths as Record<
+ string,
+ Record<string, { summary?: string; operationId: string }>
+ >
+ )["/tasks"].get.summary,
+ ).toBe("List Workspace Tasks");
+ });
+});
diff --git a/tests/api/utils/to-normal-case.test.ts b/tests/api/utils/to-normal-case.test.ts
new file mode 100644
index 000000000..75f51fa54
--- /dev/null
+++ b/tests/api/utils/to-normal-case.test.ts
@@ -0,0 +1,14 @@
+import { describe, expect, it } from "vitest";
+import toNormalCase from "../../../apps/api/src/utils/to-normal-case";
+
+describe("toNormalCase", () => {
+ it("normalizes kebab and snake case", () => {
+ expect(toNormalCase("in-progress")).toBe("In Progress");
+ expect(toNormalCase("custom_oauth_status")).toBe("Custom Oauth Status");
+ });
+
+ it("returns falsy input as-is", () => {
+ expect(toNormalCase(undefined)).toBeUndefined();
+ expect(toNormalCase("")).toBe("");
+ });
+});
diff --git a/turbo.json b/turbo.json
index ceeb3666a..09fac4ecf 100644
--- a/turbo.json
+++ b/turbo.json
@@ -15,6 +15,11 @@
"lint": {
"cache": false,
"persistent": true
+ },
+ "test": {
+ "dependsOn": ["^test"],
+ "cache": false,
+ "outputs": ["coverage/**"]
}
}
}