Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions packages/shared/src/db/queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,18 +766,23 @@ test('setJoinedGroupChannels: does not reset membership for channels not in the
describe('getPendingPosts', () => {
const channelId = 'pending-test-channel';
const authorId = '~zod';
// Keep seeded rows distinct on the (channelId, authorId, sentAt,
// sequenceNum) cache_id unique index, even when inserts happen in the same
// millisecond on fast CI runners.
let seedCounter = 0;

async function seedPost(overrides: Partial<Post>): Promise<Post> {
const t = Date.now() + seedCounter++;
const base: Post = {
id: `post-${overrides.sentAt ?? Date.now()}-${Math.random()}`,
id: `post-${overrides.sentAt ?? t}-${Math.random()}`,
type: 'chat',
channelId,
authorId,
sentAt: Date.now(),
receivedAt: Date.now(),
sentAt: t,
receivedAt: t,
sequenceNum: 0,
content: JSON.stringify([{ inline: ['seed'] }]),
syncedAt: Date.now(),
syncedAt: t,
...overrides,
} as Post;
await queries.insertChannelPosts({ posts: [base] });
Expand Down
Loading