Skip to content

Commit

Permalink
test: thread test add
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-pub committed Oct 1, 2023
1 parent cdd8b34 commit 2416dbf
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/tests/channel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,46 @@ describe("Channel test", () => {
expect(sentMessage.hasThread).toBe(false)
})

test("should create, reply to, delete a thread, and recreate the deleted thread", async () => {
const messageText = "Test message for thread recreation"
await channel.sendText(messageText)
await sleep(150) // history calls have around 130ms of cache time

let history = await channel.getHistory()
let sentMessage = history.messages[0]
expect(sentMessage.hasThread).toBe(false)

let threadDraft = await sentMessage.createThread()
await threadDraft.sendText("Initial message in the thread")
history = await channel.getHistory()
sentMessage = history.messages[0]
expect(sentMessage.hasThread).toBe(true)

const thread = await sentMessage.getThread()
const replyText = "Replying to the thread"
await thread.sendText(replyText)
await sleep(150) // history calls have around 130ms of cache time
let threadMessages = await thread.getHistory()
expect(threadMessages.messages.some((message) => message.text === replyText)).toBe(true)

await sentMessage.removeThread()
history = await channel.getHistory()
sentMessage = history.messages[0]
expect(sentMessage.hasThread).toBe(false)

threadDraft = await sentMessage.createThread()
await threadDraft.sendText("Recreated thread after deletion")
history = await channel.getHistory()
sentMessage = history.messages[0]
expect(sentMessage.hasThread).toBe(true)

const newReplyText = "Replying to the recreated thread"
await thread.sendText(newReplyText)
await sleep(150)
threadMessages = await thread.getHistory()
expect(threadMessages.messages.some((message) => message.text === newReplyText)).toBe(true)
})

test("Should mention users with special characters in their names and validate mentioned users", async () => {
const specialChar1 = ":-)"
const specialChar2 = "V$$ap_}><{"
Expand Down

0 comments on commit 2416dbf

Please sign in to comment.