Initial commit

This commit is contained in:
Igor Martyniuk
2026-06-25 15:53:49 +03:00
commit 1bb0b7e68a
1517 changed files with 218469 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import type { ApiClient } from '@japa/api-client'
/**
* Logs in as Admin using the test HTTP client.
* Returns a Bearer token string.
*/
export async function loginAsAdmin(client: ApiClient): Promise<string> {
const email = process.env.ADMIN_EMAIL || 'admin@admin.com'
const password = process.env.ADMIN_PASSWORD || '1234qqqq'
const res = await client.post('/auth/login').json({ email, password })
res.assertStatus(200)
const body = res.body()
// returns: { type, token, user }
const token = body?.token?.release?.() || body?.token || body?.access_token
if (!token) {
console.error('Login response body:', body)
throw new Error('Could not acquire admin token from /auth/login response')
}
return token
}