forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontract-drift.test.ts
More file actions
36 lines (28 loc) · 1.41 KB
/
Copy pathcontract-drift.test.ts
File metadata and controls
36 lines (28 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { describe, it, expect } from 'vitest';
import { execSync } from 'node:child_process';
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
const ROOT = resolve(__dirname, '..');
describe('Contract Drift Check', () => {
it('CI workflow file exists and contains drift detection logic', () => {
const workflowPath = resolve(ROOT, '.github', 'workflows', 'contract-drift.yml');
const content = readFileSync(workflowPath, 'utf-8');
expect(content).toContain('npm run codegen');
expect(content).toContain('git diff --exit-code src/generated/types.ts');
expect(content).toContain('CONTRACT DRIFT DETECTED');
});
it('PR template mentions contract regeneration', () => {
const templatePath = resolve(ROOT, '.github', 'PULL_REQUEST_TEMPLATE.md');
const content = readFileSync(templatePath, 'utf-8');
expect(content).toContain('npm run codegen');
expect(content).toContain('src/generated/types.ts');
expect(content).toContain('CODEGEN.md');
});
it('regenerating contracts produces no diff (no drift)', () => {
// Run codegen and check that output matches committed file
const before = readFileSync(resolve(ROOT, 'src', 'generated', 'types.ts'), 'utf-8');
execSync('npx tsx scripts/codegen.ts', { cwd: ROOT, stdio: 'pipe' });
const after = readFileSync(resolve(ROOT, 'src', 'generated', 'types.ts'), 'utf-8');
expect(after).toBe(before);
});
});