File size: 1,735 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
import { describe, it, expect, vi } from 'vitest';

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([]),
};

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() },
}));

describe('cli-shell status command', () => {
  it('acknowledges without echoing task/done text back (token duplication)', async () => {
    const { vfsShell } = await import('../cli-shell');

    const result = await vfsShell.execute('test-project', [
      'status', '--task', 'build the landing page', '--done', 'created index.html with hero and CTA', '--remaining', 'none', '--complete',
    ]);

    expect(result.success).toBe(true);
    // Machine-readable lines the loop depends on
    expect(result.stdout).toMatch(/^Remaining:\s*none/m);
    expect(result.stdout).toMatch(/^Complete:\s*yes/m);
    // No verbatim echo of the long fields
    expect(result.stdout).not.toContain('created index.html with hero and CTA');
    expect(result.stdout).not.toContain('build the landing page');
  });

  it('reports Complete: no without the --complete flag', async () => {
    const { vfsShell } = await import('../cli-shell');

    const result = await vfsShell.execute('test-project', [
      'status', '--task', 't', '--done', 'd', '--remaining', 'fix nav',
    ]);

    expect(result.stdout).toMatch(/^Remaining:\s*fix nav/m);
    expect(result.stdout).toMatch(/^Complete:\s*no/m);
  });
});