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
56 changes: 56 additions & 0 deletions cli/src/commands/__tests__/freebuff-command-aliases.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { describe, expect, test } from 'bun:test'

describe('freebuff command aliases', () => {
test('/model aliases /end-session in freebuff', () => {
const slashCommandsUrl = new URL(
'../../data/slash-commands.ts',
import.meta.url,
).href
const commandRegistryUrl = new URL(
'../command-registry.ts',
import.meta.url,
).href

const result = Bun.spawnSync({
cmd: [
'bun',
'--eval',
`
import { SLASH_COMMANDS } from ${JSON.stringify(slashCommandsUrl)}
import { findCommand } from ${JSON.stringify(commandRegistryUrl)}

const endSession = SLASH_COMMANDS.find((cmd) => cmd.id === 'end-session')
if (!endSession) throw new Error('end-session slash command missing')
if (!endSession.aliases?.includes('model')) {
throw new Error('end-session slash command is missing model alias')
}

const modelCommand = findCommand('model')
if (!modelCommand) throw new Error('model command alias missing')
if (modelCommand.name !== 'end-session') {
throw new Error('model alias did not resolve to end-session')
}
`,
],
cwd: process.cwd(),
env: {
...process.env,
FREEBUFF_MODE: 'true',
NODE_ENV: 'test',
NEXT_PUBLIC_CB_ENVIRONMENT: 'test',
NEXT_PUBLIC_CODEBUFF_APP_URL: 'https://app.codebuff.test',
NEXT_PUBLIC_SUPPORT_EMAIL: 'support@codebuff.test',
NEXT_PUBLIC_POSTHOG_API_KEY: 'phc_test_key',
NEXT_PUBLIC_POSTHOG_HOST_URL: 'https://posthog.codebuff.test',
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: 'pk_test_123',
NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL: 'https://stripe.codebuff.test',
NEXT_PUBLIC_WEB_PORT: '3000',
},
stderr: 'pipe',
stdout: 'pipe',
})

const stderr = new TextDecoder().decode(result.stderr)
expect(result.exitCode, stderr).toBe(0)
})
})
1 change: 1 addition & 0 deletions cli/src/commands/command-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ const ALL_COMMANDS: CommandDefinition[] = [
// user picks a model and hits Enter to rejoin the queue.
defineCommand({
name: 'end-session',
aliases: ['model'],
handler: (params) => {
params.setMessages((prev) => [
...prev,
Expand Down
3 changes: 2 additions & 1 deletion cli/src/data/slash-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ const ALL_SLASH_COMMANDS: SlashCommand[] = [
{
id: 'end-session',
label: 'end-session',
description: 'End your free session and return to the waiting room (lets you switch model)',
description: 'End your free session (lets you switch model)',
aliases: ['model'],
},
{
id: 'logout',
Expand Down
Loading