mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 22:23:33 +01:00
tests: Don't rely on global pad
variable
This commit is contained in:
parent
e99eb6366c
commit
f5c2ea853c
4 changed files with 9 additions and 5 deletions
|
@ -278,7 +278,7 @@ const helper = {};
|
||||||
helper.withFastCommit = async (fn) => {
|
helper.withFastCommit = async (fn) => {
|
||||||
const incorp = () => helper.padChrome$.padeditor.ace.callWithAce(
|
const incorp = () => helper.padChrome$.padeditor.ace.callWithAce(
|
||||||
(ace) => ace.ace_inCallStackIfNecessary('helper.edit', () => ace.ace_fastIncorp()));
|
(ace) => ace.ace_inCallStackIfNecessary('helper.edit', () => ace.ace_fastIncorp()));
|
||||||
const cc = helper.padChrome$.window.pad.collabClient;
|
const cc = helper.padChrome$.window.require('ep_etherpad-lite/static/js/pad').pad.collabClient;
|
||||||
const {commitDelay} = cc;
|
const {commitDelay} = cc;
|
||||||
cc.commitDelay = 0;
|
cc.commitDelay = 0;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
* that are visible in tests
|
* that are visible in tests
|
||||||
*/
|
*/
|
||||||
helper.spyOnSocketIO = () => {
|
helper.spyOnSocketIO = () => {
|
||||||
helper.contentWindow().pad.socket.on('message', (msg) => {
|
const {pad} = helper.contentWindow().require('ep_etherpad-lite/static/js/pad');
|
||||||
|
pad.socket.on('message', (msg) => {
|
||||||
if (msg.type !== 'COLLABROOM') return;
|
if (msg.type !== 'COLLABROOM') return;
|
||||||
if (msg.data.type === 'ACCEPT_COMMIT') {
|
if (msg.data.type === 'ACCEPT_COMMIT') {
|
||||||
helper.commits.push(msg);
|
helper.commits.push(msg);
|
||||||
|
|
|
@ -4,6 +4,8 @@ describe('Messages in the COLLABROOM', function () {
|
||||||
const user1Text = 'text created by user 1';
|
const user1Text = 'text created by user 1';
|
||||||
const user2Text = 'text created by user 2';
|
const user2Text = 'text created by user 2';
|
||||||
|
|
||||||
|
const getPadObj = () => helper.padChrome$.window.require('ep_etherpad-lite/static/js/pad').pad;
|
||||||
|
|
||||||
const triggerEvent = (eventName) => {
|
const triggerEvent = (eventName) => {
|
||||||
const event = new helper.padInner$.Event(eventName);
|
const event = new helper.padInner$.Event(eventName);
|
||||||
helper.padInner$('#innerdocbody').trigger(event);
|
helper.padInner$('#innerdocbody').trigger(event);
|
||||||
|
@ -36,7 +38,7 @@ describe('Messages in the COLLABROOM', function () {
|
||||||
// User 1 starts sending a change to the server.
|
// User 1 starts sending a change to the server.
|
||||||
let sendStarted;
|
let sendStarted;
|
||||||
const finishSend = (() => {
|
const finishSend = (() => {
|
||||||
const socketJsonObj = helper.padChrome$.window.pad.socket.json;
|
const socketJsonObj = getPadObj().socket.json;
|
||||||
const sendBackup = socketJsonObj.send;
|
const sendBackup = socketJsonObj.send;
|
||||||
let startSend;
|
let startSend;
|
||||||
sendStarted = new Promise((resolve) => { startSend = resolve; });
|
sendStarted = new Promise((resolve) => { startSend = resolve; });
|
||||||
|
@ -60,7 +62,7 @@ describe('Messages in the COLLABROOM', function () {
|
||||||
// User 1 receives a change from user 2. (User 1 will not incorporate the change until the
|
// User 1 receives a change from user 2. (User 1 will not incorporate the change until the
|
||||||
// composition is completed.)
|
// composition is completed.)
|
||||||
const user2ChangeArrivedAtUser1 = new Promise((resolve) => {
|
const user2ChangeArrivedAtUser1 = new Promise((resolve) => {
|
||||||
const cc = helper.padChrome$.window.pad.collabClient;
|
const cc = getPadObj().collabClient;
|
||||||
const origHM = cc.handleMessageFromServer;
|
const origHM = cc.handleMessageFromServer;
|
||||||
cc.handleMessageFromServer = (evt) => {
|
cc.handleMessageFromServer = (evt) => {
|
||||||
if (evt.type === 'COLLABROOM' && evt.data.type === 'NEW_CHANGES') {
|
if (evt.type === 'COLLABROOM' && evt.data.type === 'NEW_CHANGES') {
|
||||||
|
|
|
@ -8,7 +8,8 @@ describe('Pad modal', function () {
|
||||||
await helper.aNewPad();
|
await helper.aNewPad();
|
||||||
|
|
||||||
// force a "slowcommit" error
|
// force a "slowcommit" error
|
||||||
helper.padChrome$.window.pad.handleChannelStateChange('DISCONNECTED', 'slowcommit');
|
const {pad} = helper.padChrome$.window.require('ep_etherpad-lite/static/js/pad');
|
||||||
|
pad.handleChannelStateChange('DISCONNECTED', 'slowcommit');
|
||||||
|
|
||||||
// wait for modal to be displayed
|
// wait for modal to be displayed
|
||||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||||
|
|
Loading…
Reference in a new issue