mirror of
https://github.com/hexastack/hexabot
synced 2024-11-23 01:55:15 +00:00
fix(api): unit tests
This commit is contained in:
parent
476ffb6143
commit
ff17a9db06
@ -24,6 +24,7 @@
|
||||
"test:cov": "jest --coverage --runInBand --detectOpenHandles --forceExit",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json",
|
||||
"test:clear": "jest --clearCache",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"reset": "npm install && npm run containers:restart",
|
||||
"reset:hard": "npm clean-install && npm run containers:rebuild",
|
||||
|
@ -49,6 +49,8 @@ describe('WebsocketGateway', () => {
|
||||
ioClient = io('http://localhost:3000', {
|
||||
autoConnect: false,
|
||||
transports: ['websocket', 'polling'],
|
||||
// path: '/socket.io/?EIO=4&transport=websocket&channel=offline',
|
||||
query: { EIO: '4', transport: 'websocket', channel: 'offline' },
|
||||
});
|
||||
|
||||
app.listen(3000);
|
||||
|
@ -251,30 +251,26 @@ export class WebsocketGateway
|
||||
|
||||
handleConnection(client: Socket, ..._args: any[]): void {
|
||||
const { sockets } = this.io.sockets;
|
||||
const handshake = client.handshake;
|
||||
const { channel } = handshake.query;
|
||||
this.logger.log(`Client id: ${client.id} connected`);
|
||||
this.logger.debug(`Number of connected clients: ${sockets?.size}`);
|
||||
|
||||
this.eventEmitter.emit(`hook:websocket:connection`, client);
|
||||
// @TODO : Revisit once we don't use anymore in frontend
|
||||
if (!channel) {
|
||||
const response = new SocketResponse();
|
||||
client.send(
|
||||
response
|
||||
.setHeaders({
|
||||
'access-control-allow-origin':
|
||||
config.security.cors.allowOrigins.join(','),
|
||||
vary: 'Origin',
|
||||
'access-control-allow-credentials':
|
||||
config.security.cors.allowCredentials.toString(),
|
||||
})
|
||||
.status(200)
|
||||
.json({
|
||||
success: true,
|
||||
}),
|
||||
);
|
||||
}
|
||||
const response = new SocketResponse();
|
||||
client.send(
|
||||
response
|
||||
.setHeaders({
|
||||
'access-control-allow-origin':
|
||||
config.security.cors.allowOrigins.join(','),
|
||||
vary: 'Origin',
|
||||
'access-control-allow-credentials':
|
||||
config.security.cors.allowCredentials.toString(),
|
||||
})
|
||||
.status(200)
|
||||
.json({
|
||||
success: true,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async handleDisconnect(client: Socket): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user