mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
Merge branch 'develop' of github.com:ether/etherpad-lite into admin-tests
This commit is contained in:
commit
8b0f3ad4cb
8 changed files with 171 additions and 537 deletions
|
@ -1,353 +0,0 @@
|
||||||
'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){
|
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
|
||||||
});
|
|
||||||
|
|
||||||
xit("creates a pad", function(done) {
|
|
||||||
padName = helper.newPad(done);
|
|
||||||
this.timeout(60000);
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Tests to do
|
|
||||||
* 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
|
|
||||||
* Down arrow on any other line except the last lines shouldn't move the viewport
|
|
||||||
* Do all of the above tests after a copy/paste event
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* 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 can we simulate an edit event in the test framework?
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
// THIS DOESNT WORK IN CHROME AS IT DOESNT MOVE THE CURSOR!
|
|
||||||
it("down arrow", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
var chrome$ = helper.padChrome$;
|
|
||||||
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
$newFirstTextElement.focus();
|
|
||||||
keyEvent(inner$, 37, false, false); // arrow down
|
|
||||||
keyEvent(inner$, 37, false, false); // arrow down
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Creates N lines", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
console.log(inner$);
|
|
||||||
var chrome$ = helper.padChrome$;
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
|
|
||||||
prepareDocument(numberOfRows, $newFirstTextElement); // N lines into the first div as a target
|
|
||||||
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
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Moves caret up a line", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
var originalCaretPosition = caretPosition(inner$);
|
|
||||||
var originalPos = originalCaretPosition.y;
|
|
||||||
var newCaretPos;
|
|
||||||
keyEvent(inner$, 38, false, false); // arrow up
|
|
||||||
|
|
||||||
helper.waitFor(function(){ // Wait for the DOM to register the new items
|
|
||||||
var newCaretPosition = caretPosition(inner$);
|
|
||||||
newCaretPos = newCaretPosition.y;
|
|
||||||
return (newCaretPos < originalPos);
|
|
||||||
}).done(function(){
|
|
||||||
expect(newCaretPos).to.be.lessThan(originalPos);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Moves caret down a line", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
var originalCaretPosition = caretPosition(inner$);
|
|
||||||
var originalPos = originalCaretPosition.y;
|
|
||||||
var newCaretPos;
|
|
||||||
keyEvent(inner$, 40, false, false); // arrow down
|
|
||||||
|
|
||||||
helper.waitFor(function(){ // Wait for the DOM to register the new items
|
|
||||||
var newCaretPosition = caretPosition(inner$);
|
|
||||||
newCaretPos = newCaretPosition.y;
|
|
||||||
return (newCaretPos > originalPos);
|
|
||||||
}).done(function(){
|
|
||||||
expect(newCaretPos).to.be.moreThan(originalPos);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Moves caret to top of doc", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
var originalCaretPosition = caretPosition(inner$);
|
|
||||||
var originalPos = originalCaretPosition.y;
|
|
||||||
var newCaretPos;
|
|
||||||
|
|
||||||
var i = 0;
|
|
||||||
while(i < numberOfRows){ // press pageup key N times
|
|
||||||
keyEvent(inner$, 33, false, false);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
helper.waitFor(function(){ // Wait for the DOM to register the new items
|
|
||||||
var newCaretPosition = caretPosition(inner$);
|
|
||||||
newCaretPos = newCaretPosition.y;
|
|
||||||
return (newCaretPos < originalPos);
|
|
||||||
}).done(function(){
|
|
||||||
expect(newCaretPos).to.be.lessThan(originalPos);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Moves caret right a position", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
var originalCaretPosition = caretPosition(inner$);
|
|
||||||
var originalPos = originalCaretPosition.x;
|
|
||||||
var newCaretPos;
|
|
||||||
keyEvent(inner$, 39, false, false); // arrow right
|
|
||||||
|
|
||||||
helper.waitFor(function(){ // Wait for the DOM to register the new items
|
|
||||||
var newCaretPosition = caretPosition(inner$);
|
|
||||||
newCaretPos = newCaretPosition.x;
|
|
||||||
return (newCaretPos > originalPos);
|
|
||||||
}).done(function(){
|
|
||||||
expect(newCaretPos).to.be.moreThan(originalPos);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Moves caret left a position", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
var originalCaretPosition = caretPosition(inner$);
|
|
||||||
var originalPos = originalCaretPosition.x;
|
|
||||||
var newCaretPos;
|
|
||||||
keyEvent(inner$, 33, false, false); // arrow left
|
|
||||||
|
|
||||||
helper.waitFor(function(){ // Wait for the DOM to register the new items
|
|
||||||
var newCaretPosition = caretPosition(inner$);
|
|
||||||
newCaretPos = newCaretPosition.x;
|
|
||||||
return (newCaretPos < originalPos);
|
|
||||||
}).done(function(){
|
|
||||||
expect(newCaretPos).to.be.lessThan(originalPos);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Moves caret to the next line using right arrow", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
var originalCaretPosition = caretPosition(inner$);
|
|
||||||
var originalPos = originalCaretPosition.y;
|
|
||||||
var newCaretPos;
|
|
||||||
keyEvent(inner$, 39, false, false); // arrow right
|
|
||||||
keyEvent(inner$, 39, false, false); // arrow right
|
|
||||||
keyEvent(inner$, 39, false, false); // arrow right
|
|
||||||
keyEvent(inner$, 39, false, false); // arrow right
|
|
||||||
keyEvent(inner$, 39, false, false); // arrow right
|
|
||||||
keyEvent(inner$, 39, false, false); // arrow right
|
|
||||||
keyEvent(inner$, 39, false, false); // arrow right
|
|
||||||
|
|
||||||
helper.waitFor(function(){ // Wait for the DOM to register the new items
|
|
||||||
var newCaretPosition = caretPosition(inner$);
|
|
||||||
newCaretPos = newCaretPosition.y;
|
|
||||||
return (newCaretPos > originalPos);
|
|
||||||
}).done(function(){
|
|
||||||
expect(newCaretPos).to.be.moreThan(originalPos);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Moves caret to the previous line using left arrow", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
var originalCaretPosition = caretPosition(inner$);
|
|
||||||
var originalPos = originalCaretPosition.y;
|
|
||||||
var newCaretPos;
|
|
||||||
keyEvent(inner$, 33, false, false); // arrow left
|
|
||||||
|
|
||||||
helper.waitFor(function(){ // Wait for the DOM to register the new items
|
|
||||||
var newCaretPosition = caretPosition(inner$);
|
|
||||||
newCaretPos = newCaretPosition.y;
|
|
||||||
return (newCaretPos < originalPos);
|
|
||||||
}).done(function(){
|
|
||||||
expect(newCaretPos).to.be.lessThan(originalPos);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
it("Creates N rows, changes height of rows, updates UI by caret key events", function(done){
|
|
||||||
var inner$ = helper.padInner$;
|
|
||||||
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
|
|
||||||
var $newFirstTextElement = inner$("div").first();
|
|
||||||
var originalDivHeight = inner$("div").first().css("height");
|
|
||||||
prepareDocument(numberOfRows, $newFirstTextElement); // N lines into the first div as a target
|
|
||||||
|
|
||||||
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
|
|
||||||
// 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");
|
|
||||||
// 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
|
|
||||||
// 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
|
|
||||||
// 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");
|
|
||||||
// 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;
|
|
||||||
while(i < numberOfRows){ // press down arrow
|
|
||||||
keyEvent(inner$, 40, false, false);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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{
|
|
||||||
// Wait for the DOM to scroll into place
|
|
||||||
return isScrolledIntoView(inner$("div:nth-child("+numberOfRows+")"), inner$);
|
|
||||||
}catch(e){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).done(function(){ // Once the DOM has registered the items
|
|
||||||
|
|
||||||
var i = 0;
|
|
||||||
while(i < numberOfRows){ // press down arrow
|
|
||||||
keyEvent(inner$, 33, false, false); // doesn't work
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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{
|
|
||||||
// Wait for the DOM to scroll into place
|
|
||||||
return isScrolledIntoView(inner$("div:nth-child(0)"), inner$);
|
|
||||||
}catch(e){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).done(function(){ // Once the DOM has registered the items
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var i = 0;
|
|
||||||
while(i < numberOfRows){ // press down arrow
|
|
||||||
keyEvent(inner$, 33, false, false); // doesn't work
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// 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();
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
});
|
|
||||||
/*
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
if (shift) {
|
|
||||||
e.shiftKey = true; // Shift Key
|
|
||||||
}
|
|
||||||
e.which = charCode;
|
|
||||||
e.keyCode = charCode;
|
|
||||||
target('#innerdocbody').trigger(e);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// 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));
|
|
||||||
};
|
|
||||||
|
|
||||||
const caretPosition = ($) => {
|
|
||||||
const doc = $.window.document;
|
|
||||||
const pos = doc.getSelection();
|
|
||||||
pos.y = pos.anchorNode.parentElement.offsetTop;
|
|
||||||
pos.x = pos.anchorNode.parentElement.offsetLeft;
|
|
||||||
return pos;
|
|
||||||
};
|
|
||||||
*/
|
|
|
@ -27,9 +27,7 @@ describe('drag and drop', function () {
|
||||||
const originalHTML = helper.padInner$('body').html();
|
const originalHTML = helper.padInner$('body').html();
|
||||||
const $undoButton = helper.padChrome$('.buttonicon-undo');
|
const $undoButton = helper.padChrome$('.buttonicon-undo');
|
||||||
$undoButton.click();
|
$undoButton.click();
|
||||||
await helper.waitForPromise(
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
() => originalHTML !== helper.padInner$('body').html()
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('moves text back to its original place', function (done) {
|
it('moves text back to its original place', function (done) {
|
||||||
|
@ -66,9 +64,7 @@ describe('drag and drop', function () {
|
||||||
const originalHTML = helper.padInner$('body').html();
|
const originalHTML = helper.padInner$('body').html();
|
||||||
const $undoButton = helper.padChrome$('.buttonicon-undo');
|
const $undoButton = helper.padChrome$('.buttonicon-undo');
|
||||||
$undoButton.click();
|
$undoButton.click();
|
||||||
await helper.waitForPromise(
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
() => originalHTML !== helper.padInner$('body').html()
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('moves text back to its original place', function (done) {
|
it('moves text back to its original place', function (done) {
|
||||||
|
|
|
@ -39,21 +39,22 @@ describe('enter keystroke', function () {
|
||||||
while (i < numberOfLines) {
|
while (i < numberOfLines) {
|
||||||
$lastLine = helper.padInner$('div').last();
|
$lastLine = helper.padInner$('div').last();
|
||||||
$lastLine.sendkeys('{enter}');
|
$lastLine.sendkeys('{enter}');
|
||||||
await helper.waitFor(() => helper.padInner$('div').length > previousLineLength);
|
await helper.waitForPromise(() => helper.padInner$('div').length > previousLineLength);
|
||||||
previousLineLength = helper.padInner$('div').length;
|
previousLineLength = helper.padInner$('div').length;
|
||||||
// check we can see the caret..
|
// check we can see the caret..
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
await helper.waitFor(() => helper.padInner$('div').length === numberOfLines + originalLength);
|
await helper.waitForPromise(
|
||||||
|
() => helper.padInner$('div').length === numberOfLines + originalLength);
|
||||||
|
|
||||||
// is edited line fully visible?
|
// is edited line fully visible?
|
||||||
const lastLine = helper.padInner$('div').last();
|
const lastLine = helper.padInner$('div').last();
|
||||||
const bottomOfLastLine = lastLine.offset().top + lastLine.height();
|
const bottomOfLastLine = lastLine.offset().top + lastLine.height();
|
||||||
const scrolledWindow = helper.padChrome$('iframe')[0];
|
const scrolledWindow = helper.padChrome$('iframe')[0];
|
||||||
await helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
const scrolledAmount = scrolledWindow.contentWindow.pageYOffset +
|
const scrolledAmount =
|
||||||
scrolledWindow.contentWindow.innerHeight;
|
scrolledWindow.contentWindow.pageYOffset + scrolledWindow.contentWindow.innerHeight;
|
||||||
return scrolledAmount >= bottomOfLastLine;
|
return scrolledAmount >= bottomOfLastLine;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,135 +1,137 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('assign ordered list', function () {
|
describe('ordered_list.js', function () {
|
||||||
// create a new pad before each test run
|
describe('assign ordered list', function () {
|
||||||
beforeEach(function (cb) {
|
// create a new pad before each test run
|
||||||
helper.newPad(cb);
|
beforeEach(function (cb) {
|
||||||
this.timeout(60000);
|
helper.newPad(cb);
|
||||||
});
|
this.timeout(60000);
|
||||||
|
|
||||||
it('inserts ordered list text', function (done) {
|
|
||||||
const inner$ = helper.padInner$;
|
|
||||||
const chrome$ = helper.padChrome$;
|
|
||||||
|
|
||||||
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
|
||||||
$insertorderedlistButton.click();
|
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div').first().find('ol li').length === 1).done(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
context('when user presses Ctrl+Shift+N', function () {
|
|
||||||
context('and pad shortcut is enabled', function () {
|
|
||||||
beforeEach(async function () {
|
|
||||||
const originalHTML = helper.padInner$('body').html();
|
|
||||||
makeSureShortcutIsEnabled('cmdShiftN');
|
|
||||||
triggerCtrlShiftShortcut('N');
|
|
||||||
await helper.waitForPromise(
|
|
||||||
() => helper.padInner$('body').html !== originalHTML);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('inserts unordered list', function (done) {
|
|
||||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
context('and pad shortcut is disabled', function () {
|
it('inserts ordered list text', function (done) {
|
||||||
beforeEach(async function () {
|
const inner$ = helper.padInner$;
|
||||||
const originalHTML = helper.padInner$('body').html();
|
const chrome$ = helper.padChrome$;
|
||||||
makeSureShortcutIsDisabled('cmdShiftN');
|
|
||||||
triggerCtrlShiftShortcut('N');
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
||||||
await helper.waitForPromise(
|
$insertorderedlistButton.click();
|
||||||
() => helper.padInner$('body').html !== originalHTML);
|
|
||||||
|
helper.waitFor(() => inner$('div').first().find('ol li').length === 1).done(done);
|
||||||
|
});
|
||||||
|
|
||||||
|
context('when user presses Ctrl+Shift+N', function () {
|
||||||
|
context('and pad shortcut is enabled', function () {
|
||||||
|
beforeEach(async function () {
|
||||||
|
const originalHTML = helper.padInner$('body').html();
|
||||||
|
makeSureShortcutIsEnabled('cmdShiftN');
|
||||||
|
triggerCtrlShiftShortcut('N');
|
||||||
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('inserts unordered list', function (done) {
|
||||||
|
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
||||||
|
.done(done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not insert unordered list', function (done) {
|
context('and pad shortcut is disabled', function () {
|
||||||
helper.waitFor(
|
beforeEach(async function () {
|
||||||
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
|
const originalHTML = helper.padInner$('body').html();
|
||||||
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
makeSureShortcutIsDisabled('cmdShiftN');
|
||||||
}).fail(() => {
|
triggerCtrlShiftShortcut('N');
|
||||||
done();
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not insert unordered list', function (done) {
|
||||||
|
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
||||||
|
.done(() => {
|
||||||
|
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
||||||
|
})
|
||||||
|
.fail(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
context('when user presses Ctrl+Shift+1', function () {
|
context('when user presses Ctrl+Shift+1', function () {
|
||||||
context('and pad shortcut is enabled', function () {
|
context('and pad shortcut is enabled', function () {
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
const originalHTML = helper.padInner$('body').html();
|
const originalHTML = helper.padInner$('body').html();
|
||||||
makeSureShortcutIsEnabled('cmdShift1');
|
makeSureShortcutIsEnabled('cmdShift1');
|
||||||
triggerCtrlShiftShortcut('1');
|
triggerCtrlShiftShortcut('1');
|
||||||
await helper.waitForPromise(
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
() => helper.padInner$('body').html !== originalHTML);
|
});
|
||||||
|
|
||||||
|
it('inserts unordered list', function (done) {
|
||||||
|
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
||||||
|
.done(done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inserts unordered list', function (done) {
|
context('and pad shortcut is disabled', function () {
|
||||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done);
|
beforeEach(async function () {
|
||||||
});
|
const originalHTML = helper.padInner$('body').html();
|
||||||
});
|
makeSureShortcutIsDisabled('cmdShift1');
|
||||||
|
triggerCtrlShiftShortcut('1');
|
||||||
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
|
});
|
||||||
|
|
||||||
context('and pad shortcut is disabled', function () {
|
it('does not insert unordered list', function (done) {
|
||||||
beforeEach(async function () {
|
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
||||||
const originalHTML = helper.padInner$('body').html();
|
.done(() => {
|
||||||
makeSureShortcutIsDisabled('cmdShift1');
|
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
||||||
triggerCtrlShiftShortcut('1');
|
})
|
||||||
await helper.waitForPromise(
|
.fail(() => {
|
||||||
() => helper.padInner$('body').html !== originalHTML);
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not insert unordered list', function (done) {
|
|
||||||
helper.waitFor(
|
|
||||||
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
|
|
||||||
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
|
||||||
}).fail(() => {
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
xit('issue #1125 keeps the numbered list on enter for the new line', function (done) {
|
xit('issue #1125 keeps the numbered list on enter for the new line', function (done) {
|
||||||
// EMULATES PASTING INTO A PAD
|
// EMULATES PASTING INTO A PAD
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
||||||
$insertorderedlistButton.click();
|
$insertorderedlistButton.click();
|
||||||
|
|
||||||
// type a bit, make a line break and type again
|
// type a bit, make a line break and type again
|
||||||
const $firstTextElement = inner$('div span').first();
|
const $firstTextElement = inner$('div span').first();
|
||||||
$firstTextElement.sendkeys('line 1');
|
$firstTextElement.sendkeys('line 1');
|
||||||
$firstTextElement.sendkeys('{enter}');
|
$firstTextElement.sendkeys('{enter}');
|
||||||
$firstTextElement.sendkeys('line 2');
|
$firstTextElement.sendkeys('line 2');
|
||||||
$firstTextElement.sendkeys('{enter}');
|
$firstTextElement.sendkeys('{enter}');
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div span').first().text().indexOf('line 2') === -1).done(() => {
|
helper.waitFor(() => inner$('div span').first().text().indexOf('line 2') === -1).done(() => {
|
||||||
const $newSecondLine = inner$('div').first().next();
|
const $newSecondLine = inner$('div').first().next();
|
||||||
const hasOLElement = $newSecondLine.find('ol li').length === 1;
|
const hasOLElement = $newSecondLine.find('ol li').length === 1;
|
||||||
expect(hasOLElement).to.be(true);
|
expect(hasOLElement).to.be(true);
|
||||||
expect($newSecondLine.text()).to.be('line 2');
|
expect($newSecondLine.text()).to.be('line 2');
|
||||||
const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2;
|
const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2;
|
||||||
// This doesn't work because pasting in content doesn't work
|
// This doesn't work because pasting in content doesn't work
|
||||||
expect(hasLineNumber).to.be(true);
|
expect(hasLineNumber).to.be(true);
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const triggerCtrlShiftShortcut = (shortcutChar) => {
|
||||||
|
const inner$ = helper.padInner$;
|
||||||
|
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 = (shortcut) => {
|
||||||
|
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false;
|
||||||
|
};
|
||||||
|
const makeSureShortcutIsEnabled = (shortcut) => {
|
||||||
|
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const triggerCtrlShiftShortcut = (shortcutChar) => {
|
|
||||||
const inner$ = helper.padInner$;
|
|
||||||
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 = (shortcut) => {
|
|
||||||
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false;
|
|
||||||
};
|
|
||||||
const makeSureShortcutIsEnabled = (shortcut) => {
|
|
||||||
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('Pressing Tab in an OL increases and decreases indentation', function () {
|
describe('Pressing Tab in an OL increases and decreases indentation', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(function (cb) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ describe('Pad modal', function () {
|
||||||
clickOnPadInner();
|
clickOnPadInner();
|
||||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||||
const modalIsVisible = $modal.hasClass('popup-show');
|
const modalIsVisible = $modal.hasClass('popup-show');
|
||||||
helper.waitForPromise(() => $modal.hasClass('popup-show') === true);
|
|
||||||
expect(modalIsVisible).to.be(true);
|
expect(modalIsVisible).to.be(true);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
@ -37,12 +37,10 @@ describe('Pad modal', function () {
|
||||||
|
|
||||||
context('and user clicks on pad outer', function () {
|
context('and user clicks on pad outer', function () {
|
||||||
it('does not close the modal', function (done) {
|
it('does not close the modal', function (done) {
|
||||||
|
clickOnPadOuter();
|
||||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||||
const modalIsVisible = $modal.hasClass('popup-show');
|
const modalIsVisible = $modal.hasClass('popup-show');
|
||||||
|
|
||||||
clickOnPadOuter();
|
|
||||||
|
|
||||||
helper.waitForPromise(() => $modal.hasClass('popup-show') === true);
|
|
||||||
expect(modalIsVisible).to.be(true);
|
expect(modalIsVisible).to.be(true);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
@ -69,20 +67,16 @@ describe('Pad modal', function () {
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
context('and user clicks on editor', function () {
|
context('and user clicks on editor', function () {
|
||||||
it('closes the modal', function (done) {
|
it('closes the modal', async function () {
|
||||||
clickOnPadInner();
|
clickOnPadInner();
|
||||||
helper.waitForPromise(() => isModalOpened(MODAL_SELECTOR) === false);
|
await helper.waitForPromise(() => isModalOpened(MODAL_SELECTOR) === false);
|
||||||
expect(isModalOpened(MODAL_SELECTOR)).to.be(false);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('and user clicks on pad outer', function () {
|
context('and user clicks on pad outer', function () {
|
||||||
it('closes the modal', function (done) {
|
it('closes the modal', async function () {
|
||||||
clickOnPadOuter();
|
clickOnPadOuter();
|
||||||
helper.waitForPromise(() => isModalOpened(MODAL_SELECTOR) === false);
|
await helper.waitForPromise(() => isModalOpened(MODAL_SELECTOR) === false);
|
||||||
expect(isModalOpened(MODAL_SELECTOR)).to.be(false);
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,25 +1,24 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('scrolls to line', function () {
|
describe('scrollTo.js', function () {
|
||||||
// create a new pad with URL hash set before each test run
|
describe('scrolls to line', function () {
|
||||||
before(async function () {
|
// create a new pad with URL hash set before each test run
|
||||||
this.timeout(60000);
|
before(async function () {
|
||||||
await new Promise((resolve, reject) => helper.newPad({
|
this.timeout(60000);
|
||||||
cb: (err) => {
|
await new Promise((resolve, reject) => helper.newPad({
|
||||||
if (err != null) return reject(err);
|
cb: (err) => (err != null) ? reject(err) : resolve(),
|
||||||
resolve();
|
hash: 'L4',
|
||||||
},
|
}));
|
||||||
hash: 'L4',
|
});
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Scrolls down to Line 4', async function () {
|
it('Scrolls down to Line 4', async function () {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
await helper.waitForPromise(() => {
|
await helper.waitForPromise(() => {
|
||||||
const topOffset = parseInt(chrome$('iframe').first('iframe')
|
const topOffset = parseInt(chrome$('iframe').first('iframe')
|
||||||
.contents().find('#outerdocbody').css('top'));
|
.contents().find('#outerdocbody').css('top'));
|
||||||
return (topOffset >= 100);
|
return (topOffset >= 100);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -28,10 +27,7 @@ describe('scrolls to line', function () {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
await new Promise((resolve, reject) => helper.newPad({
|
await new Promise((resolve, reject) => helper.newPad({
|
||||||
cb: (err) => {
|
cb: (err) => (err != null) ? reject(err) : resolve(),
|
||||||
if (err != null) return reject(err);
|
|
||||||
resolve();
|
|
||||||
},
|
|
||||||
hash: '#DEEZ123123NUTS',
|
hash: '#DEEZ123123NUTS',
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,7 +39,7 @@ describe('select formatting buttons when selection has style applied', function
|
||||||
const originalHTML = helper.padInner$('body').html();
|
const originalHTML = helper.padInner$('body').html();
|
||||||
const $undoButton = helper.padChrome$('.buttonicon-undo');
|
const $undoButton = helper.padChrome$('.buttonicon-undo');
|
||||||
$undoButton.click();
|
$undoButton.click();
|
||||||
await helper.waitFor(() => originalHTML !== helper.padInner$('body').html());
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
};
|
};
|
||||||
|
|
||||||
const testIfFormattingButtonIsDeselected = function (style) {
|
const testIfFormattingButtonIsDeselected = function (style) {
|
||||||
|
@ -86,7 +86,6 @@ describe('select formatting buttons when selection has style applied', function
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const originalHTML = helper.padInner$('body').html();
|
const originalHTML = helper.padInner$('body').html();
|
||||||
|
|
||||||
helper.waitFor(() => originalHTML !== helper.padInner$('body').html());
|
|
||||||
// get the first text element out of the inner iframe
|
// get the first text element out of the inner iframe
|
||||||
const $firstTextElement = inner$('div').first();
|
const $firstTextElement = inner$('div').first();
|
||||||
|
|
||||||
|
@ -97,8 +96,7 @@ describe('select formatting buttons when selection has style applied', function
|
||||||
e.ctrlKey = true; // Control key
|
e.ctrlKey = true; // Control key
|
||||||
e.which = key.charCodeAt(0); // I, U, B, 5
|
e.which = key.charCodeAt(0); // I, U, B, 5
|
||||||
inner$('#innerdocbody').trigger(e);
|
inner$('#innerdocbody').trigger(e);
|
||||||
await helper.waitForPromise(
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
() => originalHTML !== helper.padInner$('body').html());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
STYLES.forEach((style) => {
|
STYLES.forEach((style) => {
|
||||||
|
@ -130,12 +128,10 @@ describe('select formatting buttons when selection has style applied', function
|
||||||
});
|
});
|
||||||
|
|
||||||
context('when user applies a style and the selection does not change', function () {
|
context('when user applies a style and the selection does not change', function () {
|
||||||
const style = STYLES[0]; // italic
|
|
||||||
|
|
||||||
it('selects the style button', async function () {
|
it('selects the style button', async function () {
|
||||||
|
const style = STYLES[0]; // italic
|
||||||
applyStyleOnLine(style, FIRST_LINE);
|
applyStyleOnLine(style, FIRST_LINE);
|
||||||
await helper.waitForPromise(() => isButtonSelected(style) === true);
|
await helper.waitForPromise(() => isButtonSelected(style) === true);
|
||||||
expect(isButtonSelected(style)).to.be(true);
|
|
||||||
applyStyleOnLine(style, FIRST_LINE);
|
applyStyleOnLine(style, FIRST_LINE);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,33 +1,35 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('assign unordered list', function () {
|
describe('unordered_list.js', function () {
|
||||||
// create a new pad before each test run
|
describe('assign unordered list', function () {
|
||||||
beforeEach(function (cb) {
|
// create a new pad before each test run
|
||||||
helper.newPad(cb);
|
beforeEach(function (cb) {
|
||||||
this.timeout(60000);
|
helper.newPad(cb);
|
||||||
});
|
this.timeout(60000);
|
||||||
|
});
|
||||||
|
|
||||||
it('insert unordered list text then removes by outdent', function (done) {
|
it('insert unordered list text then removes by outdent', function (done) {
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
const originalText = inner$('div').first().text();
|
const originalText = inner$('div').first().text();
|
||||||
|
|
||||||
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
|
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
|
||||||
$insertunorderedlistButton.click();
|
$insertunorderedlistButton.click();
|
||||||
|
|
||||||
helper.waitFor(() => {
|
|
||||||
const newText = inner$('div').first().text();
|
|
||||||
if (newText === originalText) {
|
|
||||||
return inner$('div').first().find('ul li').length === 1;
|
|
||||||
}
|
|
||||||
}).done(() => {
|
|
||||||
// remove indentation by bullet and ensure text string remains the same
|
|
||||||
chrome$('.buttonicon-outdent').click();
|
|
||||||
helper.waitFor(() => {
|
helper.waitFor(() => {
|
||||||
const newText = inner$('div').first().text();
|
const newText = inner$('div').first().text();
|
||||||
return (newText === originalText);
|
if (newText === originalText) {
|
||||||
|
return inner$('div').first().find('ul li').length === 1;
|
||||||
|
}
|
||||||
}).done(() => {
|
}).done(() => {
|
||||||
done();
|
// remove indentation by bullet and ensure text string remains the same
|
||||||
|
chrome$('.buttonicon-outdent').click();
|
||||||
|
helper.waitFor(() => {
|
||||||
|
const newText = inner$('div').first().text();
|
||||||
|
return (newText === originalText);
|
||||||
|
}).done(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue