Reorganize app workspaces and align Admin architecture

This commit is contained in:
Igor Martyniuk
2026-07-17 13:46:21 +00:00
parent ba691d3a0c
commit 0ba01cd111
183 changed files with 3745 additions and 4354 deletions
+6
View File
@@ -0,0 +1,6 @@
# Base URL for supertest when hitting a running server
BASE_URL=http://127.0.0.1:3333
# Admin credentials
ADMIN_EMAIL=admin@admin.com
ADMIN_PASSWORD=1234qqqq
+6
View File
@@ -0,0 +1,6 @@
# Base URL for supertest when hitting a running server
BASE_URL=http://127.0.0.1:3333
# Admin credentials
ADMIN_EMAIL=admin@admin.com
ADMIN_PASSWORD=1234qqqq
+6
View File
@@ -0,0 +1,6 @@
# Base URL for supertest when hitting a running server
BASE_URL=http://127.0.0.1:3333
# Admin credentials
ADMIN_EMAIL=admin@admin.com
ADMIN_PASSWORD=1234qqqq
+45
View File
@@ -0,0 +1,45 @@
// apps/backend/tests/bootstrap.ts
import { assert } from '@japa/assert'
import { apiClient } from '@japa/api-client'
import { pluginAdonisJS } from '@japa/plugin-adonisjs'
import { specReporter } from '@japa/spec-reporter'
import type { Config } from '@japa/runner/types'
import app from '@adonisjs/core/services/app'
import testUtils from '@adonisjs/core/services/test_utils'
/**
* Japa plugins
*/
export const plugins: Config['plugins'] = [assert(), apiClient(), pluginAdonisJS(app)]
/**
* Reporters
*/
export const reporters: Config['reporters'] = {
activated: ['spec'],
list: [
{
name: 'spec',
handler: specReporter(),
},
],
}
/**
* Global setup/teardown (for ALL suites)
*/
export const runnerHooks: Required<Pick<Config, 'setup' | 'teardown'>> = {
setup: [],
teardown: [],
}
/**
* Per-suite configuration (start HTTP server for HTTP tests)
*/
export const configureSuite: Config['configureSuite'] = (suite) => {
// adjust names to your suites if needed
if (['functional', 'e2e', 'browser'].includes(suite.name)) {
suite.setup(() => testUtils.httpServer().start())
}
}
+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
}