CoolFace
Apppublic

Leon4gr45/builder

sourceHugging Facemitupdated 3d agoView on Hugging Face
0likes
tool-analytics.test.ts47 linesDownload Raw Back to __tests__
1import { describe, it, expect } from 'vitest';2import { extractToolAnalytics, extractSkillRead, bucketInterviewTemplateId } from '../tool-analytics';3 4describe('extractSkillRead', () => {5  const j = (command: string) => JSON.stringify({ command });6 7  it('maps a built-in skill cat to its id', () => {8    expect(extractSkillRead(j('cat /.skills/frontend-design-luxury.md')))9      .toEqual({ skill: 'frontend-design-luxury' });10  });11 12  it('buckets non-built-in skill reads to custom', () => {13    expect(extractSkillRead(j('cat /.skills/my-own-thing.md'))).toEqual({ skill: 'custom' });14  });15 16  it('returns null for non-skill reads and non-cat commands', () => {17    expect(extractSkillRead(j('cat /index.html'))).toBeNull();18    expect(extractSkillRead(j('ls /.skills'))).toBeNull();19    expect(extractSkillRead('not json')).toBeNull();20  });21 22  it('never includes a path in its output', () => {23    const out = extractSkillRead(j('cat /.skills/secret-project-name.md'));24    expect(JSON.stringify(out)).not.toContain('secret-project-name');25  });26});27 28describe('extractToolAnalytics', () => {29  it('still buckets bash commands and never emits paths', () => {30    const out = extractToolAnalytics('bash', JSON.stringify({ command: 'cat /some/file.txt' }), true);31    expect(out.command).toBe('cat');32    expect(JSON.stringify(out)).not.toContain('/some/file.txt');33  });34});35 36describe('bucketInterviewTemplateId', () => {37  it('passes a built-in template id through unchanged', () => {38    // 'understand-company' is one of the shipped built-in interview templates.39    expect(bucketInterviewTemplateId('understand-company')).toBe('understand-company');40  });41 42  it('buckets a user-authored template id to custom so it never leaks', () => {43    expect(bucketInterviewTemplateId('my-secret-client-interview')).toBe('custom');44    expect(bucketInterviewTemplateId('my-secret-client-interview')).not.toContain('secret');45  });46});47