mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 17:36:14 -04:00
lint: Run eslint --fix
on bin/
and tests/
This commit is contained in:
parent
0625739cb8
commit
b8d07a42eb
78 changed files with 4319 additions and 4599 deletions
|
@ -2,22 +2,19 @@
|
|||
* Spys on socket.io messages and saves them into several arrays
|
||||
* that are visible in tests
|
||||
*/
|
||||
helper.spyOnSocketIO = function (){
|
||||
helper.contentWindow().pad.socket.on('message', function(msg){
|
||||
if (msg.type == "COLLABROOM") {
|
||||
|
||||
helper.spyOnSocketIO = function () {
|
||||
helper.contentWindow().pad.socket.on('message', (msg) => {
|
||||
if (msg.type == 'COLLABROOM') {
|
||||
if (msg.data.type == 'ACCEPT_COMMIT') {
|
||||
helper.commits.push(msg);
|
||||
}
|
||||
else if (msg.data.type == 'USER_NEWINFO') {
|
||||
helper.userInfos.push(msg)
|
||||
}
|
||||
else if (msg.data.type == 'CHAT_MESSAGE') {
|
||||
helper.chatMessages.push(msg)
|
||||
} else if (msg.data.type == 'USER_NEWINFO') {
|
||||
helper.userInfos.push(msg);
|
||||
} else if (msg.data.type == 'CHAT_MESSAGE') {
|
||||
helper.chatMessages.push(msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Makes an edit via `sendkeys` to the position of the caret and ensures ACCEPT_COMMIT
|
||||
|
@ -31,14 +28,12 @@ helper.spyOnSocketIO = function (){
|
|||
* @todo needs to support writing to a specified caret position
|
||||
*
|
||||
*/
|
||||
helper.edit = async function(message, line){
|
||||
let editsNum = helper.commits.length;
|
||||
helper.edit = async function (message, line) {
|
||||
const editsNum = helper.commits.length;
|
||||
line = line ? line - 1 : 0;
|
||||
helper.linesDiv()[line].sendkeys(message);
|
||||
return helper.waitForPromise(function(){
|
||||
return editsNum + 1 === helper.commits.length;
|
||||
})
|
||||
}
|
||||
return helper.waitForPromise(() => editsNum + 1 === helper.commits.length);
|
||||
};
|
||||
|
||||
/**
|
||||
* The pad text as an array of divs
|
||||
|
@ -48,11 +43,11 @@ helper.edit = async function(message, line){
|
|||
*
|
||||
* @returns {Array.<HTMLElement>} array of divs
|
||||
*/
|
||||
helper.linesDiv = function(){
|
||||
return helper.padInner$('.ace-line').map(function(){
|
||||
return $(this)
|
||||
}).get()
|
||||
}
|
||||
helper.linesDiv = function () {
|
||||
return helper.padInner$('.ace-line').map(function () {
|
||||
return $(this);
|
||||
}).get();
|
||||
};
|
||||
|
||||
/**
|
||||
* The pad text as an array of lines
|
||||
|
@ -60,18 +55,18 @@ helper.linesDiv = function(){
|
|||
*
|
||||
* @returns {Array.<string>} lines of text
|
||||
*/
|
||||
helper.textLines = function(){
|
||||
helper.textLines = function () {
|
||||
return helper.linesDiv().map((div) => div.text());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The default pad text transmitted via `clientVars`
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
helper.defaultText = function(){
|
||||
helper.defaultText = function () {
|
||||
return helper.padChrome$.window.clientVars.collab_client_vars.initialAttributedText.text;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a chat `message` via `sendKeys`
|
||||
|
@ -87,25 +82,23 @@ helper.defaultText = function(){
|
|||
* @param {string} message the chat message to be sent
|
||||
* @returns {Promise}
|
||||
*/
|
||||
helper.sendChatMessage = function(message){
|
||||
let noOfChatMessages = helper.chatMessages.length;
|
||||
helper.padChrome$("#chatinput").sendkeys(message)
|
||||
return helper.waitForPromise(function(){
|
||||
return noOfChatMessages + 1 === helper.chatMessages.length;
|
||||
})
|
||||
}
|
||||
helper.sendChatMessage = function (message) {
|
||||
const noOfChatMessages = helper.chatMessages.length;
|
||||
helper.padChrome$('#chatinput').sendkeys(message);
|
||||
return helper.waitForPromise(() => noOfChatMessages + 1 === helper.chatMessages.length);
|
||||
};
|
||||
|
||||
/**
|
||||
* Opens the settings menu if its hidden via button
|
||||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
helper.showSettings = function() {
|
||||
if(!helper.isSettingsShown()){
|
||||
helper.settingsButton().click()
|
||||
return helper.waitForPromise(function(){return helper.isSettingsShown(); },2000);
|
||||
helper.showSettings = function () {
|
||||
if (!helper.isSettingsShown()) {
|
||||
helper.settingsButton().click();
|
||||
return helper.waitForPromise(() => helper.isSettingsShown(), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide the settings menu if its open via button
|
||||
|
@ -113,12 +106,12 @@ helper.showSettings = function() {
|
|||
* @returns {Promise}
|
||||
* @todo untested
|
||||
*/
|
||||
helper.hideSettings = function() {
|
||||
if(helper.isSettingsShown()){
|
||||
helper.settingsButton().click()
|
||||
return helper.waitForPromise(function(){return !helper.isSettingsShown(); },2000);
|
||||
helper.hideSettings = function () {
|
||||
if (helper.isSettingsShown()) {
|
||||
helper.settingsButton().click();
|
||||
return helper.waitForPromise(() => !helper.isSettingsShown(), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Makes the chat window sticky via settings menu if the settings menu is
|
||||
|
@ -126,15 +119,13 @@ helper.hideSettings = function() {
|
|||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
helper.enableStickyChatviaSettings = function() {
|
||||
var stickyChat = helper.padChrome$('#options-stickychat');
|
||||
if(helper.isSettingsShown() && !stickyChat.is(':checked')) {
|
||||
helper.enableStickyChatviaSettings = function () {
|
||||
const stickyChat = helper.padChrome$('#options-stickychat');
|
||||
if (helper.isSettingsShown() && !stickyChat.is(':checked')) {
|
||||
stickyChat.click();
|
||||
return helper.waitForPromise(function(){
|
||||
return helper.isChatboxSticky();
|
||||
},2000);
|
||||
return helper.waitForPromise(() => helper.isChatboxSticky(), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Unsticks the chat window via settings menu if the settings menu is open
|
||||
|
@ -142,13 +133,13 @@ helper.enableStickyChatviaSettings = function() {
|
|||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
helper.disableStickyChatviaSettings = function() {
|
||||
var stickyChat = helper.padChrome$('#options-stickychat');
|
||||
if(helper.isSettingsShown() && stickyChat.is(':checked')) {
|
||||
helper.disableStickyChatviaSettings = function () {
|
||||
const stickyChat = helper.padChrome$('#options-stickychat');
|
||||
if (helper.isSettingsShown() && stickyChat.is(':checked')) {
|
||||
stickyChat.click();
|
||||
return helper.waitForPromise(function(){return !helper.isChatboxSticky()},2000);
|
||||
return helper.waitForPromise(() => !helper.isChatboxSticky(), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Makes the chat window sticky via an icon on the top right of the chat
|
||||
|
@ -156,13 +147,13 @@ helper.disableStickyChatviaSettings = function() {
|
|||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
helper.enableStickyChatviaIcon = function() {
|
||||
var stickyChat = helper.padChrome$('#titlesticky');
|
||||
if(helper.isChatboxShown() && !helper.isChatboxSticky()) {
|
||||
helper.enableStickyChatviaIcon = function () {
|
||||
const stickyChat = helper.padChrome$('#titlesticky');
|
||||
if (helper.isChatboxShown() && !helper.isChatboxSticky()) {
|
||||
stickyChat.click();
|
||||
return helper.waitForPromise(function(){return helper.isChatboxSticky()},2000);
|
||||
return helper.waitForPromise(() => helper.isChatboxSticky(), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Disables the stickyness of the chat window via an icon on the
|
||||
|
@ -170,12 +161,12 @@ helper.enableStickyChatviaIcon = function() {
|
|||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
helper.disableStickyChatviaIcon = function() {
|
||||
if(helper.isChatboxShown() && helper.isChatboxSticky()) {
|
||||
helper.titlecross().click()
|
||||
return helper.waitForPromise(function(){return !helper.isChatboxSticky()},2000);
|
||||
helper.disableStickyChatviaIcon = function () {
|
||||
if (helper.isChatboxShown() && helper.isChatboxSticky()) {
|
||||
helper.titlecross().click();
|
||||
return helper.waitForPromise(() => !helper.isChatboxSticky(), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the src-attribute of the main iframe to the timeslider
|
||||
|
@ -189,15 +180,14 @@ helper.disableStickyChatviaIcon = function() {
|
|||
* @todo for some reason this does only work the first time, you cannot
|
||||
* goto rev 0 and then via the same method to rev 5. Use buttons instead
|
||||
*/
|
||||
helper.gotoTimeslider = function(revision){
|
||||
revision = Number.isInteger(revision) ? '#'+revision : '';
|
||||
var iframe = $('#iframe-container iframe');
|
||||
iframe.attr('src', iframe.attr('src')+'/timeslider' + revision);
|
||||
helper.gotoTimeslider = function (revision) {
|
||||
revision = Number.isInteger(revision) ? `#${revision}` : '';
|
||||
const iframe = $('#iframe-container iframe');
|
||||
iframe.attr('src', `${iframe.attr('src')}/timeslider${revision}`);
|
||||
|
||||
return helper.waitForPromise(function(){
|
||||
return helper.timesliderTimerTime()
|
||||
&& !Number.isNaN(new Date(helper.timesliderTimerTime()).getTime()) },10000);
|
||||
}
|
||||
return helper.waitForPromise(() => helper.timesliderTimerTime() &&
|
||||
!Number.isNaN(new Date(helper.timesliderTimerTime()).getTime()), 10000);
|
||||
};
|
||||
|
||||
/**
|
||||
* Clicks in the timeslider at a specific offset
|
||||
|
@ -206,24 +196,24 @@ helper.gotoTimeslider = function(revision){
|
|||
* @todo no mousemove test
|
||||
* @param {number} X coordinate
|
||||
*/
|
||||
helper.sliderClick = function(X){
|
||||
let sliderBar = helper.sliderBar()
|
||||
let edown = new jQuery.Event('mousedown');
|
||||
let eup = new jQuery.Event('mouseup');
|
||||
helper.sliderClick = function (X) {
|
||||
const sliderBar = helper.sliderBar();
|
||||
const edown = new jQuery.Event('mousedown');
|
||||
const eup = new jQuery.Event('mouseup');
|
||||
edown.clientX = eup.clientX = X;
|
||||
edown.clientY = eup.clientY = sliderBar.offset().top;
|
||||
|
||||
sliderBar.trigger(edown);
|
||||
sliderBar.trigger(eup);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The timeslider text as an array of lines
|
||||
*
|
||||
* @returns {Array.<string>} lines of text
|
||||
*/
|
||||
helper.timesliderTextLines = function(){
|
||||
return helper.contentWindow().$('.ace-line').map(function(){
|
||||
return $(this).text()
|
||||
}).get()
|
||||
}
|
||||
helper.timesliderTextLines = function () {
|
||||
return helper.contentWindow().$('.ace-line').map(function () {
|
||||
return $(this).text();
|
||||
}).get();
|
||||
};
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
*
|
||||
* @returns {HTMLElement} contentWindow
|
||||
*/
|
||||
helper.contentWindow = function(){
|
||||
helper.contentWindow = function () {
|
||||
return $('#iframe-container iframe')[0].contentWindow;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Opens the chat unless it is already open via an
|
||||
|
@ -13,117 +13,118 @@ helper.contentWindow = function(){
|
|||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
helper.showChat = function(){
|
||||
var chaticon = helper.chatIcon();
|
||||
if(chaticon.hasClass('visible')) {
|
||||
chaticon.click()
|
||||
return helper.waitForPromise(function(){return !chaticon.hasClass('visible'); },2000)
|
||||
helper.showChat = function () {
|
||||
const chaticon = helper.chatIcon();
|
||||
if (chaticon.hasClass('visible')) {
|
||||
chaticon.click();
|
||||
return helper.waitForPromise(() => !chaticon.hasClass('visible'), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the chat window if it is shown and not sticky
|
||||
*
|
||||
* @returns {Promise}
|
||||
*/
|
||||
helper.hideChat = function(){
|
||||
if(helper.isChatboxShown() && !helper.isChatboxSticky()) {
|
||||
helper.titlecross().click()
|
||||
return helper.waitForPromise(function(){return !helper.isChatboxShown(); },2000);
|
||||
helper.hideChat = function () {
|
||||
if (helper.isChatboxShown() && !helper.isChatboxSticky()) {
|
||||
helper.titlecross().click();
|
||||
return helper.waitForPromise(() => !helper.isChatboxShown(), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the chat icon from the bottom right of the page
|
||||
*
|
||||
* @returns {HTMLElement} the chat icon
|
||||
*/
|
||||
helper.chatIcon = function(){return helper.padChrome$('#chaticon')}
|
||||
helper.chatIcon = function () { return helper.padChrome$('#chaticon'); };
|
||||
|
||||
/**
|
||||
* The chat messages from the UI
|
||||
*
|
||||
* @returns {Array.<HTMLElement>}
|
||||
*/
|
||||
helper.chatTextParagraphs = function(){return helper.padChrome$('#chattext').children("p")}
|
||||
helper.chatTextParagraphs = function () { return helper.padChrome$('#chattext').children('p'); };
|
||||
|
||||
/**
|
||||
* Returns true if the chat box is sticky
|
||||
*
|
||||
* @returns {boolean} stickyness of the chat box
|
||||
*/
|
||||
helper.isChatboxSticky = function() {
|
||||
helper.isChatboxSticky = function () {
|
||||
return helper.padChrome$('#chatbox').hasClass('stickyChat');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the chat box is shown
|
||||
*
|
||||
* @returns {boolean} visibility of the chat box
|
||||
*/
|
||||
helper.isChatboxShown = function() {
|
||||
helper.isChatboxShown = function () {
|
||||
return helper.padChrome$('#chatbox').hasClass('visible');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the settings menu
|
||||
*
|
||||
* @returns {HTMLElement} the settings menu
|
||||
*/
|
||||
helper.settingsMenu = function(){return helper.padChrome$('#settings') };
|
||||
helper.settingsMenu = function () { return helper.padChrome$('#settings'); };
|
||||
|
||||
/**
|
||||
* Gets the settings button
|
||||
*
|
||||
* @returns {HTMLElement} the settings button
|
||||
*/
|
||||
helper.settingsButton = function(){return helper.padChrome$("button[data-l10n-id='pad.toolbar.settings.title']") }
|
||||
helper.settingsButton = function () { return helper.padChrome$("button[data-l10n-id='pad.toolbar.settings.title']"); };
|
||||
|
||||
/**
|
||||
* Gets the titlecross icon
|
||||
*
|
||||
* @returns {HTMLElement} the titlecross icon
|
||||
*/
|
||||
helper.titlecross = function(){return helper.padChrome$('#titlecross')}
|
||||
helper.titlecross = function () { return helper.padChrome$('#titlecross'); };
|
||||
|
||||
/**
|
||||
* Returns true if the settings menu is visible
|
||||
*
|
||||
* @returns {boolean} is the settings menu shown?
|
||||
*/
|
||||
helper.isSettingsShown = function() {
|
||||
helper.isSettingsShown = function () {
|
||||
return helper.padChrome$('#settings').hasClass('popup-show');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the timer div of a timeslider that has the datetime of the revision
|
||||
*
|
||||
* @returns {HTMLElement} timer
|
||||
*/
|
||||
helper.timesliderTimer = function(){
|
||||
if(typeof helper.contentWindow().$ == 'function'){
|
||||
return helper.contentWindow().$('#timer') }
|
||||
helper.timesliderTimer = function () {
|
||||
if (typeof helper.contentWindow().$ === 'function') {
|
||||
return helper.contentWindow().$('#timer');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the time of the revision on a timeslider
|
||||
*
|
||||
* @returns {HTMLElement} timer
|
||||
*/
|
||||
helper.timesliderTimerTime = function(){
|
||||
if(helper.timesliderTimer()){
|
||||
return helper.timesliderTimer().text()
|
||||
helper.timesliderTimerTime = function () {
|
||||
if (helper.timesliderTimer()) {
|
||||
return helper.timesliderTimer().text();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The ui-slidar-bar element in the timeslider
|
||||
*
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
helper.sliderBar = function(){
|
||||
return helper.contentWindow().$('#ui-slider-bar')
|
||||
}
|
||||
helper.sliderBar = function () {
|
||||
return helper.contentWindow().$('#ui-slider-bar');
|
||||
};
|
||||
|
||||
/**
|
||||
* revision_date element
|
||||
|
@ -131,9 +132,9 @@ helper.sliderBar = function(){
|
|||
*
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
helper.revisionDateElem = function(){
|
||||
helper.revisionDateElem = function () {
|
||||
return helper.contentWindow().$('#revision_date').text();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* revision_label element
|
||||
|
@ -141,6 +142,6 @@ helper.revisionDateElem = function(){
|
|||
*
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
helper.revisionLabelElem = function(){
|
||||
return helper.contentWindow().$('#revision_label')
|
||||
}
|
||||
helper.revisionLabelElem = function () {
|
||||
return helper.contentWindow().$('#revision_label');
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue