Sample data in tests, prompts and UI placeholders uses Alex Morgan instead of the maintainer's name; decision attributions say "owner". Personal details in two test fixtures are replaced. Local paths (D:/Projects/...) and paths into the maintainer's planning repository are reworded. Clone and install URLs in CONTRIBUTING.md and the getting started guide use placeholders until the public repository location is decided (Q9). The Benchmarks page no longer names the maintainer's hive-mind repository, and the upstream fixes log names the main Waggle repository instead of an internal git host.
64 lines
2.4 KiB
TypeScript
64 lines
2.4 KiB
TypeScript
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
import { AwarenessLayer } from '../src/awareness.js';
|
|
import { IdentityLayer } from '../src/identity.js';
|
|
import { WaggleDB, workspaceDataScope } from '../src/waggle-db.js';
|
|
|
|
let tmpDir: string;
|
|
|
|
beforeEach(() => {
|
|
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-db-test-'));
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
});
|
|
|
|
describe('WaggleDB', () => {
|
|
it('creates waggle.db in the data directory and keeps meta values', () => {
|
|
const db = WaggleDB.openInDataDir(path.join(tmpDir, 'data'));
|
|
db.setMeta('k', 'v1');
|
|
db.setMeta('k', 'v2');
|
|
expect(db.getMeta('k')).toBe('v2');
|
|
expect(db.getMeta('missing')).toBeNull();
|
|
db.close();
|
|
expect(fs.existsSync(path.join(tmpDir, 'data', 'waggle.db'))).toBe(true);
|
|
});
|
|
|
|
it('rejects an empty workspace id', () => {
|
|
expect(() => workspaceDataScope(' ')).toThrow(TypeError);
|
|
});
|
|
});
|
|
|
|
describe('profile and awareness scopes', () => {
|
|
it('keeps one profile per scope', () => {
|
|
const db = new WaggleDB(':memory:');
|
|
const personal = new IdentityLayer(db);
|
|
const ws = new IdentityLayer(db, workspaceDataScope('alpha'));
|
|
personal.create({ name: 'Ana', role: 'Founder', department: '', personality: '', capabilities: '', system_prompt: '' });
|
|
expect(ws.exists()).toBe(false);
|
|
ws.create({ name: 'Alpha team', role: '', department: '', personality: '', capabilities: '', system_prompt: '' });
|
|
expect(personal.update({ role: 'CEO' }).role).toBe('CEO');
|
|
expect(ws.get().name).toBe('Alpha team');
|
|
expect(personal.toContext()).toContain('Role: CEO');
|
|
db.close();
|
|
});
|
|
|
|
it('keeps awareness items apart and refuses cross-scope edits', () => {
|
|
const db = new WaggleDB(':memory:');
|
|
const personal = new AwarenessLayer(db);
|
|
const ws = new AwarenessLayer(db, workspaceDataScope('alpha'));
|
|
const item = ws.add('task', 'Ship the beta', 2, undefined, { status: 'open' });
|
|
personal.add('pending', 'Reply to Alex');
|
|
expect(ws.getAll().map(i => i.content)).toEqual(['Ship the beta']);
|
|
expect(personal.countOpen()).toBe(1);
|
|
expect(personal.get(item.id)).toBeUndefined();
|
|
personal.remove(item.id);
|
|
expect(ws.get(item.id)).toBeDefined();
|
|
expect(ws.updateMetadata(item.id, { result: 'done' }).metadata).toContain('"result":"done"');
|
|
db.close();
|
|
});
|
|
});
|