opus-client.integration.test.ts•3.53 kB
import { describe, it, expect, beforeAll } from 'vitest';
import { OpusClient } from './opus-client.js';
import type { ShortcutData } from './types.js';
describe.skipIf(!process.env.ANTHROPIC_API_KEY)('OpusClient Integration Tests', () => {
beforeAll(() => {
console.log('✅ ANTHROPIC_API_KEY found - running integration tests');
});
it('should query tmux shortcuts from live Opus API', async () => {
const opusClient = new OpusClient();
const mockShortcuts: ShortcutData[] = [
{
os: 'ubuntu',
desktop: null,
application: 'tmux',
file: 'tmux',
categories: [
{
name: 'Session Management',
shortcuts: [
{ keys: 'Prefix + D', description: 'Detach session' },
{ keys: 'Prefix + S', description: 'List sessions' },
],
},
{
name: 'Pane Management',
shortcuts: [
{ keys: 'Prefix + %', description: 'Split pane vertically' },
{ keys: 'Prefix + "', description: 'Split pane horizontally' },
],
},
],
},
];
const query = 'how do I split a tmux pane vertically?';
const result = await opusClient.queryShortcuts(query, mockShortcuts);
// Verify response contains relevant information
expect(result).toBeTruthy();
expect(result.length).toBeGreaterThan(0);
expect(result.toLowerCase()).toContain('vertical');
expect(result).toContain('Prefix');
});
it('should query GNOME window management shortcuts', async () => {
const opusClient = new OpusClient();
const mockShortcuts: ShortcutData[] = [
{
os: 'ubuntu',
desktop: 'gnome',
application: null,
file: 'window-management',
categories: [
{
name: 'Window Tiling',
shortcuts: [
{ keys: 'Super + Left', description: 'Tile window to left half' },
{ keys: 'Super + Right', description: 'Tile window to right half' },
{ keys: 'Super + Up', description: 'Maximize window' },
],
},
],
},
];
const query = 'how do I tile a window to the left side of the screen?';
const result = await opusClient.queryShortcuts(query, mockShortcuts);
expect(result).toBeTruthy();
expect(result.toLowerCase()).toContain('left');
expect(result).toContain('Super');
});
it('should handle multiple application shortcuts', async () => {
const opusClient = new OpusClient();
const mockShortcuts: ShortcutData[] = [
{
os: 'ubuntu',
desktop: 'gnome',
application: 'firefox',
file: 'firefox',
categories: [
{
name: 'Tab Management',
shortcuts: [
{ keys: 'Ctrl + T', description: 'New tab' },
{ keys: 'Ctrl + W', description: 'Close tab' },
{ keys: 'Ctrl + Shift + T', description: 'Reopen closed tab' },
],
},
{
name: 'Navigation',
shortcuts: [
{ keys: 'Ctrl + L', description: 'Focus address bar' },
{ keys: 'Alt + Left', description: 'Back' },
],
},
],
},
];
const query = 'what are the tab shortcuts in firefox?';
const result = await opusClient.queryShortcuts(query, mockShortcuts);
expect(result).toBeTruthy();
expect(result.toLowerCase()).toMatch(/tab|ctrl/);
});
});