openvibers/openvibe.finance testllms-full.test.js

llms-full.test.js

main 2.0 KB · 35 lines · javascript

1'use strict';
2// /llms-full.txt (SEO-33): the welcome page llms.txt lists, as words, open to every crawler (11-28: it was a 404 to
3// agents, tools/llms-check.js). Signed out, as a crawler sees it: never anyone's money.
4const assert = require('assert');
5const path = require('node:path');
6const crypto = require('node:crypto');
7const { createTestDb } = require('openvibe-sdk/testing');
8const { createVault } = require('../server/crypto');
9const { createApp } = require('../server/app');
10
11(async () => {
12 const { db, close } = await createTestDb({ migrations: path.join(__dirname, '..', 'migrations'), store: process.env.FINANCE_TEST_STORE || 'pglite', service: 'finance' });
13 const vault = createVault(crypto.randomBytes(32).toString('base64'));
14 const auth = { router: (express) => express.Router(), optionalAuth: () => (req, _res, next) => next() };
15 const server = createApp({ db, vault, auth }).listen(0, '127.0.0.1');
16 await new Promise((r) => server.once('listening', r));
17 const base = `http://127.0.0.1:${server.address().port}`;
18 try {
19 const r = await fetch(`${base}/llms-full.txt`);
20 assert.strictEqual(r.status, 200);
21 assert.match(r.headers.get('content-type'), /^text\/plain/);
22 assert.ok(!/noindex/.test(r.headers.get('x-robots-tag') || ''), 'open to crawlers');
23 const text = await r.text();
24 assert.ok(text.startsWith('# OpenVibe.Finance'), 'the same header as llms.txt');
25 assert.ok(text.includes('Your money, your rules, your data'), 'the welcome page\'s words');
26 assert.ok(text.length > 500 && !/<(?:script|style|section)\b/i.test(text), 'words, not markup');
27 const llms = await (await fetch(`${base}/llms.txt`)).text();
28 assert.ok(llms.includes('(https://openvibe.finance/llms-full.txt)'), 'llms.txt points at it');
29 } finally {
30 server.close();
31 await close();
32 }
33 console.log('llms-full: the welcome page as words, linked from llms.txt, open to crawlers');
34})().catch((e) => { console.error(e); process.exit(1); });
35