Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
65 lines
2.4 KiB
TypeScript
65 lines
2.4 KiB
TypeScript
import type WS from 'jest-websocket-mock';
|
|
|
|
const acceptConnection = async (server: WS) => {
|
|
await server.nextMessage.then(async (message) => {
|
|
await expect(message).toBe('{"msg":"connect","version":"1","support":["1","pre2","pre1"]}');
|
|
server.send(`{"msg":"connected","session":"session"}`);
|
|
});
|
|
};
|
|
export const handleConnection = async (server: WS, ...client: Promise<unknown>[]) => {
|
|
await Promise.all([acceptConnection(server), ...client]);
|
|
};
|
|
|
|
export const handleConnectionAndRejects = async (server: WS, ...client: Promise<unknown>[]) => {
|
|
const suggestedVersion = '1';
|
|
|
|
return Promise.all([
|
|
server.nextMessage.then((message) => {
|
|
expect(message).toBe('{"msg":"connect","version":"1","support":["1","pre2","pre1"]}');
|
|
return server.send(`{"msg":"failed","version":"${suggestedVersion}"}`);
|
|
}),
|
|
...client,
|
|
]);
|
|
};
|
|
|
|
const handleConnectionButNoResponse = async (server: WS, method: string, params: string[]) => {
|
|
return server.nextMessage.then(async (msg) => {
|
|
if (typeof msg !== 'string') throw new Error('Expected message to be a string');
|
|
const message = JSON.parse(msg);
|
|
await expect(message).toMatchObject({
|
|
msg: 'method',
|
|
method,
|
|
params,
|
|
});
|
|
return message;
|
|
});
|
|
};
|
|
|
|
export const handleMethod = async (server: WS, method: string, params: any[], responseResult: string, ...client: Promise<unknown>[]) => {
|
|
const result = await handleConnectionButNoResponse(server, method, params);
|
|
return Promise.all([server.send(`{"msg":"result","id":"${result.id}","result":${responseResult}}`), ...client]).then((result) => {
|
|
result.shift();
|
|
return result;
|
|
});
|
|
};
|
|
|
|
export const handleSubscription = async (server: WS, id: string, streamName: string, streamParams: string) => {
|
|
await server.nextMessage.then(async (message) => {
|
|
await expect(message).toBe(
|
|
`{"msg":"sub","id":"${id}","name":"stream-${streamName}","params":["${streamParams}",{"useCollection":false,"args":[null]}]}`,
|
|
);
|
|
server.send(`{"msg":"ready","subs":["${id}"]}`);
|
|
});
|
|
};
|
|
export const fireStream = (action: 'changed' | 'removed' | 'added') => {
|
|
return (server: WS, streamName: string, streamParams: string) => {
|
|
return server.send(
|
|
`{"msg":"${action}","collection":"stream-${streamName}","id":"id","fields":{"eventName":"${streamParams}", "args":[1]}}`,
|
|
);
|
|
};
|
|
};
|
|
|
|
export const fireStreamChange = fireStream('changed');
|
|
export const fireStreamRemove = fireStream('removed');
|
|
export const fireStreamAdded = fireStream('added');
|