-
-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy pathsession-status.test.ts
More file actions
67 lines (58 loc) · 2.66 KB
/
session-status.test.ts
File metadata and controls
67 lines (58 loc) · 2.66 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { clearDaemonActivityRegistry } from '../../../daemon/activity-registry.ts';
import { getDefaultDebuggerManager } from '../../../utils/debugger/index.ts';
import { activeLogSessions } from '../../../utils/log_capture.ts';
import { activeDeviceLogSessions } from '../../../utils/log-capture/device-log-sessions.ts';
import { clearAllProcesses } from '../../tools/swift-package/active-processes.ts';
import sessionStatusResource, { sessionStatusResourceLogic } from '../session-status.ts';
describe('session-status resource', () => {
beforeEach(async () => {
activeLogSessions.clear();
activeDeviceLogSessions.clear();
clearAllProcesses();
clearDaemonActivityRegistry();
await getDefaultDebuggerManager().disposeAll();
});
afterEach(async () => {
activeLogSessions.clear();
activeDeviceLogSessions.clear();
clearAllProcesses();
clearDaemonActivityRegistry();
await getDefaultDebuggerManager().disposeAll();
});
describe('Export Field Validation', () => {
it('should export correct uri', () => {
expect(sessionStatusResource.uri).toBe('xcodebuildmcp://session-status');
});
it('should export correct description', () => {
expect(sessionStatusResource.description).toBe(
'Runtime session state for log capture and debugging',
);
});
it('should export correct mimeType', () => {
expect(sessionStatusResource.mimeType).toBe('application/json');
});
it('should export handler function', () => {
expect(typeof sessionStatusResource.handler).toBe('function');
});
});
describe('Handler Functionality', () => {
it('should return empty status when no sessions exist', async () => {
const result = await sessionStatusResourceLogic();
expect(result.contents).toHaveLength(1);
const parsed = JSON.parse(result.contents[0].text);
expect(parsed.logging.simulator.activeSessionIds).toEqual([]);
expect(parsed.logging.device.activeSessionIds).toEqual([]);
expect(parsed.debug.currentSessionId).toBe(null);
expect(parsed.debug.sessionIds).toEqual([]);
expect(parsed.watcher).toEqual({ running: false, watchedPath: null });
expect(parsed.video.activeSessionIds).toEqual([]);
expect(parsed.swiftPackage.activePids).toEqual([]);
expect(parsed.activity).toEqual({ activeOperationCount: 0, byCategory: {} });
expect(parsed.process.pid).toBeTypeOf('number');
expect(parsed.process.uptimeMs).toBeTypeOf('number');
expect(parsed.process.rssBytes).toBeTypeOf('number');
expect(parsed.process.heapUsedBytes).toBeTypeOf('number');
});
});
});