diff --git a/test/browser/connection.test.js b/test/browser/connection.test.js index 54a08a519..382086e1e 100644 --- a/test/browser/connection.test.js +++ b/test/browser/connection.test.js @@ -213,10 +213,24 @@ define(['shared_helper', 'chai'], function (Helper, chai) { }); }); + // strip instanceID and handleID from connectionKey */ + function connectionHmac(key) { + /* connectionKey has the form !- */ + + /* remove the handleID from the end of key */ + let k = key.split('-')[0]; + + /* skip the server instanceID if present, as reconnects may be routed to different frontends */ + if (k.includes('!')) { + k = k.split('!')[1]; + } + return k; + } + /* uses internal realtime knowledge of the format of the connection key to * check if a connection key is the result of a successful recovery of another */ function sameConnection(keyA, keyB) { - return keyA.split('-')[0] === keyB.split('-')[0]; + return connectionHmac(keyA) === connectionHmac(keyB); } /**