feat: persist settings and enrich conversation context
This commit is contained in:
1 parent
a36723a325
commit
2c100d72b6
84 files changed
+2248
-644
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { presentActivityItem, resolveRedditUsername } from '../../src/web/reddit-identities.js';
|
||||
|
||||
const resolver = {
|
||||
resolveSenderDisplay(identity: string) {
|
||||
return identity.replace(/^@?t2_known(?::reddit\.com)?$/, 'alice');
|
||||
},
|
||||
};
|
||||
|
||||
describe('Reddit identity presentation', () => {
|
||||
it('resolves internal ids and rejects unresolved ids', () => {
|
||||
expect(resolveRedditUsername('@t2_known:reddit.com', resolver)).toBe('alice');
|
||||
expect(resolveRedditUsername('t2_missing', resolver)).toBeNull();
|
||||
});
|
||||
|
||||
it('upgrades both the activity recipient and its persisted message text', () => {
|
||||
expect(presentActivityItem({
|
||||
timestamp: 1,
|
||||
type: 'response',
|
||||
message: 'Reply from u/t2_known',
|
||||
recipient: 't2_known',
|
||||
}, resolver)).toEqual({
|
||||
timestamp: 1,
|
||||
type: 'response',
|
||||
message: 'Reply from u/alice',
|
||||
recipient: 'alice',
|
||||
});
|
||||
});
|
||||
|
||||
it('redacts unresolved ids instead of exposing them', () => {
|
||||
const item = presentActivityItem({
|
||||
timestamp: 1,
|
||||
type: 'response',
|
||||
message: 'Reply from @t2_missing:reddit.com',
|
||||
recipient: 't2_missing',
|
||||
}, resolver);
|
||||
|
||||
expect(item.message).toBe('Reply from Reddit user');
|
||||
expect(item.recipient).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user