mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #18778 from overleaf/mj-web-chat-restore-tests
[chat+web] Add tests for revert functionality GitOrigin-RevId: f10a5589d8ee1299949ef3decd8325d8fa1f7d41
This commit is contained in:
committed by
Copybot
parent
861397e8db
commit
78ef2c2f14
@@ -114,4 +114,51 @@ describe('Getting messages', async function () {
|
||||
expect(thread2.messages[1].user_id).to.equal(userId2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('from a list of threads', function () {
|
||||
const projectId = new ObjectId().toString()
|
||||
const threadId1 = new ObjectId().toString()
|
||||
const threadId2 = new ObjectId().toString()
|
||||
const threadId3 = new ObjectId().toString()
|
||||
|
||||
before(async function () {
|
||||
const { response } = await ChatClient.sendMessage(
|
||||
projectId,
|
||||
threadId1,
|
||||
userId1,
|
||||
'one'
|
||||
)
|
||||
expect(response.statusCode).to.equal(201)
|
||||
const { response: response2 } = await ChatClient.sendMessage(
|
||||
projectId,
|
||||
threadId2,
|
||||
userId2,
|
||||
'two'
|
||||
)
|
||||
expect(response2.statusCode).to.equal(201)
|
||||
const { response: response3 } = await ChatClient.sendMessage(
|
||||
projectId,
|
||||
threadId1,
|
||||
userId1,
|
||||
'three'
|
||||
)
|
||||
expect(response3.statusCode).to.equal(201)
|
||||
})
|
||||
|
||||
it('should contain a dictionary of threads with messages with populated users', async function () {
|
||||
const { response, body: threads } = await ChatClient.generateThreadData(
|
||||
projectId,
|
||||
[threadId1, threadId3]
|
||||
)
|
||||
expect(response.statusCode).to.equal(200)
|
||||
expect(Object.keys(threads).length).to.equal(1)
|
||||
const thread1 = threads[threadId1]
|
||||
expect(thread1.messages.length).to.equal(2)
|
||||
|
||||
expect(thread1.messages[0].content).to.equal('one')
|
||||
expect(thread1.messages[0].user_id).to.equal(userId1)
|
||||
expect(thread1.messages[1].content).to.equal('three')
|
||||
expect(thread1.messages[1].user_id).to.equal(userId1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -154,3 +154,13 @@ export async function duplicateCommentThreads(projectId, threads) {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export async function generateThreadData(projectId, threads) {
|
||||
return await asyncRequest({
|
||||
method: 'post',
|
||||
url: `/project/${projectId}/generate-thread-data`,
|
||||
json: {
|
||||
threads,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user