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
@@ -27,6 +27,7 @@ describe('PostsRepository', () => {
|
||||
subreddit: 'test',
|
||||
author: 'user1',
|
||||
title: 'Test Post',
|
||||
postUrl: 'https://www.reddit.com/r/test/comments/post1/test_post/',
|
||||
imageUrl: 'http://example.com/img.jpg',
|
||||
processedAt: Date.now(),
|
||||
});
|
||||
@@ -37,6 +38,7 @@ describe('PostsRepository', () => {
|
||||
expect(post!.subreddit).toBe('test');
|
||||
expect(post!.author).toBe('user1');
|
||||
expect(post!.title).toBe('Test Post');
|
||||
expect(post!.postUrl).toBe('https://www.reddit.com/r/test/comments/post1/test_post/');
|
||||
expect(post!.imageUrl).toBe('http://example.com/img.jpg');
|
||||
expect(post!.messageSent).toBe(false);
|
||||
expect(post!.imageAnalysis).toBeNull();
|
||||
@@ -203,7 +205,7 @@ describe('MessagesRepository', () => {
|
||||
expect(updated!.gotResponse).toBe(true);
|
||||
});
|
||||
|
||||
it('chat-originated rows appear in getRecent and contribute to stats', () => {
|
||||
it('keeps unassociated chat history out of performance trends', () => {
|
||||
messagesRepo.insertChat({
|
||||
recipient: 'bob',
|
||||
subject: 'bob',
|
||||
@@ -213,6 +215,7 @@ describe('MessagesRepository', () => {
|
||||
});
|
||||
const recent = messagesRepo.getRecent(10);
|
||||
expect(recent.some((m) => m.chatRoomId === '!r1:reddit.com')).toBe(true);
|
||||
expect(messagesRepo.getResponseRateTrend()).toEqual([]);
|
||||
});
|
||||
|
||||
it('inserts and retrieves a message', () => {
|
||||
@@ -305,19 +308,22 @@ describe('MessagesRepository', () => {
|
||||
subreddit: 'gonewild',
|
||||
author: 'alice',
|
||||
title: 'Second post',
|
||||
postUrl: 'https://www.reddit.com/r/gonewild/comments/post-b/second_post/',
|
||||
imageUrl: null,
|
||||
processedAt: Date.now(),
|
||||
});
|
||||
|
||||
const base = Date.now();
|
||||
messagesRepo.insert({ postId: 'post-a', recipient: 'alice', subject: 's', message: 'm', sentAt: base });
|
||||
messagesRepo.insert({ postId: 'post-b', recipient: 'alice', subject: 's', message: 'm', sentAt: base + 1000 });
|
||||
messagesRepo.insert({ postId: 'post-b', recipient: 'alice', subject: 's', message: 'm', sentAt: base + 1000, chatRoomId: 'room-b' });
|
||||
|
||||
const latest = messagesRepo.getLatestByRecipient('alice');
|
||||
expect(latest).toBeDefined();
|
||||
expect(latest!.postId).toBe('post-b');
|
||||
expect(latest!.subreddit).toBe('gonewild');
|
||||
expect(latest!.postTitle).toBe('Second post');
|
||||
expect(latest!.postUrl).toBe('https://www.reddit.com/r/gonewild/comments/post-b/second_post/');
|
||||
expect(messagesRepo.getByChatRoomId('room-b')).toMatchObject({ postId: 'post-b', postTitle: 'Second post' });
|
||||
|
||||
expect(messagesRepo.getLatestByRecipient('ALICE')).toBeDefined();
|
||||
expect(messagesRepo.getLatestByRecipient('nobody')).toBeUndefined();
|
||||
|
||||
Reference in new issue
Block a user