fix: update dependencies to latest
This commit is contained in:
@ -1,20 +1,22 @@
|
||||
import tap from 'tap'
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import sinon from 'sinon'
|
||||
|
||||
import { application } from '../../../../application.js'
|
||||
import { authenticateUserTest } from '../../../../__test__/utils/authenticateUserTest.js'
|
||||
import prisma from '../../../../tools/database/prisma.js'
|
||||
import { messageExample } from '../../../../models/Message.js'
|
||||
import { memberExample } from '../../../../models/Member.js'
|
||||
import { userExample } from '../../../../models/User.js'
|
||||
import { channelExample } from '../../../../models/Channel.js'
|
||||
import { application } from '#src/application.js'
|
||||
import { authenticateUserTest } from '#src/__test__/utils/authenticateUserTest.js'
|
||||
import prisma from '#src/tools/database/prisma.js'
|
||||
import { messageExample } from '#src/models/Message.js'
|
||||
import { memberExample } from '#src/models/Member.js'
|
||||
import { userExample } from '#src/models/User.js'
|
||||
import { channelExample } from '#src/models/Channel.js'
|
||||
|
||||
await tap.test('DELETE /messsages/[messageId]', async (t) => {
|
||||
await test('DELETE /messsages/[messageId]', async (t) => {
|
||||
t.afterEach(() => {
|
||||
sinon.restore()
|
||||
})
|
||||
|
||||
await t.test('succeeds', async (t) => {
|
||||
await t.test('succeeds', async () => {
|
||||
const { accessToken } = await authenticateUserTest()
|
||||
sinon.stub(prisma, 'message').value({
|
||||
findFirst: async () => {
|
||||
@ -43,18 +45,18 @@ await tap.test('DELETE /messsages/[messageId]', async (t) => {
|
||||
}
|
||||
})
|
||||
const responseJson = response.json()
|
||||
t.equal(response.statusCode, 200)
|
||||
t.equal(responseJson.id, messageExample.id)
|
||||
t.equal(responseJson.value, messageExample.value)
|
||||
t.equal(responseJson.type, messageExample.type)
|
||||
t.equal(responseJson.mimetype, messageExample.mimetype)
|
||||
t.equal(responseJson.member.id, memberExample.id)
|
||||
t.equal(responseJson.member.isOwner, memberExample.isOwner)
|
||||
t.equal(responseJson.member.user.id, userExample.id)
|
||||
t.equal(responseJson.member.user.name, userExample.name)
|
||||
assert.strictEqual(response.statusCode, 200)
|
||||
assert.strictEqual(responseJson.id, messageExample.id)
|
||||
assert.strictEqual(responseJson.value, messageExample.value)
|
||||
assert.strictEqual(responseJson.type, messageExample.type)
|
||||
assert.strictEqual(responseJson.mimetype, messageExample.mimetype)
|
||||
assert.strictEqual(responseJson.member.id, memberExample.id)
|
||||
assert.strictEqual(responseJson.member.isOwner, memberExample.isOwner)
|
||||
assert.strictEqual(responseJson.member.user.id, userExample.id)
|
||||
assert.strictEqual(responseJson.member.user.name, userExample.name)
|
||||
})
|
||||
|
||||
await t.test('fails if the message is not found', async (t) => {
|
||||
await t.test('fails if the message is not found', async () => {
|
||||
const { accessToken } = await authenticateUserTest()
|
||||
sinon.stub(prisma, 'message').value({
|
||||
findFirst: async () => {
|
||||
@ -68,10 +70,10 @@ await tap.test('DELETE /messsages/[messageId]', async (t) => {
|
||||
authorization: `Bearer ${accessToken}`
|
||||
}
|
||||
})
|
||||
t.equal(response.statusCode, 404)
|
||||
assert.strictEqual(response.statusCode, 404)
|
||||
})
|
||||
|
||||
await t.test('fails if the member is not found', async (t) => {
|
||||
await t.test('fails if the member is not found', async () => {
|
||||
const { accessToken } = await authenticateUserTest()
|
||||
sinon.stub(prisma, 'message').value({
|
||||
findFirst: async () => {
|
||||
@ -93,10 +95,10 @@ await tap.test('DELETE /messsages/[messageId]', async (t) => {
|
||||
authorization: `Bearer ${accessToken}`
|
||||
}
|
||||
})
|
||||
t.equal(response.statusCode, 404)
|
||||
assert.strictEqual(response.statusCode, 404)
|
||||
})
|
||||
|
||||
await t.test('fails if the member is not owner of the message', async (t) => {
|
||||
await t.test('fails if the member is not owner of the message', async () => {
|
||||
const { accessToken } = await authenticateUserTest()
|
||||
const randomUserIdOwnerOfMessage = 14
|
||||
sinon.stub(prisma, 'message').value({
|
||||
@ -122,6 +124,6 @@ await tap.test('DELETE /messsages/[messageId]', async (t) => {
|
||||
authorization: `Bearer ${accessToken}`
|
||||
}
|
||||
})
|
||||
t.equal(response.statusCode, 400)
|
||||
assert.strictEqual(response.statusCode, 400)
|
||||
})
|
||||
})
|
||||
|
@ -1,20 +1,22 @@
|
||||
import tap from 'tap'
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import sinon from 'sinon'
|
||||
|
||||
import { application } from '../../../../application.js'
|
||||
import { authenticateUserTest } from '../../../../__test__/utils/authenticateUserTest.js'
|
||||
import prisma from '../../../../tools/database/prisma.js'
|
||||
import { messageExample } from '../../../../models/Message.js'
|
||||
import { memberExample } from '../../../../models/Member.js'
|
||||
import { userExample } from '../../../../models/User.js'
|
||||
import { channelExample } from '../../../../models/Channel.js'
|
||||
import { application } from '#src/application.js'
|
||||
import { authenticateUserTest } from '#src/__test__/utils/authenticateUserTest.js'
|
||||
import prisma from '#src/tools/database/prisma.js'
|
||||
import { messageExample } from '#src/models/Message.js'
|
||||
import { memberExample } from '#src/models/Member.js'
|
||||
import { userExample } from '#src/models/User.js'
|
||||
import { channelExample } from '#src/models/Channel.js'
|
||||
|
||||
await tap.test('PUT /messsages/[messageId]', async (t) => {
|
||||
await test('PUT /messsages/[messageId]', async (t) => {
|
||||
t.afterEach(() => {
|
||||
sinon.restore()
|
||||
})
|
||||
|
||||
await t.test('succeeds', async (t) => {
|
||||
await t.test('succeeds', async () => {
|
||||
const { accessToken } = await authenticateUserTest()
|
||||
const newValue = 'some message'
|
||||
sinon.stub(prisma, 'message').value({
|
||||
@ -48,18 +50,18 @@ await tap.test('PUT /messsages/[messageId]', async (t) => {
|
||||
payload: { value: newValue }
|
||||
})
|
||||
const responseJson = response.json()
|
||||
t.equal(response.statusCode, 200)
|
||||
t.equal(responseJson.id, messageExample.id)
|
||||
t.equal(responseJson.value, newValue)
|
||||
t.equal(responseJson.type, messageExample.type)
|
||||
t.equal(responseJson.mimetype, messageExample.mimetype)
|
||||
t.equal(responseJson.member.id, memberExample.id)
|
||||
t.equal(responseJson.member.isOwner, memberExample.isOwner)
|
||||
t.equal(responseJson.member.user.id, userExample.id)
|
||||
t.equal(responseJson.member.user.name, userExample.name)
|
||||
assert.strictEqual(response.statusCode, 200)
|
||||
assert.strictEqual(responseJson.id, messageExample.id)
|
||||
assert.strictEqual(responseJson.value, newValue)
|
||||
assert.strictEqual(responseJson.type, messageExample.type)
|
||||
assert.strictEqual(responseJson.mimetype, messageExample.mimetype)
|
||||
assert.strictEqual(responseJson.member.id, memberExample.id)
|
||||
assert.strictEqual(responseJson.member.isOwner, memberExample.isOwner)
|
||||
assert.strictEqual(responseJson.member.user.id, userExample.id)
|
||||
assert.strictEqual(responseJson.member.user.name, userExample.name)
|
||||
})
|
||||
|
||||
await t.test('fails if the message is not found', async (t) => {
|
||||
await t.test('fails if the message is not found', async () => {
|
||||
const { accessToken } = await authenticateUserTest()
|
||||
const newValue = 'some message'
|
||||
sinon.stub(prisma, 'message').value({
|
||||
@ -75,10 +77,10 @@ await tap.test('PUT /messsages/[messageId]', async (t) => {
|
||||
},
|
||||
payload: { value: newValue }
|
||||
})
|
||||
t.equal(response.statusCode, 404)
|
||||
assert.strictEqual(response.statusCode, 404)
|
||||
})
|
||||
|
||||
await t.test('fails if the member is not found', async (t) => {
|
||||
await t.test('fails if the member is not found', async () => {
|
||||
const { accessToken } = await authenticateUserTest()
|
||||
const newValue = 'some message'
|
||||
sinon.stub(prisma, 'message').value({
|
||||
@ -102,12 +104,12 @@ await tap.test('PUT /messsages/[messageId]', async (t) => {
|
||||
},
|
||||
payload: { value: newValue }
|
||||
})
|
||||
t.equal(response.statusCode, 404)
|
||||
assert.strictEqual(response.statusCode, 404)
|
||||
})
|
||||
|
||||
await t.test(
|
||||
'fails if the member is not the owner of the message',
|
||||
async (t) => {
|
||||
async () => {
|
||||
const { accessToken } = await authenticateUserTest()
|
||||
const newValue = 'some message'
|
||||
const randomUserIdOwnerOfMessage = 14
|
||||
@ -135,7 +137,7 @@ await tap.test('PUT /messsages/[messageId]', async (t) => {
|
||||
},
|
||||
payload: { value: newValue }
|
||||
})
|
||||
t.equal(response.statusCode, 400)
|
||||
assert.strictEqual(response.statusCode, 400)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
@ -2,12 +2,12 @@ import type { Static } from '@sinclair/typebox'
|
||||
import { Type } from '@sinclair/typebox'
|
||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||
|
||||
import prisma from '../../../tools/database/prisma.js'
|
||||
import { fastifyErrors } from '../../../models/utils.js'
|
||||
import authenticateUser from '../../../tools/plugins/authenticateUser.js'
|
||||
import { messageSchema } from '../../../models/Message.js'
|
||||
import { memberSchema } from '../../../models/Member.js'
|
||||
import { userPublicWithoutSettingsSchema } from '../../../models/User.js'
|
||||
import prisma from '#src/tools/database/prisma.js'
|
||||
import { fastifyErrors } from '#src/models/utils.js'
|
||||
import authenticateUser from '#src/tools/plugins/authenticateUser.js'
|
||||
import { messageSchema } from '#src/models/Message.js'
|
||||
import { memberSchema } from '#src/models/Member.js'
|
||||
import { userPublicWithoutSettingsSchema } from '#src/models/User.js'
|
||||
|
||||
const parametersSchema = Type.Object({
|
||||
messageId: messageSchema.id
|
||||
@ -53,8 +53,8 @@ export const deleteMessageService: FastifyPluginAsync = async (fastify) => {
|
||||
if (request.user == null) {
|
||||
throw fastify.httpErrors.forbidden()
|
||||
}
|
||||
const { user } = request
|
||||
const { messageId } = request.params
|
||||
const { user, params } = request
|
||||
const { messageId } = params
|
||||
const messageCheck = await prisma.message.findFirst({
|
||||
where: { id: messageId },
|
||||
include: {
|
||||
|
@ -2,12 +2,12 @@ import type { Static } from '@sinclair/typebox'
|
||||
import { Type } from '@sinclair/typebox'
|
||||
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
|
||||
|
||||
import prisma from '../../../tools/database/prisma.js'
|
||||
import { fastifyErrors } from '../../../models/utils.js'
|
||||
import authenticateUser from '../../../tools/plugins/authenticateUser.js'
|
||||
import { messageSchema } from '../../../models/Message.js'
|
||||
import { memberSchema } from '../../../models/Member.js'
|
||||
import { userPublicWithoutSettingsSchema } from '../../../models/User.js'
|
||||
import prisma from '#src/tools/database/prisma.js'
|
||||
import { fastifyErrors } from '#src/models/utils.js'
|
||||
import authenticateUser from '#src/tools/plugins/authenticateUser.js'
|
||||
import { messageSchema } from '#src/models/Message.js'
|
||||
import { memberSchema } from '#src/models/Member.js'
|
||||
import { userPublicWithoutSettingsSchema } from '#src/models/User.js'
|
||||
|
||||
const bodyPutServiceSchema = Type.Object({
|
||||
value: messageSchema.value
|
||||
@ -61,9 +61,9 @@ export const putMessageService: FastifyPluginAsync = async (fastify) => {
|
||||
if (request.user == null) {
|
||||
throw fastify.httpErrors.forbidden()
|
||||
}
|
||||
const { user } = request
|
||||
const { messageId } = request.params
|
||||
const { value } = request.body
|
||||
const { user, params, body } = request
|
||||
const { messageId } = params
|
||||
const { value } = body
|
||||
const messageCheck = await prisma.message.findFirst({
|
||||
where: { id: messageId, type: 'text' },
|
||||
include: {
|
||||
|
Reference in New Issue
Block a user