feat(companion): allow platform disconnect code and reason
This commit is contained in:
@@ -338,8 +338,18 @@ describe('platform clients integration', () => {
|
||||
expect(client.connected).toBe(false);
|
||||
await client.connect();
|
||||
expect(client.connected).toBe(true);
|
||||
client.disconnect();
|
||||
client.disconnect(4100, 'manual platform stop');
|
||||
expect(client.connected).toBe(false);
|
||||
expect(client.getConnectionSnapshot()).toEqual({
|
||||
connected: false,
|
||||
eventSubscriptionCount: 0,
|
||||
pendingRequestCount: 0,
|
||||
pendingEventWaitCount: 0,
|
||||
hasPendingWork: false,
|
||||
idle: true,
|
||||
lastDisconnectCode: 4100,
|
||||
lastDisconnectReason: 'manual platform stop',
|
||||
});
|
||||
});
|
||||
|
||||
it('macOS companion wrapper registers and writes status with platform pinning', async () => {
|
||||
|
||||
@@ -225,14 +225,14 @@ describe('platform companion clients', () => {
|
||||
await client.setLocation({ latitude: 10, longitude: 20, source: 'manual' });
|
||||
await client.registerPushToken({ token: 'a'.repeat(64), topic: 'dev.flynn.macos', environment: 'production' });
|
||||
await client.listNodes();
|
||||
client.disconnect();
|
||||
client.disconnect(4100, 'manual stop');
|
||||
|
||||
expect(mock.connect).toHaveBeenCalledOnce();
|
||||
expect(mock.registerNode).toHaveBeenCalledWith(expect.objectContaining({ nodeId: 'mac-node', role: 'companion' }));
|
||||
expect(mock.setNodeStatus).toHaveBeenCalledWith(expect.objectContaining({ platform: 'macos' }));
|
||||
expect(mock.setNodePushToken).toHaveBeenCalledWith(expect.objectContaining({ provider: 'apns', topic: 'dev.flynn.macos' }));
|
||||
expect(mock.listSystemNodes).toHaveBeenCalledWith({ platform: 'macos', role: 'companion' });
|
||||
expect(mock.disconnect).toHaveBeenCalledOnce();
|
||||
expect(mock.disconnect).toHaveBeenCalledWith(4100, 'manual stop');
|
||||
});
|
||||
|
||||
it('iOS client uses ios platform status and APNs push', async () => {
|
||||
|
||||
@@ -110,8 +110,8 @@ export class MacOSCompanionClient {
|
||||
return this.runtime.connected;
|
||||
}
|
||||
|
||||
disconnect(): void {
|
||||
this.runtime.disconnect();
|
||||
disconnect(code?: number, reason?: string): void {
|
||||
this.runtime.disconnect(code, reason);
|
||||
}
|
||||
|
||||
dispose(code?: number, reason?: string): void {
|
||||
@@ -388,8 +388,8 @@ export class IOSCompanionClient {
|
||||
return this.runtime.connected;
|
||||
}
|
||||
|
||||
disconnect(): void {
|
||||
this.runtime.disconnect();
|
||||
disconnect(code?: number, reason?: string): void {
|
||||
this.runtime.disconnect(code, reason);
|
||||
}
|
||||
|
||||
dispose(code?: number, reason?: string): void {
|
||||
@@ -666,8 +666,8 @@ export class AndroidCompanionClient {
|
||||
return this.runtime.connected;
|
||||
}
|
||||
|
||||
disconnect(): void {
|
||||
this.runtime.disconnect();
|
||||
disconnect(code?: number, reason?: string): void {
|
||||
this.runtime.disconnect(code, reason);
|
||||
}
|
||||
|
||||
dispose(code?: number, reason?: string): void {
|
||||
|
||||
Reference in New Issue
Block a user