fix: update dependencies to latest

This commit is contained in:
2023-07-22 16:26:27 +02:00
parent 23d2a9da71
commit 9a1684e22b
123 changed files with 2322 additions and 5765 deletions

View File

@ -1,15 +1,17 @@
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 { application } from '#src/application.js'
import { authenticateUserTest } from '#src/__test__/utils/authenticateUserTest.js'
await tap.test('GET /users/current', async (t) => {
await test('GET /users/current', async (t) => {
t.afterEach(() => {
sinon.restore()
})
await t.test('succeeds', async (t) => {
await t.test('succeeds', async () => {
const { accessToken, user } = await authenticateUserTest()
const response = await application.inject({
method: 'GET',
@ -19,16 +21,16 @@ await tap.test('GET /users/current', async (t) => {
}
})
const responseJson = response.json()
t.equal(response.statusCode, 200)
t.equal(responseJson.user.name, user.name)
t.strictSame(responseJson.user.strategies, ['Local'])
assert.strictEqual(response.statusCode, 200)
assert.strictEqual(responseJson.user.name, user.name)
assert.deepStrictEqual(responseJson.user.strategies, ['Local'])
})
await t.test('fails with unauthenticated user', async (t) => {
await t.test('fails with unauthenticated user', async () => {
const response = await application.inject({
method: 'GET',
url: '/users/current'
})
t.equal(response.statusCode, 401)
assert.strictEqual(response.statusCode, 401)
})
})

View File

@ -1,16 +1,18 @@
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 prisma from '../../../../tools/database/prisma.js'
import { authenticateUserTest } from '../../../../__test__/utils/authenticateUserTest.js'
import { application } from '#src/application.js'
import prisma from '#src/tools/database/prisma.js'
import { authenticateUserTest } from '#src/__test__/utils/authenticateUserTest.js'
await tap.test('PUT /users/current', async (t) => {
await test('PUT /users/current', async (t) => {
t.afterEach(() => {
sinon.restore()
})
await t.test('succeeds with valid accessToken and valid name', async (t) => {
await t.test('succeeds with valid accessToken and valid name', async () => {
const newName = 'John Doe'
const { accessToken, user, userStubValue } = await authenticateUserTest()
sinon.stub(prisma, 'user').value({
@ -36,11 +38,11 @@ await tap.test('PUT /users/current', async (t) => {
}
})
const responseJson = response.json()
t.equal(response.statusCode, 200)
t.equal(responseJson.user.name, newName)
assert.strictEqual(response.statusCode, 200)
assert.strictEqual(responseJson.user.name, newName)
})
await t.test('succeeds and only update the status', async (t) => {
await t.test('succeeds and only update the status', async () => {
const newStatus = '👀 Working on secret projects...'
const { accessToken, user, userStubValue } = await authenticateUserTest()
sinon.stub(prisma, 'user').value({
@ -66,12 +68,12 @@ await tap.test('PUT /users/current', async (t) => {
}
})
const responseJson = response.json()
t.equal(response.statusCode, 200)
t.equal(responseJson.user.name, user.name)
t.equal(responseJson.user.status, newStatus)
assert.strictEqual(response.statusCode, 200)
assert.strictEqual(responseJson.user.name, user.name)
assert.strictEqual(responseJson.user.status, newStatus)
})
await t.test('fails with name already used', async (t) => {
await t.test('fails with name already used', async () => {
const newName = 'John Doe'
const { accessToken, user, userStubValue } = await authenticateUserTest()
sinon.stub(prisma, 'user').value({
@ -90,10 +92,10 @@ await tap.test('PUT /users/current', async (t) => {
name: newName
}
})
t.equal(response.statusCode, 400)
assert.strictEqual(response.statusCode, 400)
})
await t.test('fails with invalid website url', async (t) => {
await t.test('fails with invalid website url', async () => {
const newWebsite = 'invalid website url'
const { accessToken } = await authenticateUserTest()
const response = await application.inject({
@ -106,10 +108,10 @@ await tap.test('PUT /users/current', async (t) => {
website: newWebsite
}
})
t.equal(response.statusCode, 400)
assert.strictEqual(response.statusCode, 400)
})
await t.test('succeeds with valid website url', async (t) => {
await t.test('succeeds with valid website url', async () => {
const newWebsite = 'https://somerandomwebsite.com'
const { accessToken, user, userStubValue } = await authenticateUserTest()
sinon.stub(prisma, 'user').value({
@ -135,8 +137,8 @@ await tap.test('PUT /users/current', async (t) => {
}
})
const responseJson = response.json()
t.equal(response.statusCode, 200)
t.equal(responseJson.user.name, user.name)
t.equal(responseJson.user.website, newWebsite)
assert.strictEqual(response.statusCode, 200)
assert.strictEqual(responseJson.user.name, user.name)
assert.strictEqual(responseJson.user.website, newWebsite)
})
})

View File

@ -1,9 +1,9 @@
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 { userCurrentSchema } 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 { userCurrentSchema } from '#src/models/User.js'
const getCurrentUserSchema: FastifySchema = {
description: 'GET the current connected user',

View File

@ -2,10 +2,10 @@ import { Type } from '@sinclair/typebox'
import type { FastifyPluginAsync, FastifySchema } from 'fastify'
import fastifyMultipart from '@fastify/multipart'
import authenticateUser from '../../../../tools/plugins/authenticateUser.js'
import { fastifyErrors } from '../../../../models/utils.js'
import prisma from '../../../../tools/database/prisma.js'
import { uploadFile } from '../../../../tools/utils/uploadFile.js'
import authenticateUser from '#src/tools/plugins/authenticateUser.js'
import { fastifyErrors } from '#src/models/utils.js'
import prisma from '#src/tools/database/prisma.js'
import { uploadFile } from '#src/tools/utils/uploadFile.js'
const putServiceSchema: FastifySchema = {
description: 'Edit the current connected user logo',

View File

@ -4,14 +4,14 @@ 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 { userCurrentSchema, userSchema } from '../../../models/User.js'
import { sendEmail } from '../../../tools/email/sendEmail.js'
import { API_URL } from '../../../tools/configurations.js'
import type { Language, Theme } from '../../../models/UserSettings.js'
import { parseStringNullish } from '../../../tools/utils/parseStringNullish.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 { userCurrentSchema, userSchema } from '#src/models/User.js'
import { sendEmail } from '#src/tools/email/sendEmail.js'
import { API_URL } from '#src/tools/configurations.js'
import type { Language, Theme } from '#src/models/UserSettings.js'
import { parseStringNullish } from '#src/tools/utils/parseStringNullish.js'
const bodyPutServiceSchema = Type.Object({
name: Type.Optional(userSchema.name),

View File

@ -1,19 +1,21 @@
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 { userSettingsExample } from '../../../../../models/UserSettings.js'
import { application } from '#src/application.js'
import { authenticateUserTest } from '#src/__test__/utils/authenticateUserTest.js'
import prisma from '#src/tools/database/prisma.js'
import { userSettingsExample } from '#src/models/UserSettings.js'
await tap.test('PUT /users/current/settings', async (t) => {
await test('PUT /users/current/settings', async (t) => {
t.afterEach(() => {
sinon.restore()
})
await t.test(
'succeeds and edit the theme, language, isPublicEmail and isPublicGuilds',
async (t) => {
async () => {
const newSettings = {
theme: 'light',
language: 'fr',
@ -42,15 +44,21 @@ await tap.test('PUT /users/current/settings', async (t) => {
payload: newSettings
})
const responseJson = response.json()
t.equal(response.statusCode, 200)
t.equal(responseJson.settings.theme, newSettings.theme)
t.equal(responseJson.settings.language, newSettings.language)
t.equal(responseJson.settings.isPublicEmail, newSettings.isPublicEmail)
t.equal(responseJson.settings.isPublicGuilds, newSettings.isPublicGuilds)
assert.strictEqual(response.statusCode, 200)
assert.strictEqual(responseJson.settings.theme, newSettings.theme)
assert.strictEqual(responseJson.settings.language, newSettings.language)
assert.strictEqual(
responseJson.settings.isPublicEmail,
newSettings.isPublicEmail
)
assert.strictEqual(
responseJson.settings.isPublicGuilds,
newSettings.isPublicGuilds
)
}
)
await t.test('fails with invalid language', async (t) => {
await t.test('fails with invalid language', async () => {
const newSettings = {
language: 'somerandomlanguage'
}
@ -75,6 +83,6 @@ await tap.test('PUT /users/current/settings', async (t) => {
},
payload: newSettings
})
t.equal(response.statusCode, 400)
assert.strictEqual(response.statusCode, 400)
})
})

View File

@ -2,10 +2,10 @@ 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 { userSettingsSchema } from '../../../../models/UserSettings.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 { userSettingsSchema } from '#src/models/UserSettings.js'
const bodyPutServiceSchema = Type.Object({
theme: Type.Optional(userSettingsSchema.theme),