import { describe, expect, test } from 'bun:test'; import { corePermissionCollisions } from './registry'; // The failure this exists to prevent, in one sentence: a plugin whose permission key the platform still // claims installs "successfully", shows a dock tile, rebuilds the frontend with its route — and 404s on // every request, because `setPluginPermissions` refused the key at mount time and said so only on stderr. // // It caught photos, soulseek and jellyfin on the same machine inside a day. Each had been a CORE // permission until its extraction commit, so any server whose platform predates that commit still owns // the key. The remedy is always `git pull`, and nothing in the product ever said so. describe('core permission collisions', () => { test('names a key the platform still claims', () => { // 'chat' is core and not deniable — the clearest case of something a plugin must never redefine. expect(corePermissionCollisions(['chat'])).toEqual(['chat']); }); test('an ordinary plugin key collides with nothing', () => { expect(corePermissionCollisions(['soulseek', 'jellyfin', 'photos'])).toEqual([]); }); test('reports every collision, not just the first — an install should fail once, naming all of them', () => { const found = corePermissionCollisions(['chat', 'soulseek', 'terminal']); expect(found.sort()).toEqual(['chat', 'terminal']); }); test('nothing declared collides with nothing', () => { expect(corePermissionCollisions([])).toEqual([]); }); });