room reservation model, controller, seeder and migration files added

This commit is contained in:
Kiss Dávid
2026-08-19 19:59:18 +02:00
parent b281724a1a
commit 0b88fe87e5
49 changed files with 4073 additions and 2472 deletions
+62
View File
@@ -0,0 +1,62 @@
import { test } from '@japa/runner'
test.group('Images show', () => {
test('get uploaded image', async ({ client, assert }) => {
// 1. Login to get token
const loginResponse = await client.post('/api/login').json({
email: 'kiss.david@test.hu',
password: 'Password123',
})
loginResponse.assertStatus(200)
const token = loginResponse.body().token
// 2. Upload an image
const response = await client
.post('/api/images/upload')
.header('Authorization', `Bearer ${token}`)
.file('image', Buffer.from('fake image content'), {
filename: 'test.jpg',
contentType: 'image/jpeg',
})
response.assertStatus(200)
const { url } = response.body()
// 3. Try to fetch the image
const showResponse = await client.get(url)
if (showResponse.status() === 404) {
console.log('404 Body:', showResponse.body())
}
showResponse.assertStatus(200)
assert.equal(showResponse.header('content-type'), 'image/jpeg')
})
test('get uploaded thumbnail', async ({ client, assert }) => {
// 1. Login to get token
const loginResponse = await client.post('/api/login').json({
email: 'kiss.david@test.hu',
password: 'Password123',
})
loginResponse.assertStatus(200)
const token = loginResponse.body().token
const response = await client
.post('/api/images/upload')
.header('Authorization', `Bearer ${token}`)
.file('image', Buffer.from('fake image content'), {
filename: 'test.jpg',
contentType: 'image/jpeg',
})
response.assertStatus(200)
const { thumbnailUrl } = response.body()
const showResponse = await client.get(thumbnailUrl)
showResponse.assertStatus(200)
assert.equal(showResponse.header('content-type'), 'image/jpeg')
})
})