2020-08-19 12:00:01 +00:00
|
|
|
const { ObjectId } = require('../../../app/js/mongodb')
|
2018-12-20 19:14:11 +00:00
|
|
|
const { expect } = require('chai')
|
2017-01-24 14:44:32 +00:00
|
|
|
|
2018-12-20 19:14:11 +00:00
|
|
|
const ChatClient = require('./helpers/ChatClient')
|
|
|
|
const ChatApp = require('./helpers/ChatApp')
|
2017-01-24 14:44:32 +00:00
|
|
|
|
2022-01-10 09:29:32 +00:00
|
|
|
describe('Deleting a thread', async function () {
|
2022-01-10 09:50:25 +00:00
|
|
|
const projectId = ObjectId().toString()
|
|
|
|
const userId = ObjectId().toString()
|
2022-01-10 09:29:32 +00:00
|
|
|
before(async function () {
|
|
|
|
await ChatApp.ensureRunning()
|
2018-12-20 19:14:11 +00:00
|
|
|
})
|
2017-01-24 14:44:32 +00:00
|
|
|
|
2022-01-10 09:29:32 +00:00
|
|
|
describe('with a thread that is deleted', async function () {
|
2022-01-10 09:50:25 +00:00
|
|
|
const threadId = ObjectId().toString()
|
|
|
|
const content = 'deleted thread message'
|
2022-01-10 09:29:32 +00:00
|
|
|
before(async function () {
|
|
|
|
const { response } = await ChatClient.sendMessage(
|
2022-01-10 09:50:25 +00:00
|
|
|
projectId,
|
|
|
|
threadId,
|
|
|
|
userId,
|
|
|
|
content
|
2018-12-20 19:14:11 +00:00
|
|
|
)
|
2022-01-10 09:29:32 +00:00
|
|
|
expect(response.statusCode).to.equal(201)
|
|
|
|
const { response: response2 } = await ChatClient.deleteThread(
|
2022-01-10 09:50:25 +00:00
|
|
|
projectId,
|
|
|
|
threadId
|
2022-01-10 09:29:32 +00:00
|
|
|
)
|
|
|
|
expect(response2.statusCode).to.equal(204)
|
2018-12-20 19:14:11 +00:00
|
|
|
})
|
|
|
|
|
2022-01-10 09:29:32 +00:00
|
|
|
it('should then not list the thread for the project', async function () {
|
2022-01-10 09:50:25 +00:00
|
|
|
const { response, body: threads } = await ChatClient.getThreads(projectId)
|
2022-01-10 09:29:32 +00:00
|
|
|
expect(response.statusCode).to.equal(200)
|
|
|
|
expect(Object.keys(threads).length).to.equal(0)
|
2018-12-20 19:14:11 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|