mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
Fixed frontend tests. (#6210)
* Fixed frontend tests. * Use old socket io syntax. * uSE ESM: * Remove padvar. * Remove cypress.
This commit is contained in:
parent
2fa2d5bd17
commit
d34b964cc2
5 changed files with 18 additions and 23 deletions
|
@ -21,9 +21,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const ueberDB = require('ueberdb2');
|
||||
import ueberDB from 'ueberdb2';
|
||||
const settings = require('../utils/Settings');
|
||||
const log4js = require('log4js');
|
||||
import log4js from 'log4js';
|
||||
const stats = require('../stats')
|
||||
|
||||
const logger = log4js.getLogger('ueberDB');
|
||||
|
|
|
@ -957,7 +957,6 @@ const handleClientReady = async (socket:any, message: typeof ChatMessage) => {
|
|||
rev: pad.getHeadRevisionNumber(),
|
||||
time: currentTime,
|
||||
},
|
||||
socketTransportProtocols: settings.socketTransportProtocols,
|
||||
colorPalette: authorManager.getColorPalette(),
|
||||
clientIp: '127.0.0.1',
|
||||
userColor: authorColorId,
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
||||
|
||||
const events = require('events');
|
||||
import events from 'events';
|
||||
const express = require('../express');
|
||||
const log4js = require('log4js');
|
||||
import log4js from 'log4js';
|
||||
const proxyaddr = require('proxy-addr');
|
||||
const settings = require('../../utils/Settings');
|
||||
import {Server} from 'socket.io'
|
||||
import {Server, Socket} from 'socket.io'
|
||||
const socketIORouter = require('../../handler/SocketIORouter');
|
||||
const hooks = require('../../../static/js/pluginfw/hooks');
|
||||
const padMessageHandler = require('../../handler/PadMessageHandler');
|
||||
|
@ -17,7 +17,7 @@ const logger = log4js.getLogger('socket.io');
|
|||
const sockets = new Set();
|
||||
const socketsEvents = new events.EventEmitter();
|
||||
|
||||
exports.expressCloseServer = async () => {
|
||||
export const expressCloseServer = async () => {
|
||||
if (io == null) return;
|
||||
logger.info('Closing socket.io engine...');
|
||||
// Close the socket.io engine to disconnect existing clients and reject new clients. Don't call
|
||||
|
@ -48,7 +48,7 @@ exports.expressCloseServer = async () => {
|
|||
logger.info('All socket.io clients have disconnected');
|
||||
};
|
||||
|
||||
exports.socketSessionMiddleware = (args: any) => (socket: any, next: Function) => {
|
||||
const socketSessionMiddleware = (args: any) => (socket: any, next: Function) => {
|
||||
const req = socket.request;
|
||||
// Express sets req.ip but socket.io does not. Replicate Express's behavior here.
|
||||
if (req.ip == null) {
|
||||
|
@ -65,19 +65,16 @@ exports.socketSessionMiddleware = (args: any) => (socket: any, next: Function) =
|
|||
express.sessionMiddleware(req, {}, next);
|
||||
};
|
||||
|
||||
exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
||||
export const expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
||||
// init socket.io and redirect all requests to the MessageHandler
|
||||
// there shouldn't be a browser that isn't compatible to all
|
||||
// transports in this list at once
|
||||
// e.g. XHR is disabled in IE by default, so in IE it should use jsonp-polling
|
||||
io = new Server({
|
||||
io = new Server(args.server,{
|
||||
transports: settings.socketTransportProtocols,
|
||||
})
|
||||
|
||||
io.attach(args.server, {
|
||||
cookie: false,
|
||||
maxHttpBufferSize: settings.socketIo.maxHttpBufferSize,
|
||||
});
|
||||
})
|
||||
|
||||
io.on('connection', (socket:any) => {
|
||||
sockets.add(socket);
|
||||
|
@ -92,11 +89,11 @@ exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Functio
|
|||
});
|
||||
});
|
||||
|
||||
io.use(exports.socketSessionMiddleware(args));
|
||||
io.use(socketSessionMiddleware(args));
|
||||
|
||||
// Temporary workaround so all clients go through middleware and handle connection
|
||||
io.of('/pluginfw/installer').use(exports.socketSessionMiddleware(args))
|
||||
io.of('/settings').use(exports.socketSessionMiddleware(args))
|
||||
io.of('/pluginfw/installer').use(socketSessionMiddleware(args))
|
||||
io.of('/settings').use(socketSessionMiddleware(args))
|
||||
|
||||
io.use((socket:any, next:Function) => {
|
||||
socket.conn.on('packet', (packet:string) => {
|
||||
|
|
|
@ -88,7 +88,6 @@
|
|||
"@types/sinon": "^17.0.3",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"@types/underscore": "^1.11.15",
|
||||
"cypress": "^13.6.6",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-etherpad": "^3.0.22",
|
||||
"etherpad-cli-client": "^3.0.1",
|
||||
|
@ -114,7 +113,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --import=tsx --timeout 120000 --recursive tests/backend/specs/**.ts tests/backend/specs/**/*.ts",
|
||||
"test": "mocha --import=tsx --timeout 120000 --recursive tests/backend/specs/**.ts tests/backend/specs/**/*.ts ../node_modules/ep_*/static/tests/backend/specs",
|
||||
"test-container": "mocha --import=tsx --timeout 5000 tests/container/specs/api",
|
||||
"dev": "node --import tsx node/server.ts",
|
||||
"prod": "node --import tsx node/server.ts",
|
||||
|
|
|
@ -36,8 +36,8 @@ describe('Messages in the COLLABROOM', function () {
|
|||
// User 1 starts sending a change to the server.
|
||||
let sendStarted;
|
||||
const finishSend = (() => {
|
||||
const socketJsonObj = helper.padChrome$.window.pad.socket.json;
|
||||
const sendBackup = socketJsonObj.send;
|
||||
const socketJsonObj = helper.padChrome$.window.pad.socket;
|
||||
const sendBackup = socketJsonObj.emit;
|
||||
let startSend;
|
||||
sendStarted = new Promise((resolve) => { startSend = resolve; });
|
||||
let finishSend;
|
||||
|
@ -46,7 +46,7 @@ describe('Messages in the COLLABROOM', function () {
|
|||
startSend();
|
||||
sendP.then(() => {
|
||||
socketJsonObj.send = sendBackup;
|
||||
socketJsonObj.send(...args);
|
||||
socketJsonObj.send('message', ...args);
|
||||
});
|
||||
};
|
||||
return finishSend;
|
||||
|
|
Loading…
Reference in a new issue