mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
tests: Spy on socket.io messages as early as possible
This commit is contained in:
parent
e28c9ffc97
commit
c8e0916e1a
2 changed files with 25 additions and 29 deletions
|
@ -311,14 +311,21 @@ const handshake = async () => {
|
|||
}
|
||||
});
|
||||
|
||||
await new Promise((resolve) => {
|
||||
const h = (obj) => {
|
||||
if (obj.accessStatus || obj.type !== 'CLIENT_VARS') return;
|
||||
socket.off('message', h);
|
||||
resolve();
|
||||
};
|
||||
socket.on('message', h);
|
||||
});
|
||||
await Promise.all([
|
||||
new Promise((resolve) => {
|
||||
const h = (obj) => {
|
||||
if (obj.accessStatus || obj.type !== 'CLIENT_VARS') return;
|
||||
socket.off('message', h);
|
||||
resolve();
|
||||
};
|
||||
socket.on('message', h);
|
||||
}),
|
||||
// This hook is only intended to be used by test code. If a plugin would like to use this hook,
|
||||
// the hook must first be promoted to officially supported by deleting the leading underscore
|
||||
// from the name, adding documentation to `doc/api/hooks_client-side.md`, and deleting this
|
||||
// comment.
|
||||
hooks.aCallAll('_socketCreated', {socket}),
|
||||
]);
|
||||
};
|
||||
|
||||
/** Defers message handling until setCollabClient() is called with a non-null value. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue