File size: 1,700 Bytes
94193b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { describe, it, expect, vi } from 'vitest';

const PREVIEW_HTML = `<!DOCTYPE html>
<html><head>
<script>
// Console Capture - Auto-injected by OSW Studio
(function() { var levels = ['log']; })();
</script>
<script>
// VFS Asset Interceptor
(function() { var map = {}; })();
</script>
<title>My Page</title>
</head><body>real content</body></html>`;

const mockVfs = {
  init: vi.fn(),
  readFile: vi.fn(),
  writeFile: vi.fn(),
  createFile: vi.fn(),
  listFiles: vi.fn().mockResolvedValue([]),
  listDirectories: vi.fn().mockResolvedValue([]),
  deleteFile: vi.fn(),
  renameFile: vi.fn(),
  getFileTree: vi.fn().mockResolvedValue([]),
  getProject: vi.fn().mockResolvedValue({ id: 'test-project', settings: { runtime: 'static' } }),
};

vi.mock('@/lib/vfs', () => ({
  getActiveVFS: () => mockVfs,
  vfs: mockVfs,
}));

vi.mock('@/lib/utils', () => ({
  logger: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
}));

vi.mock('@/lib/preview/virtual-server', () => ({
  VirtualServer: class {
    async getCompiledFile() {
      return { path: '/index.html', content: PREVIEW_HTML, mimeType: 'text/html' };
    }
  },
}));

describe('cli-shell curl command', () => {
  it('strips preview instrumentation from fetched pages', async () => {
    const { vfsShell } = await import('../cli-shell');

    const result = await vfsShell.execute('test-project', ['curl', '-s', 'localhost/']);

    expect(result.success).toBe(true);
    expect(result.stdout).not.toContain('Console Capture');
    expect(result.stdout).not.toContain('VFS Asset Interceptor');
    expect(result.stdout).toContain('<title>My Page</title>');
    expect(result.stdout).toContain('real content');
  });
});