Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023 11 01 merge main into v2 get conflict #1483

Closed
Closed
Changes from 1 commit
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
d936c51
Update webpack-cli to 4.10.0
lawrence-forooghian Apr 17, 2023
c62cc6a
Update tsconfig-paths-webpack-plugin to 4.0.1
lawrence-forooghian Apr 17, 2023
4b496c5
Update ts-loader to 8.4.0
lawrence-forooghian Apr 17, 2023
6db88b0
Remove null-loader dependency
lawrence-forooghian Apr 17, 2023
62bd4d3
Update grunt-webpack to 5.0.0
lawrence-forooghian Apr 17, 2023
c828952
Upgrade to webpack version 5
lawrence-forooghian Apr 17, 2023
56f80e9
Merge pull request #1201 from ably/upgrade-webpack-to-version-5
lawrence-forooghian Apr 24, 2023
1619056
Remove withoutjsonp.js
lawrence-forooghian Apr 24, 2023
3551441
Remove support for JSONP
lawrence-forooghian Apr 24, 2023
eaee6f6
Conform to spec for logging configuration
lawrence-forooghian Apr 26, 2023
e25ba64
Merge pull request #1215 from ably/1198-remove-jsonp
lawrence-forooghian Apr 27, 2023
14f20c9
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian Apr 27, 2023
a705a15
Merge pull request #1216 from ably/642-conform-to-logging-spec
lawrence-forooghian Apr 27, 2023
84c988f
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian Apr 27, 2023
440d890
Remove deprecated fromEncoded* type declarations
lawrence-forooghian Apr 27, 2023
c8a691b
Merge pull request #1222 from ably/remove-deprecated-type-declarations
lawrence-forooghian Apr 27, 2023
57b49cd
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian Apr 27, 2023
359f9a7
Remove ably-commonjs*.js files
lawrence-forooghian Apr 27, 2023
5330f75
Remove DeprecatedClientOptions.host
lawrence-forooghian Apr 26, 2023
616d2f2
Remove DeprecatedClientOptions.wsHost
lawrence-forooghian Apr 26, 2023
757ecb5
Remove DeprecatedClientOptions.queueEvents
lawrence-forooghian Apr 26, 2023
d7aaf34
Remove DeprecatedClientOptions.headers
lawrence-forooghian Apr 26, 2023
fe3c9ce
Move remaining DeprecatedClientOptions into new type
lawrence-forooghian Apr 26, 2023
adfe599
Remove deprecated ClientOptions.fallbackHostsUseDefault
lawrence-forooghian Apr 27, 2023
399c896
Remove deprecated ability to pass ClientOptions.recover as a boolean
lawrence-forooghian Apr 27, 2023
b8ad229
Remove deprecated ability to pass "xhr" in ClientOptions.transports
lawrence-forooghian Apr 27, 2023
742a981
Remove deprecated RealtimePresence.on/off methods
lawrence-forooghian Apr 27, 2023
2402dc2
Remove deprecated ability to pass AuthOptions.force property
lawrence-forooghian Apr 27, 2023
2b56a43
Remove deprecated ability to pass flags to RealtimeChannel.attach
lawrence-forooghian Apr 27, 2023
5d3a18a
Remove deprecated Auth.authorise method
lawrence-forooghian Apr 27, 2023
0f2074e
Remove deprecated forms of calling Crypto.getDefaultParams
lawrence-forooghian Apr 27, 2023
2335432
Remove Logger.deprecated* methods
lawrence-forooghian Apr 27, 2023
1934fc2
Merge pull request #1229 from ably/1200-remove-ably-commonjs-file
lawrence-forooghian May 2, 2023
077d9dd
Merge pull request #1221 from ably/remove-DeprecatedClientOptions
lawrence-forooghian May 2, 2023
21135f7
Merge pull request #1227 from ably/remove-soft-deprecated-apis
lawrence-forooghian May 2, 2023
6ad2a81
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian May 2, 2023
55c767c
Turn default*Headers’ optional param into an object
lawrence-forooghian Apr 27, 2023
ba77bfb
Add mandatory version param to Rest.request
lawrence-forooghian Apr 27, 2023
5c2597e
Merge pull request #1231 from ably/1225-add-version-param-to-Rest.req…
lawrence-forooghian May 3, 2023
da530f8
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian May 4, 2023
a4d8c5f
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian May 10, 2023
89602c7
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian May 10, 2023
806c2fb
Update docstrings for Rest.request version param
lawrence-forooghian May 11, 2023
5f69795
Upgrade TypeScript to 4.9.5
lawrence-forooghian May 8, 2023
487914e
Merge pull request #1258 from ably/upgrade-typescript-to-4.9.5
lawrence-forooghian May 15, 2023
90c3468
Merge pull request #1255 from ably/update-rest-version-param-docstring
lawrence-forooghian May 15, 2023
3d06fde
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian May 15, 2023
0e7ca13
Update Prettier to 2.8.8
lawrence-forooghian May 16, 2023
e013cc0
Update typescript-eslint to 5.59.6
lawrence-forooghian May 16, 2023
9599210
Merge pull request #1267 from ably/fix-typescript-4.9.5-upgrade-mistakes
lawrence-forooghian May 18, 2023
de788a5
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian May 18, 2023
2d50aeb
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian May 22, 2023
ffadbe8
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian May 25, 2023
ad95fc5
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian May 25, 2023
006cf55
Create ICryptoStatic and ICipher interfaces
lawrence-forooghian May 8, 2023
06479c3
Add helpers for deriving ICryptoStatic generic type arguments
lawrence-forooghian May 9, 2023
d2b61f5
Expose toWordArray property in IBufferUtils interface
lawrence-forooghian May 9, 2023
6141511
Expose isWordArray method in IBufferUtils interface
lawrence-forooghian May 11, 2023
ff05ced
Make getRandomValues’s callback error parameter non-optional
lawrence-forooghian May 9, 2023
f311c20
Remove possible boolean result of getRandomWordArray
lawrence-forooghian May 9, 2023
7b29f33
Make Node Crypto’s isInstCipherParams return a boolean
lawrence-forooghian May 4, 2023
dee0539
Pass consistent number of arguments to web’s CBCCipher.prototype.encr…
lawrence-forooghian May 9, 2023
a940e49
Pass consistent number of arguments to web’s CBCCipher.prototype.getI…
lawrence-forooghian May 9, 2023
31b4b6f
Always initialize web’s CBCCipher.iv property
lawrence-forooghian May 25, 2023
146b383
Make CipherParams constructor accept its properties
lawrence-forooghian May 9, 2023
49aa6e6
Inject BufferUtils into Node Crypto class
lawrence-forooghian May 17, 2023
53c3a55
Add types for CryptoJS functionality used by web’s crypto.js
lawrence-forooghian May 9, 2023
4a0d6df
Make Crypto class contiguous in crypto.js files
lawrence-forooghian May 16, 2023
3f5ec6f
Convert platform crypto.js files to TypeScript
lawrence-forooghian May 4, 2023
b7977e4
Convert platform crypto.ts files to use classes
lawrence-forooghian May 4, 2023
333872a
Merge pull request #1246 from ably/convert-crypto-to-TypeScript
lawrence-forooghian Jun 5, 2023
ab22a56
Rename Channels#onChannelMessage
lawrence-forooghian May 25, 2023
a407328
Rename RealtimeChannel#onMessage
lawrence-forooghian May 25, 2023
51cf0b0
Make ConnectionManager#onChannelMessages process messages asynchronously
lawrence-forooghian May 25, 2023
ec8d77e
Make Channels#processChannelMessage async
lawrence-forooghian May 29, 2023
ec8a1b1
Make some tests return a Promise
lawrence-forooghian May 29, 2023
346e5eb
Make RealtimeChannel#processMessage async
lawrence-forooghian May 29, 2023
c19b688
Make Message#fromEncoded/fromEncodedArray async
lawrence-forooghian May 29, 2023
0ba2164
Make PresenceMessage#fromEncoded/fromEncodedArray async
lawrence-forooghian May 29, 2023
5ac1f23
Make PaginatedResource’s bodyHandler async
lawrence-forooghian May 29, 2023
835f6df
Make Message.fromResponseBody async
lawrence-forooghian May 29, 2023
1b9bdb7
Make PresenceMessage.fromResponseBody async
lawrence-forooghian May 29, 2023
21bc801
Make Message.decode async
lawrence-forooghian May 29, 2023
c955702
Make ICipher.decrypt async
lawrence-forooghian May 23, 2023
f7dd898
Merge pull request #1311 from ably/1293-make-ICipher.decrypt-async
lawrence-forooghian Jun 5, 2023
cbb98f1
Remove IBufferUtils’s ComparableBuffer generic parameter
lawrence-forooghian May 31, 2023
683e88f
Always use `instanceof` for checking if something is an ArrayBuffer
lawrence-forooghian May 31, 2023
bbdf8b0
Replace use of TypedArray with ArrayBufferView
lawrence-forooghian May 31, 2023
44e4e04
Replace isArrayBufferView with direct call to ArrayBuffer.isView
lawrence-forooghian May 31, 2023
5450e80
Remove WordArray from web Bufferlike type
lawrence-forooghian May 22, 2023
79668b1
Rename IBufferUtils.bufferCompare to areBuffersEqual
lawrence-forooghian May 30, 2023
bbd9c9d
Don’t use CryptoJS in web implementation of BufferUtils.areBuffersEqual
lawrence-forooghian May 22, 2023
73ccbe6
Remove erroneous mention of WordArray in Node crypto.ts
lawrence-forooghian May 31, 2023
b8881cf
Rename misnamed test
lawrence-forooghian May 30, 2023
50af8e7
Fix comment in test
lawrence-forooghian May 31, 2023
fd833ab
Convert React Native platform config to a factory function
lawrence-forooghian May 23, 2023
7832b44
Change getRandomWordArray to getRandomArrayBuffer
lawrence-forooghian May 22, 2023
e14f1bf
Make CipherParams.key an ArrayBuffer on web instead of a WordArray
lawrence-forooghian May 22, 2023
af675d4
Change plain/ciphertext output of web Crypto to ArrayBuffer
lawrence-forooghian May 23, 2023
dd848f3
Remove blockLengthWords property of web CBCCipher
lawrence-forooghian May 24, 2023
fcdb9f3
Use Web Crypto for encrypting and decrypting on web
lawrence-forooghian May 23, 2023
2e0e90c
Merge pull request #1299 from ably/1292-use-web-crypto-for-encrypting…
lawrence-forooghian Jun 6, 2023
b4865bc
Describe the types of key returned by generateRandomKey
lawrence-forooghian Jun 1, 2023
99e4926
Remove platform-specific code from auth.ts’s toBase64
lawrence-forooghian Jun 1, 2023
b110420
Remove platform-specific code from auth.ts’s hmac
lawrence-forooghian Jun 1, 2023
fc94b80
Add an implementation of HMAC-SHA-256
lawrence-forooghian Jun 7, 2023
32833d4
Convert HMAC implementation to TypeScript
lawrence-forooghian Jun 7, 2023
90dde04
Stop using CryptoJS for token request signing
lawrence-forooghian Jun 7, 2023
1794a74
Remove unused code from HMAC implementation
lawrence-forooghian Jun 7, 2023
9e50d2e
Remove an error that will never be thrown
lawrence-forooghian Jun 7, 2023
07d8c90
Merge pull request #1320 from ably/1296-document-generateRandomKey-re…
lawrence-forooghian Jun 12, 2023
d2e87fb
Merge pull request #1325 from ably/1295-stop-using-CryptoJS-for-signi…
lawrence-forooghian Jun 12, 2023
2f1dc81
Merge branch 'origin/main' into integration/v2
lawrence-forooghian Jun 13, 2023
b8e1ea3
Merge remote-tracking branch 'origin/main' into integration/v2
lawrence-forooghian Jun 13, 2023
e036148
Make ErrorInfo.fromValues’s signature correspond to its expectations
lawrence-forooghian Jun 6, 2023
68d4aaf
Remove WordArray functionality from BufferUtils
lawrence-forooghian May 24, 2023
8fe958d
Remove unused randomHexString function
lawrence-forooghian Jun 6, 2023
a2e3e00
Remove a comment relating to CryptoJS
lawrence-forooghian Jun 5, 2023
e15dccd
Stop using CryptoJS in testapp_manager.js
lawrence-forooghian Jun 6, 2023
f1bf748
Remove all usage of the CryptoJS library
lawrence-forooghian Jun 1, 2023
d3ceb08
Merge pull request #1322 from ably/fix-signature-of-ErrorInfo-fromValues
lawrence-forooghian Jun 13, 2023
4931665
Merge pull request #1333 from ably/1239-remove-CryptoJS-library
lawrence-forooghian Jun 19, 2023
94bb5a1
Fix the type definition of Crypto.getDefaultParams
lawrence-forooghian Jun 22, 2023
267c1e1
Merge pull request #1352 from ably/1350-make-getDefaultParams-typing-…
lawrence-forooghian Jun 26, 2023
3340ca4
test: add test constructors for promise-based clients
owenpearson Apr 26, 2023
1ca52a3
test: add restTestOnJsonMsgpackAsync
owenpearson May 4, 2023
76a1e63
test: convert rest auth tests to Promise API
owenpearson Apr 26, 2023
af38ec8
test: convert rest capability tests to Promise API
owenpearson Apr 26, 2023
a1fb8dd
test: convert rest fallbacks tests to Promise API
owenpearson Apr 26, 2023
6d0d329
test: convert rest history tests to Promise API
owenpearson Apr 26, 2023
b07d032
test: remove legacy rest history promise test
owenpearson Apr 26, 2023
24d299e
test: convert rest http tests to Promise API
owenpearson Apr 26, 2023
d40ea8f
test: convert rest constructor tests to Promise API
owenpearson Apr 26, 2023
152f4e5
test: convert rest message tests to Promise API
owenpearson Apr 26, 2023
8b9e0f9
test: remove legacy rest message promise test
owenpearson Apr 26, 2023
d76a03f
test: convert rest presence tests to Promise API
owenpearson Apr 27, 2023
4ef4a98
test: remove legacy rest presence promise test
owenpearson Apr 27, 2023
844af87
test: convert rest push tests to Promise API
owenpearson Apr 27, 2023
469229b
test: remove legacy rest push promise tests
owenpearson Apr 27, 2023
1e698e2
test: convert rest request tests to Promise API
owenpearson Apr 27, 2023
b694963
test: remove legacy rest request promise test
owenpearson Apr 27, 2023
f882997
test: convert rest stats tests to Promise API
owenpearson Apr 27, 2023
2448be7
test: remove legacy rest stats promise test
owenpearson Apr 27, 2023
44808ed
test: convert rest status test to Promise API
owenpearson Apr 27, 2023
e9081a3
test: remove legacy rest status promise test
owenpearson Apr 27, 2023
edcecfa
test: convert rest time test to Promise API
owenpearson Apr 27, 2023
6796bed
test: remove legacy rest time promise test
owenpearson Apr 27, 2023
17d2aaa
Remove test of Ably.Rest.Callbacks
lawrence-forooghian Jun 20, 2023
a36fe51
Remove "Async" from name of restTestOnJsonMsgpackAsync
lawrence-forooghian Jun 20, 2023
a1c3592
Remove parts of test relating to setOptions calling its callback imme…
lawrence-forooghian Jun 20, 2023
050b95b
Prepare realtime channel publish disallowed test for conversion to Pr…
lawrence-forooghian Jun 20, 2023
43a2d1d
Update Realtime tests to use SDK’s Promise-based API
lawrence-forooghian Jun 14, 2023
45b9c3b
Remove obsolete Promise-based Realtime tests
lawrence-forooghian Jun 22, 2023
d0f034e
Remove "Promise" from name of Ably*Promise helpers
lawrence-forooghian Jun 19, 2023
a0105eb
Change Crypto.generateRandomKey API to use Promises
lawrence-forooghian Jun 22, 2023
b61e18b
Merge pull request #1349 from ably/1213-update-tests-to-use-promise-api
lawrence-forooghian Jul 3, 2023
1172194
Merge pull request #1351 from ably/1345-change-generateRandomKey-to-p…
lawrence-forooghian Jul 3, 2023
3dddbda
Remove Platform.Config.Promise
lawrence-forooghian Jun 22, 2023
9f1c38b
Remove all checks for Promise availability
lawrence-forooghian Jun 22, 2023
471f112
Expand documentation for channelEventCallback and connectionEventCall…
lawrence-forooghian Jun 27, 2023
2a2ed49
Remove the callbacks public API
lawrence-forooghian Jun 22, 2023
693804c
Remove the Promise static property
lawrence-forooghian Jun 27, 2023
6cf248f
Remove promises.js / .d.ts
lawrence-forooghian Jun 27, 2023
8c3afa4
Move RealtimeChannelPromise declaration directly below RealtimeChanne…
lawrence-forooghian Jun 26, 2023
69c35f1
Remove Realtime < Rest inheritance in public API
lawrence-forooghian Jun 27, 2023
6cb7179
Merge *Base and *Promise classes
lawrence-forooghian Jun 22, 2023
404c412
Merge pull request #1358 from ably/1199-remove-callbacks-api
lawrence-forooghian Jul 3, 2023
dbc3dbe
chore: change xhr transport file extensions to .ts
owenpearson Jul 7, 2023
2fd7cdb
refactor: convert xhrpollingtransport.ts to typescript
owenpearson Jul 7, 2023
52f1f4e
refactor: convert xhrstreamingtransport to typescript
owenpearson Jul 7, 2023
3bb7623
deps: add esbuild dependency
owenpearson Jun 30, 2023
27d0653
deps: add esbuild-plugin-umd-wrapper dependency
owenpearson Jul 7, 2023
9212a91
refactor: use named exports for web entrypoint
owenpearson Jul 7, 2023
102c733
refactor: use instanceof for isErrorInfoOrPartialErrorInfo
owenpearson Jul 7, 2023
d9b0d36
refactor: avoid unguarded `global` access
owenpearson Jul 7, 2023
ed9be58
ci: remove closure compiler check
owenpearson Jul 10, 2023
4d22ee2
build: use esbuild for browser bundles
owenpearson Jun 30, 2023
8e9d1c8
Merge pull request #1379 from ably/xhr-transports-typescript
owenpearson Jul 12, 2023
c508a39
Merge pull request #1369 from ably/esbuild
owenpearson Jul 19, 2023
c227af8
Merge remote-tracking branch 'origin/main' into 1411-merge-main-into-v2
lawrence-forooghian Aug 2, 2023
1b49159
Merge pull request #1416 from ably/1411-merge-main-into-v2
lawrence-forooghian Nov 1, 2023
4783e31
Merge remote-tracking branch 'origin/main' into 2023-11-01-merge-main…
lawrence-forooghian Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make some tests return a Promise
These are the tests that call RealtimeChannel#processMessage at their
top level. This is preparation for making that method asynchronous as
part of #1293 (making ICipher.decrypt asynchronous).
lawrence-forooghian committed Jun 5, 2023
commit ec8a1b12923b10a05bcd271beb259ca920c7f645
320 changes: 176 additions & 144 deletions test/realtime/sync.test.js
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
* sync in progress, then do one sync, then a second with a slightly
* different presence set
*/
it('sync_existing_set', function (done) {
it('sync_existing_set', async function () {
var realtime = helper.AblyRealtime({ autoConnect: false }),
channelName = 'syncexistingset',
channel = realtime.channels.get(channelName);
@@ -55,96 +55,102 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
})
);

async.series(
[
function (cb) {
channel.processMessage({
action: 16,
channel: channelName,
presence: [
{
action: 'present',
clientId: 'one',
connectionId: 'one_connid',
id: 'one_connid:0:0',
timestamp: 1e12,
},
{
action: 'present',
clientId: 'two',
connectionId: 'two_connid',
id: 'two_connid:0:0',
timestamp: 1e12,
},
],
});
cb();
},
function (cb) {
channel.presence.get(function (err, results) {
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(['one', 'two'], 'check correct members');
} catch (err) {
await new Promise(function (resolve, reject) {
var done = function (err) {
err ? reject(err) : resolve();
};

async.series(
[
function (cb) {
channel.processMessage({
action: 16,
channel: channelName,
presence: [
{
action: 'present',
clientId: 'one',
connectionId: 'one_connid',
id: 'one_connid:0:0',
timestamp: 1e12,
},
{
action: 'present',
clientId: 'two',
connectionId: 'two_connid',
id: 'two_connid:0:0',
timestamp: 1e12,
},
],
});
cb();
},
function (cb) {
channel.presence.get(function (err, results) {
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(['one', 'two'], 'check correct members');
} catch (err) {
cb(err);
return;
}
cb(err);
return;
}
cb(err);
});
},
function (cb) {
/* Trigger another sync. Two has gone without so much as a `leave` message! */
channel.processMessage({
action: 16,
channel: channelName,
presence: [
{
action: 'present',
clientId: 'one',
connectionId: 'one_connid',
id: 'one_connid:0:0',
timestamp: 1e12,
},
{
action: 'present',
clientId: 'three',
connectionId: 'three_connid',
id: 'three_connid:0:0',
timestamp: 1e12,
},
],
});
cb();
},
function (cb) {
channel.presence.get(function (err, results) {
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(
['one', 'three'],
'check two has gone and three is there'
);
} catch (err) {
});
},
function (cb) {
/* Trigger another sync. Two has gone without so much as a `leave` message! */
channel.processMessage({
action: 16,
channel: channelName,
presence: [
{
action: 'present',
clientId: 'one',
connectionId: 'one_connid',
id: 'one_connid:0:0',
timestamp: 1e12,
},
{
action: 'present',
clientId: 'three',
connectionId: 'three_connid',
id: 'three_connid:0:0',
timestamp: 1e12,
},
],
});
cb();
},
function (cb) {
channel.presence.get(function (err, results) {
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(
['one', 'three'],
'check two has gone and three is there'
);
} catch (err) {
cb(err);
return;
}
cb(err);
return;
}
cb(err);
});
},
],
function (err) {
closeAndFinish(done, realtime, err);
}
);
});
},
],
function (err) {
closeAndFinish(done, realtime, err);
}
);
});
});

/*
* Sync with an existing presence set and a presence member added in the
* middle of the sync should should discard the former, but not the latter
* */
it('sync_member_arrives_in_middle', function (done) {
it('sync_member_arrives_in_middle', async function () {
var realtime = helper.AblyRealtime({ autoConnect: false }),
channelName = 'sync_member_arrives_in_middle',
channel = realtime.channels.get(channelName);
@@ -217,27 +223,36 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
],
});

channel.presence.get(function (err, results) {
if (err) {
closeAndFinish(done, realtime, err);
return;
}
try {
expect(results.length).to.equal(3, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(['four', 'three', 'two'], 'check expected presence members');
} catch (err) {
closeAndFinish(done, realtime, err);
return;
}
closeAndFinish(done, realtime);
await new Promise(function (resolve, reject) {
var done = function (err) {
err ? reject(err) : resolve();
};

channel.presence.get(function (err, results) {
if (err) {
closeAndFinish(done, realtime, err);
return;
}
try {
expect(results.length).to.equal(3, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(
['four', 'three', 'two'],
'check expected presence members'
);
} catch (err) {
closeAndFinish(done, realtime, err);
return;
}
closeAndFinish(done, realtime);
});
});
});

/*
* Presence message that was in the sync arrives again as a normal message, after it's come in the sync
*/
it('sync_member_arrives_normally_after_came_in_sync', function (done) {
it('sync_member_arrives_normally_after_came_in_sync', async function () {
var realtime = helper.AblyRealtime({ autoConnect: false }),
channelName = 'sync_member_arrives_normally_after_came_in_sync',
channel = realtime.channels.get(channelName);
@@ -294,27 +309,33 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
],
});

channel.presence.get(function (err, results) {
if (err) {
closeAndFinish(done, realtime, err);
return;
}
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(['one', 'two'], 'check expected presence members');
} catch (err) {
closeAndFinish(done, realtime, err);
return;
}
closeAndFinish(done, realtime);
await new Promise(function (resolve, reject) {
var done = function (err) {
err ? reject(err) : resolve();
};

channel.presence.get(function (err, results) {
if (err) {
closeAndFinish(done, realtime, err);
return;
}
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(['one', 'two'], 'check expected presence members');
} catch (err) {
closeAndFinish(done, realtime, err);
return;
}
closeAndFinish(done, realtime);
});
});
});

/*
* Presence message that will be in the sync arrives as a normal message, before it comes in the sync
*/
it('sync_member_arrives_normally_before_comes_in_sync', function (done) {
it('sync_member_arrives_normally_before_comes_in_sync', async function () {
var realtime = helper.AblyRealtime({ autoConnect: false }),
channelName = 'sync_member_arrives_normally_before_comes_in_sync',
channel = realtime.channels.get(channelName);
@@ -371,28 +392,34 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
],
});

channel.presence.get(function (err, results) {
if (err) {
closeAndFinish(done, realtime, err);
return;
}
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(['one', 'two'], 'check expected presence members');
} catch (err) {
closeAndFinish(done, realtime, err);
return;
}
closeAndFinish(done, realtime);
await new Promise(function (resolve, reject) {
var done = function (err) {
err ? reject(err) : resolve();
};

channel.presence.get(function (err, results) {
if (err) {
closeAndFinish(done, realtime, err);
return;
}
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(['one', 'two'], 'check expected presence members');
} catch (err) {
closeAndFinish(done, realtime, err);
return;
}
closeAndFinish(done, realtime);
});
});
});

/*
* Get several presence messages with various combinations of msgserial,
* index, and synthesized leaves, check that the end result is correct
*/
it('presence_ordering', function (done) {
it('presence_ordering', async function () {
var realtime = helper.AblyRealtime({ autoConnect: false }),
channelName = 'sync_ordering',
channel = realtime.channels.get(channelName);
@@ -518,22 +545,27 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
],
});

channel.presence.get(function (err, results) {
if (err) {
closeAndFinish(done, realtime, err);
return;
}
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(['one', 'two'], 'check expected presence members');
expect(extractMember(results, 'one').data).to.equal('onedata', 'check correct data on one');
expect(extractMember(results, 'two').data).to.equal('twodata', 'check correct data on two');
} catch (err) {
closeAndFinish(done, realtime, err);
return;
}
closeAndFinish(done, realtime);
await new Promise(function (resolve, reject) {
var done = function (err) {
err ? reject(err) : resolve();
};
channel.presence.get(function (err, results) {
if (err) {
closeAndFinish(done, realtime, err);
return;
}
try {
expect(results.length).to.equal(2, 'Check correct number of results');
expect(channel.presence.syncComplete, 'Check in sync').to.be.ok;
expect(extractClientIds(results)).to.deep.equal(['one', 'two'], 'check expected presence members');
expect(extractMember(results, 'one').data).to.equal('onedata', 'check correct data on one');
expect(extractMember(results, 'two').data).to.equal('twodata', 'check correct data on two');
} catch (err) {
closeAndFinish(done, realtime, err);
return;
}
closeAndFinish(done, realtime);
});
});
});