1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00
Commit Graph

2131 Commits

Author SHA1 Message Date
Richard van der Hoff
8b2fdf3a75 Deflake megolm unit test
Waiting for 1ms isn't actually good enough. wait for the actual thing we are
actually waiting for.
2017-07-14 15:22:08 +01:00
Richard van der Hoff
adca75b7d8 Deflake matrix-client-timeline tests
These guys do a flush("/sync"), without waiting for it to complete, and then in
the afterEach, check that the sync has been flushed, which it may not have
been. So we should make sure we wait for the flush.
2017-07-14 15:22:08 +01:00
Richard van der Hoff
504fa2a1d3 Fix racy 'matrixclient retrying' test
when a message send fails, the promise returned by `sendMessage` is
rejected. Until we switched to bluebird, the rejection was happily being
swallowed, but with bluebird, there's a better chance of the unhandled
rejection being caught by the runtime and mocha and failing the test.
2017-07-13 18:18:21 +01:00
Richard van der Hoff
266a062a5d Fix spamming of key-share-requests
Fixes a race in the memory-backed crypto store which meant that we would spam
out multiple key-share-requests for the same session.

(This didn't happen very often in practice, because normally we use the
indexeddb-backed store, which is race-free. Or at least, doesn't have this
race.)
2017-07-13 13:29:56 +01:00
Richard van der Hoff
652a9452c2 Merge pull request #490 from matrix-org/rav/bluebird
Switch matrix-js-sdk to bluebird
2017-07-12 23:34:40 +01:00
Richard van der Hoff
503b6ea6c8 Correct incorrect Promise() invocation
you're supposed to call Promise() as a constructor rather than a static
function.
2017-07-12 23:33:55 +01:00
Richard van der Hoff
547501ba81 Replace promise.inspect()
Bluebird promises don't have an `inspect()` method, but do have an
`isFulfilled()` and a `value()` method, so use them instead.
2017-07-12 23:33:55 +01:00
Richard van der Hoff
cfffbc4a09 replace q method calls with bluebird ones
```
find src spec -name '*.js' |
    xargs perl -i -pe 's/q\.(all|defer|reject|delay|try)\(/Promise.$1(/'
```
2017-07-12 23:33:55 +01:00
Richard van der Hoff
b58d84fba1 q.Promise -> Promise
```
find src spec -name '*.js' |
    xargs perl -i -pe 's/q\.Promise/Promise/'
```
2017-07-12 23:32:28 +01:00
Richard van der Hoff
a5d3dd942e q(...) -> Promise.resolve
```
find src spec -name '*.js' |
    xargs perl -i -pe 's/\bq(\([^(]*\))/Promise.resolve$1/'
```
2017-07-12 23:32:28 +01:00
Richard van der Hoff
b96062b6de replace imports of q with bluebird
```
find src spec -name '*.js' |
   xargs perl -i -pe 'if (/require\(.q.\)/) { $_ = "import Promise from '\''bluebird'\'';\n"; }'

find src spec -name '*.js' |
   xargs perl -i -pe 'if (/import q/) { $_ = "import Promise from '\''bluebird'\'';\n"; }'
```
2017-07-12 23:32:28 +01:00
Richard van der Hoff
04b71c11e1 Merge pull request #492 from matrix-org/rav/even_more_flakey_tests
Fix some more flakey tests
2017-07-12 18:17:16 +01:00
Richard van der Hoff
651baefb1d Remove redundant expectations
Apparently we weren't hitting these expected requests, so let's get rid of them.
2017-07-12 17:25:59 +01:00
Richard van der Hoff
ff7e845615 remove redundant flushAllExpected
Turned out this flush was completely redundant
2017-07-12 17:23:11 +01:00
Richard van der Hoff
f0612a1407 Fix some more flakey tests
switch a bunch of `flush()`es to `flushAllExpected()`s
2017-07-12 16:28:21 +01:00
Richard van der Hoff
83bd24adf8 More test deflakifying (#491)
Call `flushAllExpected()` from some more places. In a couple of places, we were
apparently calling `flush()` redundantly, so remove it altogether.
2017-07-12 14:05:39 +01:00
Richard van der Hoff
b5a8e6bbdf Merge pull request #489 from t3chguy/t3chguy/test-crossplatform
make the npm test script windows-friendly
2017-07-12 13:49:43 +01:00
Michael Telatynski
9798fcf839 make the npm test script windows-friendly 2017-07-11 23:08:28 +01:00
David Baker
15556b6797 Merge pull request #488 from matrix-org/rav/deflakify_tests
Fix a bunch of races in the tests
2017-07-11 13:22:27 +01:00
Richard van der Hoff
0ca4d728d8 Fix a bunch of races in the tests
Once we switch to bluebird, suddenly a load of timing issues come out of the
woodwork. Basically, we need to try harder when flushing requests. Bump to
matrix-mock-request 1.1.0, which provides `flushAllExpected`, and waits for
requests to arrive when given a `numToFlush`; then use `flushAllExpected` in
various places to make the tests more resilient.
2017-07-11 12:09:21 +01:00
David Baker
b2c7804032 Merge pull request #487 from matrix-org/rav/fix_bad_all_usage
Fix early return in MatrixClient.setGuestAccess
2017-07-11 11:21:45 +01:00
David Baker
e091dc0294 Merge pull request #486 from matrix-org/rav/kill_failTest
Remove testUtils.failTest
2017-07-11 11:21:14 +01:00
Richard van der Hoff
3bfb4595cf Remove redundant calls to done
These tests which return a promise already don't need to call `done`.
2017-07-10 17:40:23 +01:00
Richard van der Hoff
8955d8de23 remove utils.failTest
this is no longer used, so kill it
2017-07-10 17:25:56 +01:00
Richard van der Hoff
1372b298bb kill off more utils.failTest refs
manual replacement of some more complicated utils.failTest usages with q.all()
invocations.
2017-07-10 17:25:48 +01:00
Richard van der Hoff
9558845e6e Fix early return in MatrixClient.setGuestAccess
(as well as a similar bug in the test suite)

Turns out that `q.all(a, b)` === `q.all([a])`, rather than `q.all([a,b])`: it
only waits for the *first* promise - which means that `client.setGuestAccess`
would swallow any errors returned from the API.
2017-07-10 17:14:52 +01:00
Richard van der Hoff
5ab0930de8 utils.failTest -> nodeify
Automated replacement of utils.failTest with nodeify

This was done with the perl incantation:

```
    find spec -name '*.js' |
        xargs perl -i -pe 's/catch\((testUtils|utils).failTest\).done\(done\)/nodeify(done)/'
```

more auto
2017-07-10 16:37:31 +01:00
David Baker
3294f4858a Merge pull request #485 from matrix-org/rav/test_watch
Add test:watch script
2017-07-07 14:25:36 +01:00
Richard van der Hoff
eea9a3ba59 Add test:watch script
... to run the tests in a loop.
2017-07-07 14:19:41 +01:00
Richard van der Hoff
753974d663 Merge pull request #484 from matrix-org/rav/enable_async
Make it possible to use async/await
2017-07-07 13:47:59 +01:00
David Baker
527cd0a6e5 Implement 'joined_groups' API (#477)
* Add group summary api

* Add doc for group summary API

and remove callback param as it's deprecated

* API for /joined_groups

* Create group API

* Make doc marginally more helpful
2017-07-06 22:02:17 +01:00
Richard van der Hoff
24f70387d2 Make it possible to use async/await
Enables the babel plugin that transpiles async/await to generator functions,
and load the regenerator runtime so that generator functions work.
2017-07-06 18:52:37 +01:00
Richard van der Hoff
adc2070ac1 Merge pull request #483 from matrix-org/rav/remove_new_device_support
Remove m.new_device support
2017-07-06 17:10:37 +01:00
Richard van der Hoff
a8642682d0 Remove m.new_device support
We now rely on the server to track new devices, and tell us about them when
users add them, rather than forcing devices to announce themselves (see
https://github.com/vector-im/riot-web/issues/2305 for the whole backstory
there).

The necessary support for that has now been in all the clients and the server
for several months (since March or so). I now want to get rid of the
localstorage store, which this code is relying on, so now seems like a good
time to get rid of it. Yay.
2017-07-06 16:05:40 +01:00
Kegsay
d66e6db480 Merge pull request #478 from krombel/access_token_header
Use access-token in header
2017-07-06 13:44:31 +01:00
Krombel
dc66bbc3dc pass useAuthorizationHeader from constructor; add docs 2017-07-06 13:47:54 +02:00
Krombel
6e7f5feea5 remove fallback to query-params and set Authorization-Header based on construcor-option 2017-07-05 17:04:40 +02:00
Richard van der Hoff
f21ea6c065 Extend timeout in megolm test
Use the default timeout of 100ms when waiting for the /send request, instead of
clamping it to 20ms.
2017-07-05 15:08:50 +01:00
Richard van der Hoff
6af56b56bc Merge pull request #482 from matrix-org/rav/sanity_check_protocols
Sanity-check response from /thirdparty/protocols
2017-07-05 11:09:20 +01:00
Richard van der Hoff
598d40b0b7 Sanity-check response from /thirdparty/protocols
Check that /thirdparty/protocols gives us an object (rather than a string, for
instance). I saw a test explode, apparently because it gave us a string. Which
is odd, but in general we ought to be sanity-checking the things coming back
from the server.
2017-07-05 10:51:08 +01:00
Richard van der Hoff
6ae714f51f Merge pull request #479 from matrix-org/rav/error_parsing
Avoid parsing plain-text errors as JSON
2017-07-04 17:11:47 +01:00
Richard van der Hoff
b0661bb586 Update to matrix-mock-request 1.0
-- to pick up on the json parsing differences
2017-07-04 16:35:33 +01:00
Richard van der Hoff
b6a165f1f8 Merge branch 'develop' into rav/error_parsing 2017-07-04 16:03:33 +01:00
Richard van der Hoff
8fe4a36b68 Merge pull request #481 from matrix-org/rav/use_external_mock_request
Use external mock-request
2017-07-04 16:01:21 +01:00
Richard van der Hoff
0d24f2d4c1 Use external mock-request
mock-request is now factored out to matrix-mock-request; use it
2017-07-04 15:45:22 +01:00
Krombel
dd0ff3eeb5 intercept first authedRequest to determine if accessToken can be send by header (clearer structure) 2017-07-04 16:16:10 +02:00
Krombel
07868f701a Merge remote-tracking branch 'upstream/develop' into access_token_header 2017-07-04 15:28:17 +02:00
Richard van der Hoff
f4f0e4b60f Merge pull request #480 from matrix-org/rav/fix_test_races
Fix some races in the tests
2017-07-04 14:04:24 +01:00
Richard van der Hoff
ae950a2ff4 Fix some races in the tests
There is a common pattern in the tests which is, when we want to mock a /sync,
to flush it, and then, in the next tick of the promise loop, to wait for the
syncing event. However, this is racy: there is no guarantee that the syncing
event will not happen before the next tick of the promise loop.

Instead, we should set the expectation of the syncing event, then do the flush.
(Technically we only need to wait for the syncing event, but by waiting for
both we'll catch any errors thrown by the flush, and make sure we don't have
any outstanding flushes before proceeding).

Add a utility method to TestClient to do the above, and use it where we have a
TestClient.

(Also fixes a couple of other minor buglets in the tests).
2017-07-04 13:48:26 +01:00
Richard van der Hoff
5f6e4bdfe9 Avoid parsing plain-text errors as JSON
It's somewhat unhelpful to spam over the actual error from the reverse-proxy or
whatever with a SyntaxError.
2017-07-03 19:30:23 +01:00