|
| 1 | +import { describe, expect, test } from 'bun:test' |
| 2 | + |
| 3 | +describe('freebuff command aliases', () => { |
| 4 | + test('/model aliases /end-session in freebuff', () => { |
| 5 | + const slashCommandsUrl = new URL( |
| 6 | + '../../data/slash-commands.ts', |
| 7 | + import.meta.url, |
| 8 | + ).href |
| 9 | + const commandRegistryUrl = new URL( |
| 10 | + '../command-registry.ts', |
| 11 | + import.meta.url, |
| 12 | + ).href |
| 13 | + |
| 14 | + const result = Bun.spawnSync({ |
| 15 | + cmd: [ |
| 16 | + 'bun', |
| 17 | + '--eval', |
| 18 | + ` |
| 19 | + import { SLASH_COMMANDS } from ${JSON.stringify(slashCommandsUrl)} |
| 20 | + import { findCommand } from ${JSON.stringify(commandRegistryUrl)} |
| 21 | +
|
| 22 | + const endSession = SLASH_COMMANDS.find((cmd) => cmd.id === 'end-session') |
| 23 | + if (!endSession) throw new Error('end-session slash command missing') |
| 24 | + if (!endSession.aliases?.includes('model')) { |
| 25 | + throw new Error('end-session slash command is missing model alias') |
| 26 | + } |
| 27 | +
|
| 28 | + const modelCommand = findCommand('model') |
| 29 | + if (!modelCommand) throw new Error('model command alias missing') |
| 30 | + if (modelCommand.name !== 'end-session') { |
| 31 | + throw new Error('model alias did not resolve to end-session') |
| 32 | + } |
| 33 | + `, |
| 34 | + ], |
| 35 | + cwd: process.cwd(), |
| 36 | + env: { |
| 37 | + ...process.env, |
| 38 | + FREEBUFF_MODE: 'true', |
| 39 | + NODE_ENV: 'test', |
| 40 | + NEXT_PUBLIC_CB_ENVIRONMENT: 'test', |
| 41 | + NEXT_PUBLIC_CODEBUFF_APP_URL: 'https://app.codebuff.test', |
| 42 | + NEXT_PUBLIC_SUPPORT_EMAIL: 'support@codebuff.test', |
| 43 | + NEXT_PUBLIC_POSTHOG_API_KEY: 'phc_test_key', |
| 44 | + NEXT_PUBLIC_POSTHOG_HOST_URL: 'https://posthog.codebuff.test', |
| 45 | + NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: 'pk_test_123', |
| 46 | + NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL: 'https://stripe.codebuff.test', |
| 47 | + NEXT_PUBLIC_WEB_PORT: '3000', |
| 48 | + }, |
| 49 | + stderr: 'pipe', |
| 50 | + stdout: 'pipe', |
| 51 | + }) |
| 52 | + |
| 53 | + const stderr = new TextDecoder().decode(result.stderr) |
| 54 | + expect(result.exitCode, stderr).toBe(0) |
| 55 | + }) |
| 56 | +}) |
0 commit comments