chore: seminarhof customer project

This commit is contained in:
e2e
2026-07-10 23:27:29 +02:00
commit 3c84c9ff80
188 changed files with 20779 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
# Environment variables required by createConfig() during tests.
# Add any env vars your config.ts reads at module load time.
# This file is loaded via --env-file and is NOT committed to version control.
NODE_ENV=test

View File

@@ -0,0 +1,24 @@
{
"name": "tests",
"version": "0.0.1",
"private": true,
"type": "module",
"description": "Function test harness — Cucumber over in-process Pikku RPC with stubbed services.",
"scripts": {
"test": "node --env-file=.env.test node_modules/.bin/cucumber-js --config tests/cucumber.mjs --tags 'not @skip'",
"test:tag": "node --env-file=.env.test node_modules/.bin/cucumber-js --config tests/cucumber.mjs --tags",
"coverage": "pikku tests coverage",
"tsc": "tsc --noEmit"
},
"dependencies": {
"@pikku/cucumber": "0.12.9",
"@pikku/kysely-node-sqlite": "^0.12.3"
},
"devDependencies": {
"@cucumber/cucumber": "^11.0.0",
"@types/node": "^22",
"c8": "^10.0.0",
"tsx": "^4.21.0",
"typescript": "~5.8.0"
}
}

View File

@@ -0,0 +1,7 @@
export default {
requireModule: ['tsx'],
require: ['tests/support/**/*.ts', 'tests/steps/**/*.ts'],
paths: ['tests/features/**/*.feature'],
format: ['progress', 'html:tests/reports/cucumber-report.html'],
forceExit: true,
}

View File

@@ -0,0 +1,24 @@
Feature: Example function test
Starter scenario created by `pikku tests init`. It uses only the built-in
pikku/cucumber steps (no custom step code) and passes out of the box, so the
Run-tests button and coverage report work immediately. Replace it with real
scenarios that call your RPCs see the commented example at the bottom.
Scenario: the function-test harness is wired up
Given the data "example" is:
| hello | world |
Then the data "example" is not empty
# Real example — call one of your RPCs and assert the outcome. Uncomment and
# adapt (run `pikku meta` to list versioned RPC names and input schemas):
#
# Scenario: an anonymous user cannot reach a protected RPC
# When an anonymous user calls "yourProtectedRpc"
# Then the call fails with "Unauthorized"
#
# Scenario: a public RPC returns data
# When an anonymous user calls "yourPublicRpc" with:
# | someField | someValue |
# Then the call succeeds
# And the result has "id"

View File

@@ -0,0 +1,7 @@
import '../../../.pikku/pikku-bootstrap.gen.js'
import { Before, After, BeforeAll, AfterAll, setDefaultTimeout, Given, When, Then } from '@cucumber/cucumber'
import { registerHooks, registerCommonSteps } from '@pikku/cucumber'
import { db } from './services.js'
registerHooks({ Before, After, BeforeAll, AfterAll, setDefaultTimeout }, db)
registerCommonSteps({ Given, When, Then })

View File

@@ -0,0 +1,44 @@
import { createNodeSqliteKysely, createCoercionPlugin } from '@pikku/kysely-node-sqlite'
import { createDbUtils, type StubTracker } from '@pikku/cucumber'
import { createConfig } from '../../../src/config.js'
import { createSingletonServices } from '../../../src/services.js'
import { coercionMap } from '../../../.pikku/db/coercion.gen.js'
import type { DB } from '../../../.pikku/db/schema.js'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const repoRoot = (p: string) => resolve(__dirname, '../../../../..', p)
export const db = createDbUtils({
migrationsDir: repoRoot('db/sqlite'),
seedFile: repoRoot('db/sqlite-seed.sql'),
})
type StubKysely = ReturnType<typeof createNodeSqliteKysely<DB>>
const REAL_SERVICES = (kysely: StubKysely) => ({ kysely })
export async function createStubServices(dbFile: string, tracker: StubTracker) {
const kysely = createNodeSqliteKysely<DB>({
filename: dbFile,
camelCase: true,
plugins: [createCoercionPlugin({ map: coercionMap })],
})
const real = REAL_SERVICES(kysely)
const injected = new Proxy(real as Record<string, unknown>, {
get(target, prop: string) {
if (prop in target) return target[prop]
return tracker.stub(prop)
},
})
const config = await createConfig()
const services = await createSingletonServices(
{ ...config, dev: { db: { file: dbFile } } } as never,
injected as never,
)
return { services, kysely }
}

View File

@@ -0,0 +1,5 @@
import { World, setWorldConstructor } from '@cucumber/cucumber'
import { createFunctionWorld } from '@pikku/cucumber'
import { createStubServices } from './services.js'
createFunctionWorld(World, setWorldConstructor, createStubServices)

View File

@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"types": [
"node"
],
"noEmit": true,
"skipLibCheck": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"strict": true
},
"include": [
"tests/**/*.ts"
]
}