Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions apps/web/__tests__/issuer-policy-review.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
Expand Down Expand Up @@ -523,3 +524,43 @@ describe('Policy Review Surface — UI render guards', () => {
}
});
});

describe('policyReview.ts — purity guard (no I/O, no DB, no audit writes)', () => {
it('source contains no fetch / axios / network / db / audit-writer tokens', () => {
const src = readFileSync(
new URL(
'../lib/issuer-verification/policyReview.ts',
import.meta.url,
),
'utf8',
);
const banned = [
'fetch(',
'axios',
'XMLHttpRequest',
'navigator.sendBeacon',
'prisma.',
'recordAudit',
'recordAuditEvent',
"import('@/",
'require(',
];
for (const phrase of banned) {
expect(src).not.toContain(phrase);
}
});

it('does not statically import any backend module', () => {
const src = readFileSync(
new URL(
'../lib/issuer-verification/policyReview.ts',
import.meta.url,
),
'utf8',
);
expect(src).not.toMatch(/from ['"]apps\/api/);
expect(src).not.toMatch(/from ['"]@vitalcv\/psv['"]/);
expect(src).not.toMatch(/from ['"][^'"]*prisma_client['"]/);
expect(src).not.toMatch(/from ['"][^'"]*psvReceipts\.repo['"]/);
});
});
41 changes: 41 additions & 0 deletions apps/web/__tests__/issuer-verification.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import {
PARTNER_CATEGORY_LABEL,
Expand Down Expand Up @@ -244,3 +245,43 @@ describe('Issuer Verification — Banned Strings', () => {
}
});
});

describe('receiptCandidate.ts — purity guard (no I/O, no DB, no audit writes)', () => {
it('source contains no fetch / axios / network / db / audit-writer tokens', () => {
const src = readFileSync(
new URL(
'../lib/issuer-verification/receiptCandidate.ts',
import.meta.url,
),
'utf8',
);
const banned = [
'fetch(',
'axios',
'XMLHttpRequest',
'navigator.sendBeacon',
'prisma.',
'recordAudit',
'recordAuditEvent',
"import('@/",
'require(',
];
for (const phrase of banned) {
expect(src).not.toContain(phrase);
}
});

it('does not statically import any backend module', () => {
const src = readFileSync(
new URL(
'../lib/issuer-verification/receiptCandidate.ts',
import.meta.url,
),
'utf8',
);
expect(src).not.toMatch(/from ['"]apps\/api/);
expect(src).not.toMatch(/from ['"]@vitalcv\/psv['"]/);
expect(src).not.toMatch(/from ['"][^'"]*prisma_client['"]/);
expect(src).not.toMatch(/from ['"][^'"]*psvReceipts\.repo['"]/);
});
});
Loading