Files
pbakaus_impeccable/tests/server/download-validation.test.js
T
Paul BakausandClaude Opus 4.6 4092ee5f22 Move PID file to project root (.impeccable-live.json)
os.tmpdir() returns /var/folders/.../T/ on macOS, not /tmp/. The skill
reference was telling the agent to cat /tmp/impeccable-live.json which
didn't exist. Moving the PID file to the project root makes it
predictable across platforms and project-scoped (multiple projects can
run independent live sessions).

Changed in: live-server.mjs, live-poll.mjs, live.md reference.
Added .impeccable-live.json to .gitignore.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 12:32:42 -07:00

54 lines
2.0 KiB
JavaScript

import { describe, expect, test } from 'bun:test';
import path from 'path';
import {
ALLOWED_BUNDLE_PROVIDERS,
ALLOWED_FILE_PROVIDERS,
isAllowedBundleProvider,
isAllowedFileProvider,
isAllowedProvider,
} from '../../server/lib/validation.js';
import { getFilePath, handleFileDownload } from '../../server/lib/api-handlers.js';
describe('download provider validation', () => {
test('allows opencode and pi as individual download providers', () => {
expect(ALLOWED_FILE_PROVIDERS).toContain('opencode');
expect(ALLOWED_FILE_PROVIDERS).toContain('pi');
expect(ALLOWED_FILE_PROVIDERS).toContain('github');
expect(isAllowedFileProvider('opencode')).toBe(true);
expect(isAllowedFileProvider('pi')).toBe(true);
expect(isAllowedFileProvider('github')).toBe(true);
});
test('separates file downloads from bundle downloads', () => {
expect(ALLOWED_BUNDLE_PROVIDERS).toContain('universal');
expect(isAllowedBundleProvider('universal')).toBe(true);
expect(isAllowedProvider('universal')).toBe(true);
expect(isAllowedFileProvider('universal')).toBe(false);
});
});
describe('download file paths', () => {
test('maps opencode skills into the .opencode config directory', () => {
expect(getFilePath('skill', 'opencode', 'impeccable')).toBe(
path.join(process.cwd(), 'dist', 'opencode', '.opencode', 'skills', 'impeccable', 'SKILL.md')
);
});
test('maps pi commands into the .pi config directory', () => {
expect(getFilePath('command', 'pi', 'audit')).toBe(
path.join(process.cwd(), 'dist', 'pi', '.pi', 'skills', 'audit', 'SKILL.md')
);
});
test('maps github copilot skills into the .github config directory', () => {
expect(getFilePath('skill', 'github', 'impeccable')).toBe(
path.join(process.cwd(), 'dist', 'github', '.github', 'skills', 'impeccable', 'SKILL.md')
);
});
test('rejects bundle-only providers on the individual download route', async () => {
const response = await handleFileDownload('skill', 'universal', 'impeccable');
expect(response.status).toBe(400);
});
});