@davoodmehraban89 / LifeMate / commits / 5461e06
Fork 0

LifeMate — Personal, Family & Learning Companion

test: define phase 5 operations contract

davoodmehraban89 committed Oct 5, 2026 at 17:08 UTC 5461e06772c35bc208a902b2fe0474b095bc9c32
1 file changed +30
backend/tests/operations_contract.test.js new
+30
@@ -0,0 +1,30 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import fs from 'node:fs';
4 +
5 +const operations = fs.readFileSync(new URL('../src/operations.js', import.meta.url), 'utf8');
6 +const server = fs.readFileSync(new URL('../src/server.js', import.meta.url), 'utf8');
7 +
8 +test('operations layer provides correlation, safe telemetry and security headers', () => {
9 + assert.match(operations, /x-request-id/i);
10 + assert.match(operations, /x-content-type-options/i);
11 + assert.match(operations, /x-frame-options/i);
12 + assert.match(operations, /referrer-policy/i);
13 + assert.match(operations, /durationMs/);
14 + assert.doesNotMatch(operations, /req\.body/);
15 + assert.doesNotMatch(operations, /authorization/i);
16 +});
17 +
18 +test('operations layer defines bounded rate-limit profiles and retry-after', () => {
19 + assert.match(operations, /120/);
20 + assert.match(operations, /10\s*\*\s*60/);
21 + assert.match(operations, /30/);
22 + assert.match(operations, /Retry-After/);
23 + assert.match(operations, /rate_limited/);
24 +});
25 +
26 +test('server exposes liveness and database readiness separately', () => {
27 + assert.match(server, /app\.get\('\/live'/);
28 + assert.match(server, /app\.get\('\/ready'/);
29 + assert.match(server, /select 1 as ok/);
30 +});