import assert from 'node:assert/strict'; import fs from 'node:fs/promises'; import path from 'node:path'; import test from 'node:test'; const root = path.resolve(import.meta.dirname, '..'); async function read(relativePath) { return fs.readFile(path.join(root, relativePath), 'utf8'); } test('default server socket uses the local Wegwichtel endpoint', async () => { const configSource = await read('src/config.js'); const envExample = await read('.env.example'); const serverSource = await read('server.js'); const apiSource = await read('src/routes/api.js'); assert.match(configSource, /process\.env\.HOST \|\| '127\.0\.0\.1'/); assert.match(configSource, /process\.env\.PORT \|\| '47145'/); assert.match(envExample, /^HOST=127\.0\.0\.1$/m); assert.match(envExample, /^PORT=47145$/m); assert.doesNotMatch(configSource, /instanceName|INSTANCE_NAME/); assert.doesNotMatch(envExample, /INSTANCE_NAME/); assert.match(serverSource, /Wegwichtel läuft auf http:\/\/\$\{config\.host\}:\$\{config\.port\}/); assert.doesNotMatch(apiSource, /instance:/); }); test('retired internal instance label is absent from the project', async () => { const files = [ '.env.example', 'README.md', 'server.js', 'src/config.js', 'src/routes/api.js', 'public/index.html' ]; const content = (await Promise.all(files.map(read))).join('\n'); const retiredLabel = ['at', 'las'].join(''); assert.doesNotMatch(content, new RegExp(retiredLabel, 'i')); });