Skip to content

Commit ee1cbff

Browse files
Move injectAttachedMessage helper to top-level scope
Extract this helper from inside the 'Sync events' describe block so it can be reused by other test sections. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 61c80e6 commit ee1cbff

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/realtime/liveobjects.test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ define(['ably', 'shared_helper', 'chai', 'liveobjects', 'liveobjects_helper'], f
163163
});
164164
}
165165

166+
/**
167+
* Helper function to inject an ATTACHED protocol message with or without HAS_OBJECTS flag
168+
*/
169+
async function injectAttachedMessage(helper, channel, hasObjects) {
170+
helper.recordPrivateApi('call.connectionManager.activeProtocol.getTransport');
171+
helper.recordPrivateApi('call.transport.onProtocolMessage');
172+
helper.recordPrivateApi('call.makeProtocolMessageFromDeserialized');
173+
const transport = channel.client.connection.connectionManager.activeProtocol.getTransport();
174+
const pm = createPM({
175+
action: 11, // ATTACHED
176+
channel: channel.name,
177+
flags: hasObjects ? 1 << 7 : 0, // HAS_OBJECTS flag is bit 7
178+
});
179+
await transport.onProtocolMessage(pm);
180+
}
181+
166182
/**
167183
* The channel with fixture data may not yet be populated by REST API requests made by LiveObjectsHelper.
168184
* This function waits for a channel to have all keys set.
@@ -8311,22 +8327,6 @@ define(['ably', 'shared_helper', 'chai', 'liveobjects', 'liveobjects_helper'], f
83118327

83128328
/** @nospec */
83138329
describe('Sync events', () => {
8314-
/**
8315-
* Helper function to inject an ATTACHED protocol message with or without HAS_OBJECTS flag
8316-
*/
8317-
async function injectAttachedMessage(helper, channel, hasObjects) {
8318-
helper.recordPrivateApi('call.connectionManager.activeProtocol.getTransport');
8319-
helper.recordPrivateApi('call.transport.onProtocolMessage');
8320-
helper.recordPrivateApi('call.makeProtocolMessageFromDeserialized');
8321-
const transport = channel.client.connection.connectionManager.activeProtocol.getTransport();
8322-
const pm = createPM({
8323-
action: 11, // ATTACHED
8324-
channel: channel.name,
8325-
flags: hasObjects ? 1 << 7 : 0, // HAS_OBJECTS flag is bit 7
8326-
});
8327-
await transport.onProtocolMessage(pm);
8328-
}
8329-
83308330
const syncEventsScenarios = [
83318331
// 1. ATTACHED with HAS_OBJECTS false
83328332

0 commit comments

Comments
 (0)