Something went wrong. Try again.
A collaborative coding-agent orchestrator for atproto radl.app
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546import { describe, expect, it } from 'vitest'import { memoryStorage } from './fake-pds.js'import { readRememberedIdentities, saveRememberedIdentity } from './auth.svelte.js'
describe('remembered sign-in identities', () => { it('keeps the most recently used identity first and preserves its verified handle', () => { const storage = memoryStorage()
saveRememberedIdentity({ did: 'did:plc:one', handle: 'one.example' }, storage) saveRememberedIdentity({ did: 'did:plc:two', handle: 'two.example' }, storage) saveRememberedIdentity({ did: 'did:plc:one' }, storage)
expect(readRememberedIdentities(storage)).toEqual([ { did: 'did:plc:one', handle: 'one.example' }, { did: 'did:plc:two', handle: 'two.example' }, ]) })
it('bounds and sanitizes the public identity cache', () => { const storage = memoryStorage() storage.setItem( 'radial:accounts', JSON.stringify([ { did: 'did:plc:one', handle: 42 }, null, { nope: true }, ...Array.from({ length: 8 }, (_, index) => ({ did: `did:plc:${index + 2}` })), ]), )
expect(readRememberedIdentities(storage)).toEqual([ { did: 'did:plc:one' }, { did: 'did:plc:2' }, { did: 'did:plc:3' }, { did: 'did:plc:4' }, { did: 'did:plc:5' }, ]) })
it('ignores a malformed cache', () => { const storage = memoryStorage() storage.setItem('radial:accounts', '{not json') expect(readRememberedIdentities(storage)).toEqual([]) })})