Add Android node foundation with FCM push support

This commit is contained in:
William Valentin
2026-02-16 12:55:22 -08:00
parent 58c4b0b9bb
commit a954d7e136
11 changed files with 190 additions and 19 deletions
+52
View File
@@ -868,4 +868,56 @@ describe('GatewayServer node registration and capability negotiation', () => {
}
}
});
it('supports android fcm push token registration', async () => {
if (!LISTEN_ALLOWED) {
return;
}
const ws = await new Promise<WebSocket>((resolve, reject) => {
const c = new WebSocket(`ws://127.0.0.1:${NODE_PORT}`);
c.on('open', () => resolve(c));
c.on('error', reject);
});
try {
const registered = await sendAndReceive(ws, {
id: 40,
method: 'node.register',
params: {
nodeId: 'node-android',
role: 'companion',
protocolVersion: 1,
capabilities: ['notifications'],
},
});
expect(((registered as GatewayResponse).result as { registered: boolean }).registered).toBe(true);
const push = await sendAndReceive(ws, {
id: 41,
method: 'node.push_token.set',
params: {
provider: 'fcm',
token: 'fcm_abcdefghijklmnopqrstuvwxyz123456',
},
});
expect(((push as GatewayResponse).result as { updated: boolean }).updated).toBe(true);
const nodes = await sendAndReceive(ws, {
id: 42,
method: 'system.nodes',
params: { role: 'companion', limit: 20 },
});
const list = ((nodes as GatewayResponse).result as {
nodes: Array<{ nodeId: string; push?: { provider: string; environment?: string } }>;
}).nodes;
const androidNode = list.find((entry) => entry.nodeId === 'node-android');
expect(androidNode?.push?.provider).toBe('fcm');
expect(androidNode?.push?.environment).toBeUndefined();
} finally {
if (ws.readyState === WebSocket.OPEN) {
ws.close();
}
}
});
});