mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-25 01:46:14 -04:00
Merge branch 'develop' into mochawesome
This commit is contained in:
commit
7630e71957
75 changed files with 1347 additions and 1020 deletions
|
@ -7,10 +7,11 @@ describe('author of pad edition', function () {
|
|||
|
||||
// author 1 creates a new pad with some content (regular lines and lists)
|
||||
before(function (done) {
|
||||
var padId = helper.newPad(() => {
|
||||
const padId = helper.newPad(() => {
|
||||
// make sure pad has at least 3 lines
|
||||
const $firstLine = helper.padInner$('div').first();
|
||||
const threeLines = ['regular line', 'line with ordered list', 'line with unordered list'].join('<br>');
|
||||
const threeLines = ['regular line', 'line with ordered list', 'line with unordered list']
|
||||
.join('<br>');
|
||||
$firstLine.html(threeLines);
|
||||
|
||||
// wait for lines to be processed by Etherpad
|
||||
|
@ -45,7 +46,8 @@ describe('author of pad edition', function () {
|
|||
setTimeout(() => {
|
||||
// Expire cookie, so author is changed after reloading the pad.
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Example_4_Reset_the_previous_cookie
|
||||
helper.padChrome$.document.cookie = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
|
||||
helper.padChrome$.document.cookie =
|
||||
'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
|
||||
|
||||
helper.newPad(done, padId);
|
||||
}, 10000);
|
||||
|
@ -62,26 +64,25 @@ describe('author of pad edition', function () {
|
|||
changeLineAndCheckOnlyThatChangeIsFromThisAuthor(REGULAR_LINE, 'x', done);
|
||||
});
|
||||
|
||||
it('marks only the new content as changes of the second user on a line with ordered list', function (done) {
|
||||
|
||||
it('marks only the new content as changes of the second user on a ' +
|
||||
'line with ordered list', function (done) {
|
||||
this.timeout(1000);
|
||||
changeLineAndCheckOnlyThatChangeIsFromThisAuthor(LINE_WITH_ORDERED_LIST, 'y', done);
|
||||
});
|
||||
|
||||
it('marks only the new content as changes of the second user on a line with unordered list', function (done) {
|
||||
it('marks only the new content as changes of the second user on ' +
|
||||
'a line with unordered list', function (done) {
|
||||
this.timeout(1000);
|
||||
changeLineAndCheckOnlyThatChangeIsFromThisAuthor(LINE_WITH_UNORDERED_LIST, 'z', done);
|
||||
});
|
||||
|
||||
/* ********************** Helper functions ************************ */
|
||||
var getLine = function (lineNumber) {
|
||||
return helper.padInner$('div').eq(lineNumber);
|
||||
};
|
||||
const getLine = (lineNumber) => helper.padInner$('div').eq(lineNumber);
|
||||
|
||||
const getAuthorFromClassList = function (classes) {
|
||||
return classes.find((cls) => cls.startsWith('author'));
|
||||
};
|
||||
const getAuthorFromClassList = (classes) => classes.find((cls) => cls.startsWith('author'));
|
||||
|
||||
var changeLineAndCheckOnlyThatChangeIsFromThisAuthor = function (lineNumber, textChange, done) {
|
||||
const changeLineAndCheckOnlyThatChangeIsFromThisAuthor = (lineNumber, textChange, done) => {
|
||||
// get original author class
|
||||
const classes = getLine(lineNumber).find('span').first().attr('class').split(' ');
|
||||
const originalAuthor = getAuthorFromClassList(classes);
|
||||
|
|
|
@ -22,8 +22,6 @@ describe('bold button', function () {
|
|||
const $boldButton = chrome$('.buttonicon-bold');
|
||||
$boldButton.click();
|
||||
|
||||
// ace creates a new dom element when you press a button
|
||||
// so just get the first text element again
|
||||
const $newFirstTextElement = inner$('div').first();
|
||||
|
||||
// is there a <b> element now?
|
||||
|
@ -48,13 +46,11 @@ describe('bold button', function () {
|
|||
// select this text element
|
||||
$firstTextElement.sendkeys('{selectall}');
|
||||
|
||||
const e = inner$.Event(helper.evtType);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.ctrlKey = true; // Control key
|
||||
e.which = 66; // b
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
|
||||
// ace creates a new dom element when you press a button
|
||||
// so just get the first text element again
|
||||
const $newFirstTextElement = inner$('div').first();
|
||||
|
||||
// is there a <b> element now?
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
describe('As the caret is moved is the UI properly updated?', function () {
|
||||
/*
|
||||
let padName;
|
||||
const numberOfRows = 50;
|
||||
/*
|
||||
|
||||
//create a new pad before each test run
|
||||
beforeEach(function(cb){
|
||||
|
@ -16,7 +18,8 @@ describe('As the caret is moved is the UI properly updated?', function () {
|
|||
*/
|
||||
|
||||
/* Tests to do
|
||||
* Keystroke up (38), down (40), left (37), right (39) with and without special keys IE control / shift
|
||||
* Keystroke up (38), down (40), left (37), right (39)
|
||||
* with and without special keys IE control / shift
|
||||
* Page up (33) / down (34) with and without special keys
|
||||
* Page up on the first line shouldn't move the viewport
|
||||
* Down down on the last line shouldn't move the viewport
|
||||
|
@ -25,7 +28,9 @@ describe('As the caret is moved is the UI properly updated?', function () {
|
|||
*/
|
||||
|
||||
/* Challenges
|
||||
* How do we keep the authors focus on a line if the lines above the author are modified? We should only redraw the user to a location if they are typing and make sure shift and arrow keys aren't redrawing the UI else highlight - copy/paste would get broken
|
||||
* How do we keep the authors focus on a line if the lines above the author are modified?
|
||||
* We should only redraw the user to a location if they are typing and make sure shift
|
||||
* and arrow keys aren't redrawing the UI else highlight - copy/paste would get broken
|
||||
* How can we simulate an edit event in the test framework?
|
||||
*/
|
||||
/*
|
||||
|
@ -200,7 +205,8 @@ console.log(inner$);
|
|||
var chrome$ = helper.padChrome$;
|
||||
var numberOfRows = 50;
|
||||
|
||||
//ace creates a new dom element when you press a keystroke, so just get the first text element again
|
||||
// ace creates a new dom element when you press a keystroke,
|
||||
// so just get the first text element again
|
||||
var $newFirstTextElement = inner$("div").first();
|
||||
var originalDivHeight = inner$("div").first().css("height");
|
||||
prepareDocument(numberOfRows, $newFirstTextElement); // N lines into the first div as a target
|
||||
|
@ -208,28 +214,33 @@ console.log(inner$);
|
|||
helper.waitFor(function(){ // Wait for the DOM to register the new items
|
||||
return inner$("div").first().text().length == 6;
|
||||
}).done(function(){ // Once the DOM has registered the items
|
||||
inner$("div").each(function(index){ // Randomize the item heights (replicates images / headings etc)
|
||||
// Randomize the item heights (replicates images / headings etc)
|
||||
inner$("div").each(function(index){
|
||||
var random = Math.floor(Math.random() * (50)) + 20;
|
||||
$(this).css("height", random+"px");
|
||||
});
|
||||
|
||||
console.log(caretPosition(inner$));
|
||||
var newDivHeight = inner$("div").first().css("height");
|
||||
var heightHasChanged = originalDivHeight != newDivHeight; // has the new div height changed from the original div height
|
||||
// has the new div height changed from the original div height
|
||||
var heightHasChanged = originalDivHeight != newDivHeight;
|
||||
expect(heightHasChanged).to.be(true); // expect the first line to be blank
|
||||
});
|
||||
|
||||
// Is this Element now visible to the pad user?
|
||||
helper.waitFor(function(){ // Wait for the DOM to register the new items
|
||||
return isScrolledIntoView(inner$("div:nth-child("+numberOfRows+")"), inner$); // Wait for the DOM to scroll into place
|
||||
// Wait for the DOM to scroll into place
|
||||
return isScrolledIntoView(inner$("div:nth-child("+numberOfRows+")"), inner$);
|
||||
}).done(function(){ // Once the DOM has registered the items
|
||||
inner$("div").each(function(index){ // Randomize the item heights (replicates images / headings etc)
|
||||
// Randomize the item heights (replicates images / headings etc)
|
||||
inner$("div").each(function(index){
|
||||
var random = Math.floor(Math.random() * (80 - 20 + 1)) + 20;
|
||||
$(this).css("height", random+"px");
|
||||
});
|
||||
|
||||
var newDivHeight = inner$("div").first().css("height");
|
||||
var heightHasChanged = originalDivHeight != newDivHeight; // has the new div height changed from the original div height
|
||||
// has the new div height changed from the original div height
|
||||
var heightHasChanged = originalDivHeight != newDivHeight;
|
||||
expect(heightHasChanged).to.be(true); // expect the first line to be blank
|
||||
});
|
||||
var i = 0;
|
||||
|
@ -241,7 +252,8 @@ console.log(inner$);
|
|||
// Does scrolling back up the pad with the up arrow show the correct contents?
|
||||
helper.waitFor(function(){ // Wait for the new position to be in place
|
||||
try{
|
||||
return isScrolledIntoView(inner$("div:nth-child("+numberOfRows+")"), inner$); // Wait for the DOM to scroll into place
|
||||
// Wait for the DOM to scroll into place
|
||||
return isScrolledIntoView(inner$("div:nth-child("+numberOfRows+")"), inner$);
|
||||
}catch(e){
|
||||
return false;
|
||||
}
|
||||
|
@ -256,7 +268,8 @@ console.log(inner$);
|
|||
// Does scrolling back up the pad with the up arrow show the correct contents?
|
||||
helper.waitFor(function(){ // Wait for the new position to be in place
|
||||
try{
|
||||
return isScrolledIntoView(inner$("div:nth-child(0)"), inner$); // Wait for the DOM to scroll into place
|
||||
// Wait for the DOM to scroll into place
|
||||
return isScrolledIntoView(inner$("div:nth-child(0)"), inner$);
|
||||
}catch(e){
|
||||
return false;
|
||||
}
|
||||
|
@ -276,7 +289,8 @@ console.log(inner$);
|
|||
|
||||
// Does scrolling back up the pad with the up arrow show the correct contents?
|
||||
helper.waitFor(function(){ // Wait for the new position to be in place
|
||||
return isScrolledIntoView(inner$("div:nth-child(1)"), inner$); // Wait for the DOM to scroll into place
|
||||
// Wait for the DOM to scroll into place
|
||||
return isScrolledIntoView(inner$("div:nth-child(1)"), inner$);
|
||||
}).done(function(){ // Once the DOM has registered the items
|
||||
expect(true).to.be(true);
|
||||
done();
|
||||
|
@ -284,17 +298,19 @@ console.log(inner$);
|
|||
*/
|
||||
});
|
||||
|
||||
function prepareDocument(n, target) { // generates a random document with random content on n lines
|
||||
// generates a random document with random content on n lines
|
||||
const prepareDocument = (n, target) => {
|
||||
let i = 0;
|
||||
while (i < n) { // for each line
|
||||
target.sendkeys(makeStr()); // generate a random string and send that to the editor
|
||||
target.sendkeys('{enter}'); // generator an enter keypress
|
||||
i++; // rinse n times
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function keyEvent(target, charCode, ctrl, shift) { // sends a charCode to the window
|
||||
const e = target.Event(helper.evtType);
|
||||
// sends a charCode to the window
|
||||
const keyEvent = (target, charCode, ctrl, shift) => {
|
||||
const e = new target.Event(helper.evtType);
|
||||
if (ctrl) {
|
||||
e.ctrlKey = true; // Control key
|
||||
}
|
||||
|
@ -304,30 +320,33 @@ function keyEvent(target, charCode, ctrl, shift) { // sends a charCode to the wi
|
|||
e.which = charCode;
|
||||
e.keyCode = charCode;
|
||||
target('#innerdocbody').trigger(e);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function makeStr() { // from http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
|
||||
// from http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
|
||||
const makeStr = () => {
|
||||
let text = '';
|
||||
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
|
||||
for (let i = 0; i < 5; i++) text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
return text;
|
||||
}
|
||||
};
|
||||
|
||||
function isScrolledIntoView(elem, $) { // from http://stackoverflow.com/questions/487073/check-if-element-is-visible-after-scrolling
|
||||
// from http://stackoverflow.com/questions/487073/check-if-element-is-visible-after-scrolling
|
||||
const isScrolledIntoView = (elem, $) => {
|
||||
const docViewTop = $(window).scrollTop();
|
||||
const docViewBottom = docViewTop + $(window).height();
|
||||
const elemTop = $(elem).offset().top; // how far the element is from the top of it's container
|
||||
let elemBottom = elemTop + $(elem).height(); // how far plus the height of the elem.. IE is it all in?
|
||||
// how far plus the height of the elem.. IE is it all in?
|
||||
let elemBottom = elemTop + $(elem).height();
|
||||
elemBottom -= 16; // don't ask, sorry but this is needed..
|
||||
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
|
||||
}
|
||||
};
|
||||
|
||||
function caretPosition($) {
|
||||
const caretPosition = ($) => {
|
||||
const doc = $.window.document;
|
||||
const pos = doc.getSelection();
|
||||
pos.y = pos.anchorNode.parentElement.offsetTop;
|
||||
pos.x = pos.anchorNode.parentElement.offsetLeft;
|
||||
return pos;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,7 +7,8 @@ describe('change user color', function () {
|
|||
this.timeout(60000);
|
||||
});
|
||||
|
||||
it('Color picker remembers the user color after a refresh', function (done) {
|
||||
it('Color picker matches original color and remembers the user color' +
|
||||
' after a refresh', function (done) {
|
||||
this.timeout(10000);
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -95,7 +96,6 @@ describe('change user color', function () {
|
|||
// simulate a keypress of enter actually does evt.which = 10 not 13
|
||||
$chatInput.sendkeys('{enter}');
|
||||
|
||||
// check if chat shows up
|
||||
// wait until the chat message shows up
|
||||
helper.waitFor(() => chrome$('#chattext').children('p').length !== 0
|
||||
).done(() => {
|
||||
|
|
|
@ -6,8 +6,10 @@ describe('Chat messages and UI', function () {
|
|||
helper.newPad(cb);
|
||||
});
|
||||
|
||||
it('opens chat, sends a message, makes sure it exists and hides chat', async function () {
|
||||
it('opens chat, sends a message, makes sure it exists ' +
|
||||
'on the page and hides chat', async function () {
|
||||
this.timeout(3000);
|
||||
|
||||
const chatValue = 'JohnMcLear';
|
||||
|
||||
await helper.showChat();
|
||||
|
@ -49,7 +51,8 @@ describe('Chat messages and UI', function () {
|
|||
expect(chat.text()).to.be(`${username}${time} ${chatValue}`);
|
||||
});
|
||||
|
||||
it('makes chat stick to right side of the screen via settings, remove sticky via settings, close it', async function () {
|
||||
it('makes chat stick to right side of the screen via settings, ' +
|
||||
'remove sticky via settings, close it', async function () {
|
||||
this.timeout(5000);
|
||||
await helper.showSettings();
|
||||
|
||||
|
@ -66,8 +69,10 @@ describe('Chat messages and UI', function () {
|
|||
expect(helper.isChatboxShown()).to.be(false);
|
||||
});
|
||||
|
||||
it('makes chat stick to right side of the screen via icon on the top right, remove sticky via icon, close it', async function () {
|
||||
it('makes chat stick to right side of the screen via icon on the top' +
|
||||
' right, remove sticky via icon, close it', async function () {
|
||||
this.timeout(5000);
|
||||
|
||||
await helper.showChat();
|
||||
|
||||
await helper.enableStickyChatviaIcon();
|
||||
|
@ -83,7 +88,8 @@ describe('Chat messages and UI', function () {
|
|||
expect(helper.isChatboxShown()).to.be(false);
|
||||
});
|
||||
|
||||
xit('Checks showChat=false URL Parameter shows/hides chat', function (done) {
|
||||
xit('Checks showChat=false URL Parameter hides chat then' +
|
||||
' when removed it shows chat', function (done) {
|
||||
this.timeout(60000);
|
||||
|
||||
setTimeout(() => { // give it a second to save the username on the server side
|
||||
|
|
|
@ -92,7 +92,7 @@ describe('clear authorship colors button', function () {
|
|||
let hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||
expect(hasAuthorClass).to.be(false);
|
||||
|
||||
const e = inner$.Event(helper.evtType);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.ctrlKey = true; // Control key
|
||||
e.which = 90; // z
|
||||
inner$('#innerdocbody').trigger(e); // shouldn't od anything
|
||||
|
|
|
@ -22,8 +22,6 @@ describe('delete keystroke', function () {
|
|||
$firstTextElement.sendkeys('{leftarrow}'); // simulate a keypress of the left arrow key
|
||||
$firstTextElement.sendkeys('{del}'); // simulate a keypress of delete
|
||||
|
||||
// ace creates a new dom element when you press a keystroke
|
||||
// so just get the first text element again
|
||||
const $newFirstTextElement = inner$('div').first();
|
||||
|
||||
// get the new length of this element
|
||||
|
|
|
@ -86,16 +86,16 @@ describe('drag and drop', function () {
|
|||
const TARGET_LINE = 2;
|
||||
const FIRST_SOURCE_LINE = 5;
|
||||
|
||||
const getLine = function (lineNumber) {
|
||||
const getLine = (lineNumber) => {
|
||||
const $lines = helper.padInner$('div');
|
||||
return $lines.slice(lineNumber, lineNumber + 1);
|
||||
};
|
||||
|
||||
const createScriptWithSeveralLines = function (done) {
|
||||
const createScriptWithSeveralLines = (done) => {
|
||||
// create some lines to be used on the tests
|
||||
const $firstLine = helper.padInner$('div').first();
|
||||
$firstLine.html(
|
||||
'...<br>...<br>Target line []<br>...<br>...<br>Source line 1.<br>Source line 2.<br>');
|
||||
$firstLine.html('...<br>...<br>Target line []<br>...<br>...<br>' +
|
||||
'Source line 1.<br>Source line 2.<br>');
|
||||
|
||||
// wait for lines to be split
|
||||
helper.waitFor(() => {
|
||||
|
@ -104,7 +104,7 @@ describe('drag and drop', function () {
|
|||
}).done(done);
|
||||
};
|
||||
|
||||
const selectPartOfSourceLine = function () {
|
||||
const selectPartOfSourceLine = () => {
|
||||
const $sourceLine = getLine(FIRST_SOURCE_LINE);
|
||||
|
||||
// select 'line 1' from 'Source line 1.'
|
||||
|
@ -112,14 +112,14 @@ describe('drag and drop', function () {
|
|||
const end = start + 'line 1'.length;
|
||||
helper.selectLines($sourceLine, $sourceLine, start, end);
|
||||
};
|
||||
const selectMultipleSourceLines = function () {
|
||||
const selectMultipleSourceLines = () => {
|
||||
const $firstSourceLine = getLine(FIRST_SOURCE_LINE);
|
||||
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
||||
|
||||
helper.selectLines($firstSourceLine, $lastSourceLine);
|
||||
};
|
||||
|
||||
const dragSelectedTextAndDropItIntoMiddleOfLine = function (targetLineNumber) {
|
||||
const dragSelectedTextAndDropItIntoMiddleOfLine = (targetLineNumber) => {
|
||||
// dragstart: start dragging content
|
||||
triggerEvent('dragstart');
|
||||
|
||||
|
@ -132,7 +132,7 @@ describe('drag and drop', function () {
|
|||
triggerEvent('dragend');
|
||||
};
|
||||
|
||||
const getHtmlFromSelectedText = function () {
|
||||
const getHtmlFromSelectedText = () => {
|
||||
const innerDocument = helper.padInner$.document;
|
||||
|
||||
const range = innerDocument.getSelection().getRangeAt(0);
|
||||
|
@ -145,12 +145,12 @@ describe('drag and drop', function () {
|
|||
return draggedHtml;
|
||||
};
|
||||
|
||||
const triggerEvent = function (eventName) {
|
||||
const event = helper.padInner$.Event(eventName);
|
||||
const triggerEvent = (eventName) => {
|
||||
const event = new helper.padInner$.Event(eventName);
|
||||
helper.padInner$('#innerdocbody').trigger(event);
|
||||
};
|
||||
|
||||
const moveSelectionIntoTarget = function (draggedHtml, targetLineNumber) {
|
||||
const moveSelectionIntoTarget = (draggedHtml, targetLineNumber) => {
|
||||
const innerDocument = helper.padInner$.document;
|
||||
|
||||
// delete original content
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('the test helper', function () {
|
|||
|
||||
let times = 10;
|
||||
|
||||
const loadPad = function () {
|
||||
const loadPad = () => {
|
||||
helper.newPad(() => {
|
||||
times--;
|
||||
if (times > 0) {
|
||||
|
@ -77,13 +77,14 @@ describe('the test helper', function () {
|
|||
// Before refreshing, make sure the name is there
|
||||
expect($usernameInput.val()).to.be('John McLear');
|
||||
|
||||
// Now that we have a chrome, we can set a pad cookie, so we can confirm it gets wiped as well
|
||||
// Now that we have a chrome, we can set a pad cookie
|
||||
// so we can confirm it gets wiped as well
|
||||
chrome$.document.cookie = 'prefsHtml=baz;expires=Thu, 01 Jan 3030 00:00:00 GMT';
|
||||
expect(chrome$.document.cookie).to.contain('prefsHtml=baz');
|
||||
|
||||
// Cookies are weird. Because it's attached to chrome$ (as helper.setPadCookies does), AND we
|
||||
// didn't put path=/, we shouldn't expect it to be visible on window.document.cookie. Let's just
|
||||
// be sure.
|
||||
// Cookies are weird. Because it's attached to chrome$ (as helper.setPadCookies does)
|
||||
// AND we didn't put path=/, we shouldn't expect it to be visible on
|
||||
// window.document.cookie. Let's just be sure.
|
||||
expect(window.document.cookie).to.not.contain('prefsHtml=baz');
|
||||
|
||||
setTimeout(() => { // give it a second to save the username on the server side
|
||||
|
@ -268,7 +269,8 @@ describe('the test helper', function () {
|
|||
this.timeout(60000);
|
||||
});
|
||||
|
||||
it('changes editor selection to be between startOffset of $startLine and endOffset of $endLine', function (done) {
|
||||
it('changes editor selection to be between startOffset of $startLine ' +
|
||||
'and endOffset of $endLine', function (done) {
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
const startOffset = 2;
|
||||
|
@ -315,7 +317,8 @@ describe('the test helper', function () {
|
|||
* is not consistent between browsers but that's the situation so that's
|
||||
* how I'm covering it in this test.
|
||||
*/
|
||||
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines to test');
|
||||
expect(cleanText(
|
||||
selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines to test');
|
||||
|
||||
done();
|
||||
});
|
||||
|
@ -367,12 +370,14 @@ describe('the test helper', function () {
|
|||
* is not consistent between browsers but that's the situation so that's
|
||||
* how I'm covering it in this test.
|
||||
*/
|
||||
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines to test');
|
||||
expect(cleanText(
|
||||
selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines to test');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('selects all text between beginning of $startLine and end of $endLine when no offset is provided', function (done) {
|
||||
it('selects all text between beginning of $startLine and end of $endLine ' +
|
||||
'when no offset is provided', function (done) {
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
const $lines = inner$('div');
|
||||
|
@ -390,7 +395,8 @@ describe('the test helper', function () {
|
|||
* is not consistent between browsers but that's the situation so that's
|
||||
* how I'm covering it in this test.
|
||||
*/
|
||||
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('short lines to test');
|
||||
expect(cleanText(
|
||||
selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('short lines to test');
|
||||
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
describe('import functionality', function () {
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb); // creates a new pad
|
||||
|
@ -16,7 +18,6 @@ describe('import functionality', function () {
|
|||
return newtext;
|
||||
}
|
||||
function importrequest(data, importurl, type) {
|
||||
let success;
|
||||
let error;
|
||||
const result = $.ajax({
|
||||
url: importurl,
|
||||
|
@ -27,7 +28,17 @@ describe('import functionality', function () {
|
|||
accepts: {
|
||||
text: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
},
|
||||
data: `Content-Type: multipart/form-data; boundary=--boundary\r\n\r\n--boundary\r\nContent-Disposition: form-data; name="file"; filename="import.${type}"\r\nContent-Type: text/plain\r\n\r\n${data}\r\n\r\n--boundary`,
|
||||
data: [
|
||||
'Content-Type: multipart/form-data; boundary=--boundary',
|
||||
'',
|
||||
'--boundary',
|
||||
`Content-Disposition: form-data; name="file"; filename="import.${type}"`,
|
||||
'Content-Type: text/plain',
|
||||
'',
|
||||
data,
|
||||
'',
|
||||
'--boundary',
|
||||
].join('\r\n'),
|
||||
error(res) {
|
||||
error = res;
|
||||
},
|
||||
|
@ -56,7 +67,8 @@ describe('import functionality', function () {
|
|||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const textWithNewLines = 'imported text\nnewline';
|
||||
importrequest(textWithNewLines, importurl, 'txt');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('<span class="">imported text</span>\n<span class="">newline</span>\n<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext())
|
||||
.to.be('<span class="">imported text</span>\n<span class="">newline</span>\n<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
expect(results[0][1]).to.be('imported text<br>newline<br><br>');
|
||||
expect(results[1][1]).to.be('imported text\nnewline\n\n');
|
||||
|
@ -66,7 +78,8 @@ describe('import functionality', function () {
|
|||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithNewLines = '<html><body>htmltext<br/>newline</body></html>';
|
||||
importrequest(htmlWithNewLines, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('<span class="">htmltext</span>\n<span class="">newline</span>\n<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext())
|
||||
.to.be('<span class="">htmltext</span>\n<span class="">newline</span>\n<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
expect(results[0][1]).to.be('htmltext<br>newline<br><br>');
|
||||
expect(results[1][1]).to.be('htmltext\nnewline\n\n');
|
||||
|
@ -74,69 +87,109 @@ describe('import functionality', function () {
|
|||
});
|
||||
xit('import a pad with attributes from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithNewLines = '<html><body>htmltext<br/><span class="b s i u"><b><i><s><u>newline</u></s></i></b></body></html>';
|
||||
const htmlWithNewLines = '<html><body>htmltext<br/><span class="b s i u">' +
|
||||
'<b><i><s><u>newline</u></s></i></b></body></html>';
|
||||
importrequest(htmlWithNewLines, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('<span class="">htmltext</span>\n<span class="b i s u"><b><i><s><u>newline</u></s></i></b></span>\n<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext())
|
||||
.to.be('<span class="">htmltext</span>\n<span class="b i s u">' +
|
||||
'<b><i><s><u>newline</u></s></i></b></span>\n<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
expect(results[0][1]).to.be('htmltext<br><strong><em><s><u>newline</u></s></em></strong><br><br>');
|
||||
expect(results[0][1])
|
||||
.to.be('htmltext<br><strong><em><s><u>newline</u></s></em></strong><br><br>');
|
||||
expect(results[1][1]).to.be('htmltext\nnewline\n\n');
|
||||
done();
|
||||
});
|
||||
xit('import a pad with bullets from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li><li>bullet2 line 2</li></ul></ul></body></html>';
|
||||
const htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li>' +
|
||||
'<li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li>' +
|
||||
'<li>bullet2 line 2</li></ul></ul></body></html>';
|
||||
importrequest(htmlWithBullets, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('\
|
||||
<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\
|
||||
<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\
|
||||
<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n\
|
||||
<ul class="list-bullet2"><li><span class="">bullet2 line 2</span></li></ul>\n\
|
||||
<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
'<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n' +
|
||||
'<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n' +
|
||||
'<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n' +
|
||||
'<ul class="list-bullet2"><li><span class="">bullet2 line 2</span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li><li>bullet2 line 2</li></ul></ul><br>');
|
||||
expect(results[1][1]).to.be('\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t* bullet2 line 2\n\n');
|
||||
expect(results[0][1]).to.be(
|
||||
'<ul class="bullet"><li>bullet line 1</li><li>bullet line 2</li>' +
|
||||
'<ul class="bullet"><li>bullet2 line 1</li><li>bullet2 line 2</li></ul></ul><br>');
|
||||
expect(results[1][1])
|
||||
.to.be('\t* bullet line 1\n\t* bullet line 2\n' +
|
||||
'\t\t* bullet2 line 1\n\t\t* bullet2 line 2\n\n');
|
||||
done();
|
||||
});
|
||||
xit('import a pad with bullets and newlines from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li></ul><br/><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li></ul></ul><br/><ul class="list-bullet1"><ul class="list-bullet2"><li>bullet2 line 2</li></ul></ul></body></html>';
|
||||
const htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li>' +
|
||||
'</ul><br/><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2">' +
|
||||
'<li>bullet2 line 1</li></ul></ul><br/><ul class="list-bullet1">' +
|
||||
'<ul class="list-bullet2"><li>bullet2 line 2</li></ul></ul></body></html>';
|
||||
importrequest(htmlWithBullets, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('\
|
||||
<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\
|
||||
<br>\n\
|
||||
<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\
|
||||
<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n\
|
||||
<br>\n\
|
||||
<ul class="list-bullet2"><li><span class="">bullet2 line 2</span></li></ul>\n\
|
||||
<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
'<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n' +
|
||||
'<br>\n' +
|
||||
'<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n' +
|
||||
'<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n' +
|
||||
'<br>\n' +
|
||||
'<ul class="list-bullet2"><li><span class="">bullet2 line 2</span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li></ul><br><ul class="bullet"><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li></ul></ul><br><ul><ul class="bullet"><li>bullet2 line 2</li></ul></ul><br>');
|
||||
expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t* bullet2 line 2\n\n');
|
||||
expect(results[0][1]).to.be(
|
||||
'<ul class="bullet"><li>bullet line 1</li></ul><br><ul class="bullet">' +
|
||||
'<li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li></ul>' +
|
||||
'</ul><br><ul><ul class="bullet"><li>bullet2 line 2</li></ul></ul><br>');
|
||||
expect(results[1][1]).to.be(
|
||||
'\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t* bullet2 line 2\n\n');
|
||||
done();
|
||||
});
|
||||
xit('import a pad with bullets and newlines and attributes from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li></ul><br/><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li></ul></ul><br/><ul class="list-bullet1"><ul class="list-bullet2"><ul class="list-bullet3"><ul class="list-bullet4"><li><span class="b s i u"><b><i><s><u>bullet4 line 2 bisu</u></s></i></b></span></li><li><span class="b s "><b><s>bullet4 line 2 bs</s></b></span></li><li><span class="u"><u>bullet4 line 2 u</u></span><span class="u i s"><i><s><u>uis</u></s></i></span></li></ul></ul></ul></ul></body></html>';
|
||||
const htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li>' +
|
||||
'</ul><br/><ul class="list-bullet1"><li>bullet line 2</li>' +
|
||||
'<ul class="list-bullet2"><li>bullet2 line 1</li></ul></ul>' +
|
||||
'<br/><ul class="list-bullet1"><ul class="list-bullet2"><ul class="list-bullet3">' +
|
||||
'<ul class="list-bullet4"><li><span class="b s i u"><b><i>' +
|
||||
'<s><u>bullet4 line 2 bisu</u></s></i></b></span></li><li>' +
|
||||
'<span class="b s "><b><s>bullet4 line 2 bs</s></b></span></li>' +
|
||||
'<li><span class="u"><u>bullet4 line 2 u</u></span><span class="u i s">' +
|
||||
'<i><s><u>uis</u></s></i></span></li></ul></ul></ul></ul></body></html>';
|
||||
importrequest(htmlWithBullets, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('\
|
||||
<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\<br>\n\
|
||||
<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\
|
||||
<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n<br>\n\
|
||||
<ul class="list-bullet4"><li><span class="b i s u"><b><i><s><u>bullet4 line 2 bisu</u></s></i></b></span></li></ul>\n\
|
||||
<ul class="list-bullet4"><li><span class="b s"><b><s>bullet4 line 2 bs</s></b></span></li></ul>\n\
|
||||
<ul class="list-bullet4"><li><span class="u"><u>bullet4 line 2 u</u></span><span class="i s u"><i><s><u>uis</u></s></i></span></li></ul>\n\
|
||||
<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
'<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n<br>\n' +
|
||||
'<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n' +
|
||||
'<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n<br>\n' +
|
||||
'<ul class="list-bullet4"><li><span class="b i s u">' +
|
||||
'<b><i><s><u>bullet4 line 2 bisu</u></s></i></b></span></li></ul>\n' +
|
||||
'<ul class="list-bullet4"><li><span class="b s">' +
|
||||
'<b><s>bullet4 line 2 bs</s></b></span></li></ul>\n' +
|
||||
'<ul class="list-bullet4"><li><span class="u"><u>bullet4 line 2 u</u>' +
|
||||
'</span><span class="i s u"><i><s><u>uis</u></s></i></span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li></ul><br><ul class="bullet"><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li></ul></ul><br><ul><ul><ul><ul class="bullet"><li><strong><em><s><u>bullet4 line 2 bisu</u></s></em></strong></li><li><strong><s>bullet4 line 2 bs</s></strong></li><li><u>bullet4 line 2 u<em><s>uis</s></em></u></li></ul></ul></ul></ul><br>');
|
||||
expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t\t\t* bullet4 line 2 bisu\n\t\t\t\t* bullet4 line 2 bs\n\t\t\t\t* bullet4 line 2 uuis\n\n');
|
||||
expect(results[0][1]).to.be(
|
||||
'<ul class="bullet"><li>bullet line 1</li></ul>' +
|
||||
'<br><ul class="bullet"><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li>' +
|
||||
'</ul></ul><br><ul><ul><ul><ul class="bullet"><li><strong><em><s><u>bullet4 line 2 bisu' +
|
||||
'</u></s></em></strong></li><li><strong><s>bullet4 line 2 bs</s></strong>' +
|
||||
'</li><li><u>bullet4 line 2 u<em><s>uis</s></em></u></li></ul></ul></ul></ul><br>');
|
||||
expect(results[1][1]).to.be(
|
||||
'\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t\t\t* bullet4 line 2' +
|
||||
' bisu\n\t\t\t\t* bullet4 line 2 bs\n\t\t\t\t* bullet4 line 2 uuis\n\n');
|
||||
done();
|
||||
});
|
||||
xit('import a pad with nested bullets from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li></ul><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li></ul></ul><ul class="list-bullet1"><ul class="list-bullet2"><ul class="list-bullet3"><ul class="list-bullet4"><li>bullet4 line 2</li><li>bullet4 line 2</li><li>bullet4 line 2</li></ul><li>bullet3 line 1</li></ul></ul><li>bullet2 line 1</li></ul></body></html>';
|
||||
const htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li>' +
|
||||
'</ul><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2">' +
|
||||
'<li>bullet2 line 1</li></ul></ul><ul class="list-bullet1"><ul class="list-bullet2">' +
|
||||
'<ul class="list-bullet3"><ul class="list-bullet4"><li>bullet4 line 2</li>' +
|
||||
'<li>bullet4 line 2</li><li>bullet4 line 2</li></ul><li>bullet3 line 1</li></ul>' +
|
||||
'</ul><li>bullet2 line 1</li></ul></body></html>';
|
||||
importrequest(htmlWithBullets, importurl, 'html');
|
||||
const oldtext = getinnertext();
|
||||
helper.waitFor(() => oldtext != getinnertext()
|
||||
helper.waitFor(() => oldtext !== getinnertext()
|
||||
// return expect(getinnertext()).to.be('\
|
||||
// <ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\
|
||||
// <ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\
|
||||
|
@ -148,73 +201,127 @@ describe('import functionality', function () {
|
|||
);
|
||||
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li><ul><ul class="bullet"><li>bullet4 line 2</li><li>bullet4 line 2</li><li>bullet4 line 2</li></ul><li>bullet3 line 1</li></ul></ul><li>bullet2 line 1</li></ul><br>');
|
||||
expect(results[1][1]).to.be('\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t* bullet3 line 1\n\t* bullet2 line 1\n\n');
|
||||
expect(results[0][1]).to.be(
|
||||
'<ul class="bullet"><li>bullet line 1</li><li>bullet line 2</li>' +
|
||||
'<ul class="bullet"><li>bullet2 line 1</li><ul><ul class="bullet"><li>bullet4 line 2</li>' +
|
||||
'<li>bullet4 line 2</li><li>bullet4 line 2</li></ul><li>bullet3 line 1</li></ul></ul>' +
|
||||
'<li>bullet2 line 1</li></ul><br>');
|
||||
expect(results[1][1]).to.be(
|
||||
'\t* bullet line 1\n\t* bullet line 2\n\t\t* bullet2 line 1\n\t\t\t\t* bullet4 line 2' +
|
||||
'\n\t\t\t\t* bullet4 line 2\n\t\t\t\t* bullet4 line 2\n\t\t\t* bullet3 line 1' +
|
||||
'\n\t* bullet2 line 1\n\n');
|
||||
done();
|
||||
});
|
||||
xit('import a pad with 8 levels of bullets and newlines and attributes from html', function (done) {
|
||||
xit('import with 8 levels of bullets and newlines and attributes from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithBullets = '<html><body><ul class="list-bullet1"><li>bullet line 1</li></ul><br/><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2"><li>bullet2 line 1</li></ul></ul><br/><ul class="list-bullet1"><ul class="list-bullet2"><ul class="list-bullet3"><ul class="list-bullet4"><li><span class="b s i u"><b><i><s><u>bullet4 line 2 bisu</u></s></i></b></span></li><li><span class="b s "><b><s>bullet4 line 2 bs</s></b></span></li><li><span class="u"><u>bullet4 line 2 u</u></span><span class="u i s"><i><s><u>uis</u></s></i></span></li><ul class="list-bullet5"><ul class="list-bullet6"><ul class="list-bullet7"><ul class="list-bullet8"><li><span class="">foo</span></li><li><span class="b s"><b><s>foobar bs</b></s></span></li></ul></ul></ul></ul><ul class="list-bullet5"><li>foobar</li></ul></ul></ul></ul></body></html>';
|
||||
const htmlWithBullets =
|
||||
'<html><body><ul class="list-bullet1"><li>bullet line 1</li>' +
|
||||
'</ul><br/><ul class="list-bullet1"><li>bullet line 2</li><ul class="list-bullet2"><li>' +
|
||||
'bullet2 line 1</li></ul></ul><br/><ul class="list-bullet1"><ul class="list-bullet2">' +
|
||||
'<ul class="list-bullet3"><ul class="list-bullet4"><li><span class="b s i u"><b><i>' +
|
||||
'<s><u>bullet4 line 2 bisu</u></s></i></b></span></li><li><span class="b s "><b><s>' +
|
||||
'bullet4 line 2 bs</s></b></span></li><li><span class="u"><u>bullet4 line 2 u' +
|
||||
'</u></span><span class="u i s"><i><s><u>uis</u></s></i></span></li>' +
|
||||
'<ul class="list-bullet5"><ul class="list-bullet6"><ul class="list-bullet7">' +
|
||||
'<ul class="list-bullet8"><li><span class="">foo</span></li><li><span class="b s">' +
|
||||
'<b><s>foobar bs</b></s></span></li></ul></ul></ul></ul><ul class="list-bullet5">' +
|
||||
'<li>foobar</li></ul></ul></ul></ul></body></html>';
|
||||
importrequest(htmlWithBullets, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('\
|
||||
<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n\<br>\n\
|
||||
<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n\
|
||||
<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n<br>\n\
|
||||
<ul class="list-bullet4"><li><span class="b i s u"><b><i><s><u>bullet4 line 2 bisu</u></s></i></b></span></li></ul>\n\
|
||||
<ul class="list-bullet4"><li><span class="b s"><b><s>bullet4 line 2 bs</s></b></span></li></ul>\n\
|
||||
<ul class="list-bullet4"><li><span class="u"><u>bullet4 line 2 u</u></span><span class="i s u"><i><s><u>uis</u></s></i></span></li></ul>\n\
|
||||
<ul class="list-bullet8"><li><span class="">foo</span></li></ul>\n\
|
||||
<ul class="list-bullet8"><li><span class="b s"><b><s>foobar bs</s></b></span></li></ul>\n\
|
||||
<ul class="list-bullet5"><li><span class="">foobar</span></li></ul>\n\
|
||||
<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
'<ul class="list-bullet1"><li><span class="">bullet line 1</span></li></ul>\n<br>\n' +
|
||||
'<ul class="list-bullet1"><li><span class="">bullet line 2</span></li></ul>\n' +
|
||||
'<ul class="list-bullet2"><li><span class="">bullet2 line 1</span></li></ul>\n<br>\n' +
|
||||
'<ul class="list-bullet4"><li><span class="b i s u"><b><i><s><u>bullet4 line 2 bisu</u>' +
|
||||
'</s></i></b></span></li></ul>\n' +
|
||||
'<ul class="list-bullet4"><li><span class="b s"><b><s>bullet4 line 2 bs</s></b>' +
|
||||
'</span></li></ul>\n' +
|
||||
'<ul class="list-bullet4"><li><span class="u"><u>bullet4 line 2 u</u></span>' +
|
||||
'<span class="i s u"><i><s><u>uis</u></s>' +
|
||||
'</i></span></li></ul>\n' +
|
||||
'<ul class="list-bullet8"><li><span class="">foo</span></li></ul>\n' +
|
||||
'<ul class="list-bullet8"><li><span class="b s"><b><s>foobar bs</s></b>' +
|
||||
'</span></li></ul>\n' +
|
||||
'<ul class="list-bullet5"><li><span class="">foobar</span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
expect(results[0][1]).to.be('<ul class="bullet"><li>bullet line 1</li></ul><br><ul class="bullet"><li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li></ul></ul><br><ul><ul><ul><ul class="bullet"><li><strong><em><s><u>bullet4 line 2 bisu</u></s></em></strong></li><li><strong><s>bullet4 line 2 bs</s></strong></li><li><u>bullet4 line 2 u<em><s>uis</s></em></u></li><ul><ul><ul><ul class="bullet"><li>foo</li><li><strong><s>foobar bs</s></strong></li></ul></ul></ul><li>foobar</li></ul></ul></ul></ul></ul><br>');
|
||||
expect(results[1][1]).to.be('\t* bullet line 1\n\n\t* bullet line 2\n\t\t* bullet2 line 1\n\n\t\t\t\t* bullet4 line 2 bisu\n\t\t\t\t* bullet4 line 2 bs\n\t\t\t\t* bullet4 line 2 uuis\n\t\t\t\t\t\t\t\t* foo\n\t\t\t\t\t\t\t\t* foobar bs\n\t\t\t\t\t* foobar\n\n');
|
||||
expect(results[0][1]).to.be(
|
||||
'<ul class="bullet"><li>bullet line 1</li></ul><br><ul class="bullet">' +
|
||||
'<li>bullet line 2</li><ul class="bullet"><li>bullet2 line 1</li></ul></ul>' +
|
||||
'<br><ul><ul><ul><ul class="bullet"><li><strong><em><s><u>' +
|
||||
'bullet4 line 2 bisu</u></s></em></strong></li><li><strong><s>' +
|
||||
'bullet4 line 2 bs</s></strong></li><li><u>bullet4 line 2 u<em>' +
|
||||
'<s>uis</s></em></u></li><ul><ul><ul><ul class="bullet"><li>foo</li>' +
|
||||
'<li><strong><s>foobar bs</s></strong></li></ul></ul></ul><li>foobar</li>' +
|
||||
'</ul></ul></ul></ul></ul><br>');
|
||||
expect(results[1][1]).to.be(
|
||||
'\t* bullet line 1\n\n\t* bullet line 2\n\t\t* ' +
|
||||
'bullet2 line 1\n\n\t\t\t\t* bullet4 line 2 bisu\n\t\t\t\t* bullet4 line 2 ' +
|
||||
'bs\n\t\t\t\t* bullet4 line 2 uuis\n\t\t\t\t\t\t\t\t* foo\n\t\t\t\t\t\t\t\t* ' +
|
||||
'foobar bs\n\t\t\t\t\t* foobar\n\n');
|
||||
done();
|
||||
});
|
||||
|
||||
xit('import a pad with ordered lists from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithBullets = '<html><body><ol class="list-number1" start="1"><li>number 1 line 1</li></ol><ol class="list-number1" start="2"><li>number 2 line 2</li></ol></body></html>';
|
||||
const htmlWithBullets = '<html><body><ol class="list-number1" start="1">' +
|
||||
'<li>number 1 line 1</li></ol><ol class="list-number1" start="2">' +
|
||||
'<li>number 2 line 2</li></ol></body></html>';
|
||||
importrequest(htmlWithBullets, importurl, 'html');
|
||||
console.error(getinnertext());
|
||||
expect(getinnertext()).to.be('\
|
||||
<ol class="list-number1" start="1"><li><span class="">number 1 line 1</span></li></ol>\n\
|
||||
<ol class="list-number1" start="2"><li><span class="">number 2 line 2</span></li></ol>\n\
|
||||
<br>\n');
|
||||
expect(getinnertext()).to.be(
|
||||
'<ol class="list-number1" start="1"><li><span class="">number 1 line 1</span></li></ol>\n' +
|
||||
'<ol class="list-number1" start="2"><li><span class="">number 2 line 2</span></li></ol>\n' +
|
||||
'<br>\n');
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
expect(results[0][1]).to.be('<ol class="list-number1" start="1"><li>number 1 line 1</li></ol><ol class="list-number1" start="2"><li>number 2 line 2</li></ol>');
|
||||
expect(results[0][1]).to.be(
|
||||
'<ol class="list-number1" start="1"><li>number 1 line 1</li>' +
|
||||
'</ol><ol class="list-number1" start="2"><li>number 2 line 2</li></ol>');
|
||||
expect(results[1][1]).to.be('');
|
||||
done();
|
||||
});
|
||||
xit('import a pad with ordered lists and newlines from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithBullets = '<html><body><ol class="list-number1" start="1"><li>number 9 line 1</li></ol><br/><ol class="list-number1" start="2"><li>number 10 line 2</li><ol class="list-number2"><li>number 2 times line 1</li></ol></ol><br/><ol class="list-bullet1"><ol class="list-number2"><li>number 2 times line 2</li></ol></ol></body></html>';
|
||||
const htmlWithBullets = '<html><body><ol class="list-number1" start="1">' +
|
||||
'<li>number 9 line 1</li></ol><br/><ol class="list-number1" start="2">' +
|
||||
'<li>number 10 line 2</li><ol class="list-number2">' +
|
||||
'<li>number 2 times line 1</li></ol></ol><br/><ol class="list-bullet1">' +
|
||||
'<ol class="list-number2"><li>number 2 times line 2</li></ol></ol></body></html>';
|
||||
importrequest(htmlWithBullets, importurl, 'html');
|
||||
expect(getinnertext()).to.be('\
|
||||
<ol class="list-number1" start="1"><li><span class="">number 9 line 1</span></li></ol>\n\
|
||||
<br>\n\
|
||||
<ol class="list-number1" start="2"><li><span class="">number 10 line 2</span></li></ol>\n\
|
||||
<ol class="list-number2"><li><span class="">number 2 times line 1</span></li></ol>\n\
|
||||
<br>\n\
|
||||
<ol class="list-number2"><li><span class="">number 2 times line 2</span></li></ol>\n\
|
||||
<br>\n');
|
||||
expect(getinnertext()).to.be(
|
||||
'<ol class="list-number1" start="1"><li><span class="">number 9 line 1</span></li></ol>\n' +
|
||||
'<br>\n' +
|
||||
'<ol class="list-number1" start="2"><li><span class="">number 10 line 2</span></li>' +
|
||||
'</ol>\n' +
|
||||
'<ol class="list-number2"><li><span class="">number 2 times line 1</span></li></ol>\n' +
|
||||
'<br>\n' +
|
||||
'<ol class="list-number2"><li><span class="">number 2 times line 2</span></li></ol>\n' +
|
||||
'<br>\n');
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
console.error(results);
|
||||
done();
|
||||
});
|
||||
xit('import a pad with nested ordered lists and attributes and newlines from html', function (done) {
|
||||
xit('import with nested ordered lists and attributes and newlines from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
const htmlWithBullets = '<html><body><ol class="list-number1" start="1"><li><span class="b s i u"><b><i><s><u>bold strikethrough italics underline</u></s><i/></b></span> line <span class="b"><b>1bold</b></span></li></ol><br/><span class="i"><i><ol class="list-number1" start="2"><li>number 10 line 2</li><ol class="list-number2"><li>number 2 times line 1</li></ol></ol></i></span><br/><ol class="list-bullet1"><ol class="list-number2"><li>number 2 times line 2</li></ol></ol></body></html>';
|
||||
const htmlWithBullets = '<html><body><ol class="list-number1" start="1"><li>' +
|
||||
'<span class="b s i u"><b><i><s><u>bold strikethrough italics underline</u>' +
|
||||
'</s><i/></b></span> line <span class="b"><b>1bold</b></span></li>' +
|
||||
'</ol><br/><span class="i"><i><ol class="list-number1" start="2">' +
|
||||
'<li>number 10 line 2</li><ol class="list-number2">' +
|
||||
'<li>number 2 times line 1</li></ol></ol></i></span><br/>' +
|
||||
'<ol class="list-bullet1"><ol class="list-number2">' +
|
||||
'<li>number 2 times line 2</li></ol></ol></body></html>';
|
||||
importrequest(htmlWithBullets, importurl, 'html');
|
||||
expect(getinnertext()).to.be('\
|
||||
<ol class="list-number1"><li><span class="b i s u"><b><i><s><u>bold strikethrough italics underline</u></s></i></b></span><span class=""> line </span><span class="b"><b>1bold</b></span></li></ol>\n\
|
||||
<br>\n\
|
||||
<ol class="list-number1"><li><span class="i"><i>number 10 line 2</i></span></li></ol>\n\
|
||||
<ol class="list-number2"><li><span class="i"><i>number 2 times line 1</i></span></li></ol>\n\
|
||||
<br>\n\
|
||||
<ol class="list-number2"><li><span class="">number 2 times line 2</span></li></ol>\n\
|
||||
<br>\n');
|
||||
expect(getinnertext()).to.be(
|
||||
'<ol class="list-number1"><li><span class="b i s u"><b><i><s><u>' +
|
||||
'bold strikethrough italics underline</u></s></i></b></span><span class="">' +
|
||||
' line </span><span class="b"><b>1bold</b></span></li></ol>\n' +
|
||||
'<br>\n' +
|
||||
'<ol class="list-number1"><li><span class="i"><i>number 10 line 2</i></span></li></ol>\n' +
|
||||
'<ol class="list-number2"><li><span class="i">' +
|
||||
'<i>number 2 times line 1</i></span></li></ol>\n' +
|
||||
'<br>\n' +
|
||||
'<ol class="list-number2"><li><span class="">number 2 times line 2</span></li></ol>\n' +
|
||||
'<br>\n');
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
console.error(results);
|
||||
done();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
describe('import indents functionality', function () {
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb); // creates a new pad
|
||||
|
@ -13,7 +15,6 @@ describe('import indents functionality', function () {
|
|||
return newtext;
|
||||
}
|
||||
function importrequest(data, importurl, type) {
|
||||
let success;
|
||||
let error;
|
||||
const result = $.ajax({
|
||||
url: importurl,
|
||||
|
@ -24,7 +25,17 @@ describe('import indents functionality', function () {
|
|||
accepts: {
|
||||
text: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
},
|
||||
data: `Content-Type: multipart/form-data; boundary=--boundary\r\n\r\n--boundary\r\nContent-Disposition: form-data; name="file"; filename="import.${type}"\r\nContent-Type: text/plain\r\n\r\n${data}\r\n\r\n--boundary`,
|
||||
data: [
|
||||
'Content-Type: multipart/form-data; boundary=--boundary',
|
||||
'',
|
||||
'--boundary',
|
||||
`Content-Disposition: form-data; name="file"; filename="import.${type}"`,
|
||||
'Content-Type: text/plain',
|
||||
'',
|
||||
data,
|
||||
'',
|
||||
'--boundary',
|
||||
].join('\r\n'),
|
||||
error(res) {
|
||||
error = res;
|
||||
},
|
||||
|
@ -51,54 +62,67 @@ describe('import indents functionality', function () {
|
|||
|
||||
xit('import a pad with indents from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
/* eslint-disable-next-line max-len */
|
||||
const htmlWithIndents = '<html><body><ul class="list-indent1"><li>indent line 1</li><li>indent line 2</li><ul class="list-indent2"><li>indent2 line 1</li><li>indent2 line 2</li></ul></ul></body></html>';
|
||||
importrequest(htmlWithIndents, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('\
|
||||
<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n\
|
||||
<ul class="list-indent1"><li><span class="">indent line 2</span></li></ul>\n\
|
||||
<ul class="list-indent2"><li><span class="">indent2 line 1</span></li></ul>\n\
|
||||
<ul class="list-indent2"><li><span class="">indent2 line 2</span></li></ul>\n\
|
||||
<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
'<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n' +
|
||||
'<ul class="list-indent1"><li><span class="">indent line 2</span></li></ul>\n' +
|
||||
'<ul class="list-indent2"><li><span class="">indent2 line 1</span></li></ul>\n' +
|
||||
'<ul class="list-indent2"><li><span class="">indent2 line 2</span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[0][1]).to.be('<ul class="indent"><li>indent line 1</li><li>indent line 2</li><ul class="indent"><li>indent2 line 1</li><li>indent2 line 2</li></ul></ul><br>');
|
||||
expect(results[1][1]).to.be('\tindent line 1\n\tindent line 2\n\t\tindent2 line 1\n\t\tindent2 line 2\n\n');
|
||||
expect(results[1][1])
|
||||
.to.be('\tindent line 1\n\tindent line 2\n\t\tindent2 line 1\n\t\tindent2 line 2\n\n');
|
||||
done();
|
||||
});
|
||||
|
||||
xit('import a pad with indented lists and newlines from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
/* eslint-disable-next-line max-len */
|
||||
const htmlWithIndents = '<html><body><ul class="list-indent1"><li>indent line 1</li></ul><br/><ul class="list-indent1"><li>indent 1 line 2</li><ul class="list-indent2"><li>indent 2 times line 1</li></ul></ul><br/><ul class="list-indent1"><ul class="list-indent2"><li>indent 2 times line 2</li></ul></ul></body></html>';
|
||||
importrequest(htmlWithIndents, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('\
|
||||
<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n\
|
||||
<br>\n\
|
||||
<ul class="list-indent1"><li><span class="">indent 1 line 2</span></li></ul>\n\
|
||||
<ul class="list-indent2"><li><span class="">indent 2 times line 1</span></li></ul>\n\
|
||||
<br>\n\
|
||||
<ul class="list-indent2"><li><span class="">indent 2 times line 2</span></li></ul>\n\
|
||||
<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
'<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n' +
|
||||
'<br>\n' +
|
||||
'<ul class="list-indent1"><li><span class="">indent 1 line 2</span></li></ul>\n' +
|
||||
'<ul class="list-indent2"><li><span class="">indent 2 times line 1</span></li></ul>\n' +
|
||||
'<br>\n' +
|
||||
'<ul class="list-indent2"><li><span class="">indent 2 times line 2</span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[0][1]).to.be('<ul class="indent"><li>indent line 1</li></ul><br><ul class="indent"><li>indent 1 line 2</li><ul class="indent"><li>indent 2 times line 1</li></ul></ul><br><ul><ul class="indent"><li>indent 2 times line 2</li></ul></ul><br>');
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[1][1]).to.be('\tindent line 1\n\n\tindent 1 line 2\n\t\tindent 2 times line 1\n\n\t\tindent 2 times line 2\n\n');
|
||||
done();
|
||||
});
|
||||
xit('import a pad with 8 levels of indents and newlines and attributes from html', function (done) {
|
||||
xit('import with 8 levels of indents and newlines and attributes from html', function (done) {
|
||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||
/* eslint-disable-next-line max-len */
|
||||
const htmlWithIndents = '<html><body><ul class="list-indent1"><li>indent line 1</li></ul><br/><ul class="list-indent1"><li>indent line 2</li><ul class="list-indent2"><li>indent2 line 1</li></ul></ul><br/><ul class="list-indent1"><ul class="list-indent2"><ul class="list-indent3"><ul class="list-indent4"><li><span class="b s i u"><b><i><s><u>indent4 line 2 bisu</u></s></i></b></span></li><li><span class="b s "><b><s>indent4 line 2 bs</s></b></span></li><li><span class="u"><u>indent4 line 2 u</u></span><span class="u i s"><i><s><u>uis</u></s></i></span></li><ul class="list-indent5"><ul class="list-indent6"><ul class="list-indent7"><ul class="list-indent8"><li><span class="">foo</span></li><li><span class="b s"><b><s>foobar bs</b></s></span></li></ul></ul></ul></ul><ul class="list-indent5"><li>foobar</li></ul></ul></ul></ul></body></html>';
|
||||
importrequest(htmlWithIndents, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be('\
|
||||
<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n\<br>\n\
|
||||
<ul class="list-indent1"><li><span class="">indent line 2</span></li></ul>\n\
|
||||
<ul class="list-indent2"><li><span class="">indent2 line 1</span></li></ul>\n<br>\n\
|
||||
<ul class="list-indent4"><li><span class="b i s u"><b><i><s><u>indent4 line 2 bisu</u></s></i></b></span></li></ul>\n\
|
||||
<ul class="list-indent4"><li><span class="b s"><b><s>indent4 line 2 bs</s></b></span></li></ul>\n\
|
||||
<ul class="list-indent4"><li><span class="u"><u>indent4 line 2 u</u></span><span class="i s u"><i><s><u>uis</u></s></i></span></li></ul>\n\
|
||||
<ul class="list-indent8"><li><span class="">foo</span></li></ul>\n\
|
||||
<ul class="list-indent8"><li><span class="b s"><b><s>foobar bs</s></b></span></li></ul>\n\
|
||||
<ul class="list-indent5"><li><span class="">foobar</span></li></ul>\n\
|
||||
<br>\n'));
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
'<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n<br>\n' +
|
||||
'<ul class="list-indent1"><li><span class="">indent line 2</span></li></ul>\n' +
|
||||
'<ul class="list-indent2"><li><span class="">indent2 line 1</span></li></ul>\n<br>\n' +
|
||||
'<ul class="list-indent4"><li><span class="b i s u"><b><i><s><u>indent4 ' +
|
||||
'line 2 bisu</u></s></i></b></span></li></ul>\n' +
|
||||
'<ul class="list-indent4"><li><span class="b s"><b><s>' +
|
||||
'indent4 line 2 bs</s></b></span></li></ul>\n' +
|
||||
'<ul class="list-indent4"><li><span class="u"><u>indent4 line 2 u</u>' +
|
||||
'</span><span class="i s u"><i><s><u>uis</u></s></i></span></li></ul>\n' +
|
||||
'<ul class="list-indent8"><li><span class="">foo</span></li></ul>\n' +
|
||||
'<ul class="list-indent8"><li><span class="b s"><b><s>foobar bs</s></b>' +
|
||||
'</span></li></ul>\n' +
|
||||
'<ul class="list-indent5"><li><span class="">foobar</span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[0][1]).to.be('<ul class="indent"><li>indent line 1</li></ul><br><ul class="indent"><li>indent line 2</li><ul class="indent"><li>indent2 line 1</li></ul></ul><br><ul><ul><ul><ul class="indent"><li><strong><em><s><u>indent4 line 2 bisu</u></s></em></strong></li><li><strong><s>indent4 line 2 bs</s></strong></li><li><u>indent4 line 2 u<em><s>uis</s></em></u></li><ul><ul><ul><ul class="indent"><li>foo</li><li><strong><s>foobar bs</s></strong></li></ul></ul></ul><li>foobar</li></ul></ul></ul></ul></ul><br>');
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[1][1]).to.be('\tindent line 1\n\n\tindent line 2\n\t\tindent2 line 1\n\n\t\t\t\tindent4 line 2 bisu\n\t\t\t\tindent4 line 2 bs\n\t\t\t\tindent4 line 2 uuis\n\t\t\t\t\t\t\t\tfoo\n\t\t\t\t\t\t\t\tfoobar bs\n\t\t\t\t\tfoobar\n\n');
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('indentation button', function () {
|
|||
// select this text element
|
||||
$firstTextElement.sendkeys('{selectall}');
|
||||
|
||||
const e = inner$.Event(helper.evtType);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.keyCode = 9; // tab :|
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
|
||||
|
@ -60,7 +60,8 @@ describe('indentation button', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it("indents text with spaces on enter if previous line ends with ':', '[', '(', or '{'", function (done) {
|
||||
it('indents text with spaces on enter if previous line ends ' +
|
||||
"with ':', '[', '(', or '{'", function (done) {
|
||||
this.timeout(1200);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -111,7 +112,8 @@ describe('indentation button', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it("appends indentation to the indent of previous line if previous line ends with ':', '[', '(', or '{'", function (done) {
|
||||
it('appends indentation to the indent of previous line if previous line ends ' +
|
||||
"with ':', '[', '(', or '{'", function (done) {
|
||||
this.timeout(1200);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -136,7 +138,8 @@ describe('indentation button', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it("issue #2772 shows '*' when multiple indented lines receive a style and are outdented", async function () {
|
||||
it("issue #2772 shows '*' when multiple indented lines " +
|
||||
' receive a style and are outdented', async function () {
|
||||
this.timeout(1200);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -189,7 +192,6 @@ describe('indentation button', function () {
|
|||
var $indentButton = testHelper.$getPadChrome().find(".buttonicon-indent");
|
||||
$indentButton.click();
|
||||
|
||||
//ace creates a new dom element when you press a button, so just get the first text element again
|
||||
var newFirstTextElement = $inner.find("div").first();
|
||||
|
||||
// is there a list-indent class element now?
|
||||
|
@ -227,7 +229,6 @@ describe('indentation button', function () {
|
|||
$outdentButton.click();
|
||||
$outdentButton.click();
|
||||
|
||||
//ace creates a new dom element when you press a button, so just get the first text element again
|
||||
var newFirstTextElement = $inner.find("div").first();
|
||||
|
||||
// is there a list-indent class element now?
|
||||
|
@ -274,7 +275,9 @@ describe('indentation button', function () {
|
|||
|
||||
//get the second text element out of the inner iframe
|
||||
setTimeout(function(){ // THIS IS REALLY BAD
|
||||
var secondTextElement = $('iframe').contents().find('iframe').contents().find('iframe').contents().find('body > div').get(1); // THIS IS UGLY
|
||||
var secondTextElement = $('iframe').contents()
|
||||
.find('iframe').contents()
|
||||
.find('iframe').contents().find('body > div').get(1); // THIS IS UGLY
|
||||
|
||||
// is there a list-indent class element now?
|
||||
var firstChild = secondTextElement.children(":first");
|
||||
|
@ -289,7 +292,10 @@ describe('indentation button', function () {
|
|||
expect(isLI).to.be(true);
|
||||
|
||||
//get the first text element out of the inner iframe
|
||||
var thirdTextElement = $('iframe').contents().find('iframe').contents().find('iframe').contents().find('body > div').get(2); // THIS IS UGLY TOO
|
||||
var thirdTextElement = $('iframe').contents()
|
||||
.find('iframe').contents()
|
||||
.find('iframe').contents()
|
||||
.find('body > div').get(2); // THIS IS UGLY TOO
|
||||
|
||||
// is there a list-indent class element now?
|
||||
var firstChild = thirdTextElement.children(":first");
|
||||
|
@ -309,7 +315,7 @@ describe('indentation button', function () {
|
|||
|
||||
const pressEnter = () => {
|
||||
const inner$ = helper.padInner$;
|
||||
const e = inner$.Event(helper.evtType);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.keyCode = 13; // enter :|
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('italic some text', function () {
|
|||
// get the bold button and click it
|
||||
const $boldButton = chrome$('.buttonicon-italic');
|
||||
$boldButton.click();
|
||||
|
||||
|
||||
const $newFirstTextElement = inner$('div').first();
|
||||
|
||||
// is there a <i> element now?
|
||||
|
@ -46,7 +46,7 @@ describe('italic some text', function () {
|
|||
// select this text element
|
||||
$firstTextElement.sendkeys('{selectall}');
|
||||
|
||||
const e = inner$.Event(helper.evtType);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.ctrlKey = true; // Control key
|
||||
e.which = 105; // i
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
|
|
|
@ -15,8 +15,8 @@ describe('author of pad edition', function () {
|
|||
setTimeout(() => {
|
||||
// Expire cookie, so author is changed after reloading the pad.
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Example_4_Reset_the_previous_cookie
|
||||
const cookieVal = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
|
||||
helper.padChrome$.document.cookie = cookieVal;
|
||||
helper.padChrome$.document.cookie =
|
||||
'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
|
||||
|
||||
helper.newPad(done, padId);
|
||||
}, 1000);
|
||||
|
@ -25,7 +25,12 @@ describe('author of pad edition', function () {
|
|||
this.timeout(60000);
|
||||
});
|
||||
|
||||
const clearAuthorship = function (done) {
|
||||
// author 2 makes some changes on the pad
|
||||
it('Clears Authorship by second user', function (done) {
|
||||
clearAuthorship(done);
|
||||
});
|
||||
|
||||
const clearAuthorship = (done) => {
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ describe('assign ordered list', function () {
|
|||
|
||||
it('does not insert unordered list', function (done) {
|
||||
this.timeout(3000);
|
||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
|
||||
helper.waitFor(
|
||||
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
|
||||
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
||||
}).fail(() => {
|
||||
done();
|
||||
|
@ -69,7 +70,8 @@ describe('assign ordered list', function () {
|
|||
|
||||
it('does not insert unordered list', function (done) {
|
||||
this.timeout(3000);
|
||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
|
||||
helper.waitFor(
|
||||
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
|
||||
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
||||
}).fail(() => {
|
||||
done();
|
||||
|
@ -78,7 +80,8 @@ describe('assign ordered list', function () {
|
|||
});
|
||||
});
|
||||
|
||||
xit('issue #1125 keeps the numbered list on enter for the new line - EMULATES PASTING INTO A PAD', function (done) {
|
||||
xit('issue #1125 keeps the numbered list on enter for the new line', function (done) {
|
||||
// EMULATES PASTING INTO A PAD
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -104,19 +107,19 @@ describe('assign ordered list', function () {
|
|||
});
|
||||
});
|
||||
|
||||
const triggerCtrlShiftShortcut = function (shortcutChar) {
|
||||
const triggerCtrlShiftShortcut = (shortcutChar) => {
|
||||
const inner$ = helper.padInner$;
|
||||
const e = inner$.Event(helper.evtType);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.ctrlKey = true;
|
||||
e.shiftKey = true;
|
||||
e.which = shortcutChar.toString().charCodeAt(0);
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
};
|
||||
|
||||
const makeSureShortcutIsDisabled = function (shortcut) {
|
||||
const makeSureShortcutIsDisabled = (shortcut) => {
|
||||
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false;
|
||||
};
|
||||
const makeSureShortcutIsEnabled = function (shortcut) {
|
||||
const makeSureShortcutIsEnabled = (shortcut) => {
|
||||
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
|
||||
};
|
||||
});
|
||||
|
@ -142,7 +145,7 @@ describe('Pressing Tab in an OL increases and decreases indentation', function (
|
|||
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
||||
$insertorderedlistButton.click();
|
||||
|
||||
const e = inner$.Event(helper.evtType);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.keyCode = 9; // tab
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
|
||||
|
@ -156,7 +159,8 @@ describe('Pressing Tab in an OL increases and decreases indentation', function (
|
|||
});
|
||||
|
||||
|
||||
describe('Pressing indent/outdent button in an OL increases and decreases indentation and bullet / ol formatting', function () {
|
||||
describe('Pressing indent/outdent button in an OL increases and ' +
|
||||
'decreases indentation and bullet / ol formatting', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
|
|
|
@ -100,17 +100,17 @@ describe('Pad modal', function () {
|
|||
});
|
||||
});
|
||||
|
||||
const clickOnPadInner = function () {
|
||||
const clickOnPadInner = () => {
|
||||
const $editor = helper.padInner$('#innerdocbody');
|
||||
$editor.click();
|
||||
};
|
||||
|
||||
const clickOnPadOuter = function () {
|
||||
const clickOnPadOuter = () => {
|
||||
const $lineNumbersColumn = helper.padOuter$('#sidedivinner');
|
||||
$lineNumbersColumn.click();
|
||||
};
|
||||
|
||||
const openSettingsAndWaitForModalToBeVisible = function (done) {
|
||||
const openSettingsAndWaitForModalToBeVisible = (done) => {
|
||||
helper.padChrome$('.buttonicon-settings').click();
|
||||
|
||||
// wait for modal to be displayed
|
||||
|
@ -118,7 +118,7 @@ describe('Pad modal', function () {
|
|||
helper.waitFor(() => isModalOpened(modalSelector), 10000).done(done);
|
||||
};
|
||||
|
||||
const isEditorDisabled = function () {
|
||||
const isEditorDisabled = () => {
|
||||
const editorDocument = helper.padOuter$("iframe[name='ace_inner']").get(0).contentDocument;
|
||||
const editorBody = editorDocument.getElementById('innerdocbody');
|
||||
|
||||
|
@ -128,7 +128,7 @@ describe('Pad modal', function () {
|
|||
return editorIsDisabled;
|
||||
};
|
||||
|
||||
const isModalOpened = function (modalSelector) {
|
||||
const isModalOpened = (modalSelector) => {
|
||||
const $modal = helper.padChrome$(modalSelector);
|
||||
|
||||
return $modal.hasClass('popup-show');
|
||||
|
|
|
@ -3,14 +3,17 @@
|
|||
// Test for https://github.com/ether/etherpad-lite/issues/1763
|
||||
|
||||
// This test fails in Opera, IE and Safari
|
||||
// Opera fails due to a weird way of handling the order of execution, yet actual performance seems fine
|
||||
// Opera fails due to a weird way of handling the order of execution,
|
||||
// yet actual performance seems fine
|
||||
// Safari fails due the delay being too great yet the actual performance seems fine
|
||||
// Firefox might panic that the script is taking too long so will fail
|
||||
// IE will fail due to running out of memory as it can't fit 2M chars in memory.
|
||||
|
||||
// Just FYI Google Docs crashes on large docs whilst trying to Save, it's likely the limitations we are
|
||||
// Just FYI Google Docs crashes on large docs whilst trying to Save,
|
||||
// it's likely the limitations we are
|
||||
// experiencing are more to do with browser limitations than improper implementation.
|
||||
// A ueber fix for this would be to have a separate lower cpu priority thread that handles operations that aren't
|
||||
// A ueber fix for this would be to have a separate lower cpu priority
|
||||
// thread that handles operations that aren't
|
||||
// visible to the user.
|
||||
|
||||
// Adapted from John McLear's original test case.
|
||||
|
@ -22,16 +25,18 @@ xdescribe('Responsiveness of Editor', function () {
|
|||
this.timeout(6000);
|
||||
});
|
||||
// JM commented out on 8th Sep 2020 for a release, after release this needs uncommenting
|
||||
// And the test needs to be fixed to work in Firefox 52 on Windows 7. I am not sure why it fails on this specific platform
|
||||
// The errors show this.timeout... then crash the browser but I am sure something is actually causing the stack trace and
|
||||
// And the test needs to be fixed to work in Firefox 52 on Windows 7.
|
||||
// I am not sure why it fails on this specific platform
|
||||
// The errors show this.timeout... then crash the browser but
|
||||
// I am sure something is actually causing the stack trace and
|
||||
// I just need to narrow down what, offers to help accepted.
|
||||
it('Fast response to keypress in pad with large amount of contents', function (done) {
|
||||
// skip on Windows Firefox 52.0
|
||||
if (window.bowser && window.bowser.windows && window.bowser.firefox && window.bowser.version == '52.0') {
|
||||
if (window.bowser &&
|
||||
window.bowser.windows && window.bowser.firefox && window.bowser.version === '52.0') {
|
||||
this.skip();
|
||||
}
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
const chars = '0000000000'; // row of placeholder chars
|
||||
const amount = 200000; // number of blocks of chars we will insert
|
||||
const length = (amount * (chars.length) + 1); // include a counter for each space
|
||||
|
@ -41,7 +46,7 @@ xdescribe('Responsiveness of Editor', function () {
|
|||
// get keys to send
|
||||
const keyMultiplier = 10; // multiplier * 10 == total number of key events
|
||||
let keysToSend = '';
|
||||
for (var i = 0; i <= keyMultiplier; i++) {
|
||||
for (let i = 0; i <= keyMultiplier; i++) {
|
||||
keysToSend += chars;
|
||||
}
|
||||
|
||||
|
@ -49,23 +54,23 @@ xdescribe('Responsiveness of Editor', function () {
|
|||
textElement.sendkeys('{selectall}'); // select all
|
||||
textElement.sendkeys('{del}'); // clear the pad text
|
||||
|
||||
for (var i = 0; i <= amount; i++) {
|
||||
for (let i = 0; i <= amount; i++) {
|
||||
text = `${text + chars} `; // add the chars and space to the text contents
|
||||
}
|
||||
inner$('div').first().text(text); // Put the text contents into the pad
|
||||
|
||||
helper.waitFor(() => // Wait for the new contents to be on the pad
|
||||
inner$('div').text().length > length
|
||||
).done(() => {
|
||||
expect(inner$('div').text().length).to.be.greaterThan(length); // has the text changed?
|
||||
// Wait for the new contents to be on the pad
|
||||
helper.waitFor(() => inner$('div').text().length > length).done(() => {
|
||||
// has the text changed?
|
||||
expect(inner$('div').text().length).to.be.greaterThan(length);
|
||||
const start = Date.now(); // get the start time
|
||||
|
||||
// send some new text to the screen (ensure all 3 key events are sent)
|
||||
const el = inner$('div').first();
|
||||
for (let i = 0; i < keysToSend.length; ++i) {
|
||||
var x = keysToSend.charCodeAt(i);
|
||||
const x = keysToSend.charCodeAt(i);
|
||||
['keyup', 'keypress', 'keydown'].forEach((type) => {
|
||||
const e = $.Event(type);
|
||||
const e = new $.Event(type);
|
||||
e.keyCode = x;
|
||||
el.trigger(e);
|
||||
});
|
||||
|
|
|
@ -91,7 +91,7 @@ describe('select formatting buttons when selection has style applied', function
|
|||
// select this text element
|
||||
$firstTextElement.sendkeys('{selectall}');
|
||||
|
||||
const e = inner$.Event(helper.evtType);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.ctrlKey = true; // Control key
|
||||
e.which = key.charCodeAt(0); // I, U, B, 5
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
|
|
|
@ -22,8 +22,6 @@ describe('strikethrough button', function () {
|
|||
const $strikethroughButton = chrome$('.buttonicon-strikethrough');
|
||||
$strikethroughButton.click();
|
||||
|
||||
// ace creates a new dom element when you press a button
|
||||
// so just get the first text element again
|
||||
const $newFirstTextElement = inner$('div').first();
|
||||
|
||||
// is there a <i> element now?
|
||||
|
|
|
@ -14,7 +14,6 @@ xdescribe('timeslider button takes you to the timeslider of a pad', function ()
|
|||
// get the first text element inside the editable space
|
||||
const $firstTextElement = inner$('div span').first();
|
||||
const originalValue = $firstTextElement.text(); // get the original value
|
||||
const newValue = `Testing${originalValue}`;
|
||||
$firstTextElement.sendkeys('Testing'); // send line 1 to the pad
|
||||
|
||||
const modifiedValue = $firstTextElement.text(); // get the modified value
|
||||
|
|
|
@ -9,8 +9,10 @@ describe('timeslider', function () {
|
|||
/**
|
||||
* @todo test authorsList
|
||||
*/
|
||||
|
||||
it('Shows a correctly formatted date and time', async function () {
|
||||
this.timeout(12000);
|
||||
|
||||
// make some changes to produce 3 revisions
|
||||
const revs = 3;
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ describe('timeslider', function () {
|
|||
|
||||
setTimeout(() => {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
$('#iframe-container iframe').attr('src',
|
||||
`${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
|
||||
setTimeout(() => {
|
||||
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
|
@ -84,8 +84,8 @@ describe('timeslider', function () {
|
|||
|
||||
setTimeout(() => {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
$('#iframe-container iframe').attr('src',
|
||||
`${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
|
||||
setTimeout(() => {
|
||||
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
|
@ -102,15 +102,16 @@ describe('timeslider', function () {
|
|||
helper.waitFor(
|
||||
() => $('#iframe-container iframe')[0].contentWindow.location.hash !== oldUrl, 6000)
|
||||
.always(() => {
|
||||
expect($('#iframe-container iframe')[0].contentWindow.location.hash)
|
||||
.not.to.eql(oldUrl);
|
||||
expect(
|
||||
$('#iframe-container iframe')[0].contentWindow.location.hash
|
||||
).not.to.eql(oldUrl);
|
||||
done();
|
||||
});
|
||||
}, 6000);
|
||||
}, revs * timePerRev);
|
||||
});
|
||||
it('jumps to a revision given in the url', function (done) {
|
||||
this.timeout(6000);
|
||||
this.timeout(40000);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
// wait for the text to be loaded
|
||||
|
@ -132,15 +133,16 @@ describe('timeslider', function () {
|
|||
return lenOkay && colorOkay;
|
||||
}, 10000).always(() => {
|
||||
// go to timeslider with a specific revision set
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
|
||||
$('#iframe-container iframe').attr('src',
|
||||
`${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
|
||||
// wait for the timeslider to be loaded
|
||||
helper.waitFor(() => {
|
||||
try {
|
||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
} catch (e) {
|
||||
// silently fart. Deadly.
|
||||
// Empty catch block <3
|
||||
}
|
||||
if (timeslider$) {
|
||||
return timeslider$('#innerdocbody').text().length === oldLength;
|
||||
|
@ -161,8 +163,8 @@ describe('timeslider', function () {
|
|||
|
||||
setTimeout(() => {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
$('#iframe-container iframe').attr('src',
|
||||
`${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
let timeslider$;
|
||||
let exportLink;
|
||||
|
||||
|
@ -170,7 +172,7 @@ describe('timeslider', function () {
|
|||
try {
|
||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
} catch (e) {
|
||||
// silently give up on life.
|
||||
// Empty catch block <3
|
||||
}
|
||||
if (!timeslider$) return false;
|
||||
exportLink = timeslider$('#exportplaina').attr('href');
|
||||
|
|
|
@ -43,7 +43,7 @@ describe('undo button', function () {
|
|||
const modifiedValue = $firstTextElement.text(); // get the modified value
|
||||
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
|
||||
|
||||
const e = inner$.Event(helper.evtType);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.ctrlKey = true; // Control key
|
||||
e.which = 90; // z
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
|
|
|
@ -138,7 +138,8 @@ describe('Pressing Tab in an UL increases and decreases indentation', function (
|
|||
});
|
||||
});
|
||||
|
||||
describe('Pressing indent/outdent button in an UL increases and decreases indentation and bullet / ol formatting', function () {
|
||||
describe('Pressing indent/outdent button in an UL increases and decreases indentation ' +
|
||||
'and bullet / ol formatting', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue