Show Reddit post age in conversations
This commit is contained in:
1 parent
7db60e8839
commit
50f9f8a6aa
14 files changed
+65
-11
No files matched your search
@@ -49,6 +49,7 @@ function detailFixture(chat = alice) {
|
||||
title: 'Looking for a chat',
|
||||
url: 'https://reddit.com/r/casualconversation/comments/post-1',
|
||||
imageUrl: 'https://i.redd.it/source-post.jpg',
|
||||
postedAt: Date.now() - (2 * 60 * 60 * 1000),
|
||||
sentAt: 1_785_999_800_000,
|
||||
},
|
||||
automation: { turnsUsed: 0, remainingTurns: 3, status: 'active', handoffReason: null },
|
||||
@@ -142,6 +143,7 @@ describe('ConversationsPage', () => {
|
||||
'src',
|
||||
'https://i.redd.it/source-post.jpg',
|
||||
);
|
||||
expect(screen.getByText('2h ago')).toBeInTheDocument();
|
||||
expect(screen.getByRole('img', { name: 'Source post: Looking for a chat' })).toHaveClass('is-blurred');
|
||||
await user.click(screen.getByRole('button', { name: 'Reveal original image' }));
|
||||
expect(screen.getByRole('img', { name: 'Source post: Looking for a chat' })).not.toHaveClass('is-blurred');
|
||||
|
||||
@@ -156,7 +156,7 @@ describe('Database Client', () => {
|
||||
DROP TABLE conversation_automation_claims;
|
||||
DROP TABLE ai_usage;
|
||||
`);
|
||||
db.pragma(`user_version = ${latestVersion - 2}`);
|
||||
db.pragma(`user_version = ${latestVersion - 3}`);
|
||||
runMigrations(db);
|
||||
|
||||
expect(db.prepare('SELECT recipient, reason FROM recipient_suppressions ORDER BY recipient COLLATE NOCASE').all())
|
||||
@@ -176,6 +176,7 @@ describe('Database Client', () => {
|
||||
expect(columnMap.get('subreddit')?.notnull).toBe(1);
|
||||
expect(columnMap.get('author')?.notnull).toBe(1);
|
||||
expect(columnMap.get('title')?.notnull).toBe(1);
|
||||
expect(columnMap.get('post_created_at')).toBeDefined();
|
||||
expect(columnMap.get('processed_at')?.notnull).toBe(1);
|
||||
expect(columnMap.get('message_sent')).toBeDefined();
|
||||
expect(columnMap.get('error')).toBeDefined();
|
||||
|
||||
@@ -31,6 +31,7 @@ describe('PostsRepository', () => {
|
||||
title: 'Test Post',
|
||||
postUrl: 'https://www.reddit.com/r/test/comments/post1/test_post/',
|
||||
imageUrl: 'http://example.com/img.jpg',
|
||||
postCreatedAt: 1_700_000_000_000,
|
||||
processedAt: Date.now(),
|
||||
});
|
||||
|
||||
@@ -42,6 +43,7 @@ describe('PostsRepository', () => {
|
||||
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!.postCreatedAt).toBe(1_700_000_000_000);
|
||||
expect(post!.messageSent).toBe(false);
|
||||
expect(post!.imageAnalysis).toBeNull();
|
||||
expect(post!.error).toBeNull();
|
||||
@@ -314,6 +316,7 @@ describe('MessagesRepository', () => {
|
||||
title: 'Second post',
|
||||
postUrl: 'https://www.reddit.com/r/gonewild/comments/post-b/second_post/',
|
||||
imageUrl: null,
|
||||
postCreatedAt: 1_700_000_000_000,
|
||||
processedAt: Date.now(),
|
||||
});
|
||||
|
||||
@@ -327,6 +330,7 @@ describe('MessagesRepository', () => {
|
||||
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(latest!.postCreatedAt).toBe(1_700_000_000_000);
|
||||
expect(messagesRepo.getByChatRoomId('room-b')).toMatchObject({ postId: 'post-b', postTitle: 'Second post' });
|
||||
|
||||
expect(messagesRepo.getLatestByRecipient('ALICE')).toBeDefined();
|
||||
|
||||
@@ -296,6 +296,7 @@ describe('conversations route', () => {
|
||||
chatRoomId: 'room-alice', subreddit: 'example', postTitle: 'Exact source post',
|
||||
postUrl: 'https://www.reddit.com/r/example/comments/post-exact/exact_source_post/',
|
||||
postImageUrl: 'https://i.redd.it/exact-source.jpg',
|
||||
postCreatedAt: 8,
|
||||
};
|
||||
const latestRecipientOrigin = { ...roomOrigin, postId: 'wrong-latest-post', postTitle: 'Wrong post' };
|
||||
const context = {
|
||||
@@ -318,7 +319,7 @@ describe('conversations route', () => {
|
||||
const body = await response.json();
|
||||
expect(body.triggeringPost).toEqual({
|
||||
id: 'post-exact', subreddit: 'example', title: 'Exact source post',
|
||||
url: roomOrigin.postUrl, imageUrl: roomOrigin.postImageUrl, sentAt: 9,
|
||||
url: roomOrigin.postUrl, imageUrl: roomOrigin.postImageUrl, postedAt: 8, sentAt: 9,
|
||||
});
|
||||
expect(body.messages[0]).toMatchObject({ text: 'Hello', isAi: true });
|
||||
expect(context.repos.messages.getLatestByRecipient).not.toHaveBeenCalled();
|
||||
|
||||
Reference in new issue
Block a user