overleaf/libraries
Antoine Clausse 5afa892981 [fetch-utils] Fix unit tests (#20210)
* [fetch-utils] Fix FetchUtilsTests.js tests

* Cleanup between tests
* Define `AbortError`

* [fetch-utils] Add `expectConnectionCount` showcasing that the connection stays on when the stream is destroyed

* Revert "[fetch-utils] Add `expectConnectionCount` showcasing that the connection stays on when the stream is destroyed"

This reverts commit b10da7b3fc06a7345df8fd70f27fad70a478bbb4.

* [fetch-utils] Fix `supports abort signals` test

* [fetch-utils] Add tests "aborts the request when the request body is destroyed during transfer"

* [fetch-utils] Add extra waiting step before `expectRequestAborted`

* [fetch-utils] Add `while (!req?.destroyed) await wait(10)`

Unfortunately I couldn't find a better event to await.

To try with this to test flakiness
```
for i in {1..100}; do npm run test:unit || break; echo "Run $i completed"; done
```

* [fetch-utils] Replace arbitrary `wait(10)` by `this.server.waitForEvent('request-received')`

* [fetch-utils] Improve tests per PR comments

See https://github.com/overleaf/internal/pull/20210

1. Replace `waitForEvent` with `once`
2. Replace `waitForRequestAborted` by `expectRequestAborted`
3. Add comment in `expectRequestAborted` empty catch block

Non-flakiness rechecked with `for i in {1..100}; do npm run test:unit || break; echo "Run $i completed"; done`

* [fetch-utils] Add small wait before checking `lastReq === undefined`

Per https://github.com/overleaf/internal/pull/20210#discussion_r1743329462

GitOrigin-RevId: 5fe542e0a8e6011307e03237e2f81404d9a0e674
2024-09-05 08:05:57 +00:00
..
access-token-encryptor [web] Promisify two-factor-authentication (#19004) 2024-06-26 08:05:06 +00:00
fetch-utils [fetch-utils] Fix unit tests (#20210) 2024-09-05 08:05:57 +00:00
logger Add some JSDoc types to @overleaf/logger (#19153) 2024-06-28 08:04:25 +00:00
metrics Support v5 of mongodb when recording metrics 2024-08-21 08:04:55 +00:00
o-error Merge pull request #18167 from overleaf/em-simpler-typescript-backend 2024-05-07 08:04:00 +00:00
object-persistor Merge pull request #19322 from overleaf/revert-19259-ac-update-google-cloud-storage 2024-07-15 09:01:58 +00:00
overleaf-editor-core Merge pull request #20057 from overleaf/jpa-readonly-tuning 2024-08-23 08:04:48 +00:00
promise-utils Return the Promise from an expressified async function (#19359) 2024-07-15 09:05:29 +00:00
ranges-tracker Merge pull request #20052 from overleaf/em-tracked-deletes-limit 2024-08-27 08:04:31 +00:00
redis-wrapper Merge pull request #18906 from overleaf/em-migrate-existing-histories-2 2024-06-19 08:05:02 +00:00
settings Merge pull request #18167 from overleaf/em-simpler-typescript-backend 2024-05-07 08:04:00 +00:00
stream-utils Merge pull request #18167 from overleaf/em-simpler-typescript-backend 2024-05-07 08:04:00 +00:00