mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
tests: Refine frontend tests
* Switch from `helper.newPad()` to `helper.aNewPad()`. * Promisify. * Delete redundant logic. * Lint fixes.
This commit is contained in:
parent
3790c0e41c
commit
bbf89dfcf9
35 changed files with 697 additions and 842 deletions
|
@ -4,9 +4,9 @@ describe('All the alphabet works n stuff', function () {
|
||||||
const expectedString = 'abcdefghijklmnopqrstuvwxyz';
|
const expectedString = 'abcdefghijklmnopqrstuvwxyz';
|
||||||
|
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('when you enter any char it appears right', function (done) {
|
it('when you enter any char it appears right', function (done) {
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
describe('bold button', function () {
|
describe('bold button', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('makes text bold on click', function (done) {
|
it('makes text bold on click', function (done) {
|
||||||
|
|
|
@ -2,26 +2,26 @@
|
||||||
|
|
||||||
describe('change user color', function () {
|
describe('change user color', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Color picker matches original color and remembers the user color' +
|
it('Color picker matches original color and remembers the user color' +
|
||||||
' after a refresh', function (done) {
|
' after a refresh', async function () {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
const chrome$ = helper.padChrome$;
|
let chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
// click on the settings button to make settings visible
|
// click on the settings button to make settings visible
|
||||||
const $userButton = chrome$('.buttonicon-showusers');
|
let $userButton = chrome$('.buttonicon-showusers');
|
||||||
$userButton.click();
|
$userButton.click();
|
||||||
|
|
||||||
const $userSwatch = chrome$('#myswatch');
|
let $userSwatch = chrome$('#myswatch');
|
||||||
$userSwatch.click();
|
$userSwatch.click();
|
||||||
|
|
||||||
const fb = chrome$.farbtastic('#colorpicker');
|
const fb = chrome$.farbtastic('#colorpicker');
|
||||||
const $colorPickerSave = chrome$('#mycolorpickersave');
|
const $colorPickerSave = chrome$('#mycolorpickersave');
|
||||||
const $colorPickerPreview = chrome$('#mycolorpickerpreview');
|
let $colorPickerPreview = chrome$('#mycolorpickerpreview');
|
||||||
|
|
||||||
// Same color represented in two different ways
|
// Same color represented in two different ways
|
||||||
const testColorHash = '#abcdef';
|
const testColorHash = '#abcdef';
|
||||||
|
@ -38,28 +38,25 @@ describe('change user color', function () {
|
||||||
$colorPickerSave.click();
|
$colorPickerSave.click();
|
||||||
expect($userSwatch.css('background-color')).to.be(testColorRGB);
|
expect($userSwatch.css('background-color')).to.be(testColorRGB);
|
||||||
|
|
||||||
setTimeout(() => { // give it a second to save the color on the server side
|
// give it a second to save the color on the server side
|
||||||
helper.newPad({ // get a new pad, but don't clear the cookies
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
clearCookies: false,
|
|
||||||
cb() {
|
|
||||||
const chrome$ = helper.padChrome$;
|
|
||||||
|
|
||||||
// click on the settings button to make settings visible
|
// get a new pad, but don't clear the cookies
|
||||||
const $userButton = chrome$('.buttonicon-showusers');
|
await helper.aNewPad({clearCookies: false});
|
||||||
$userButton.click();
|
|
||||||
|
|
||||||
const $userSwatch = chrome$('#myswatch');
|
chrome$ = helper.padChrome$;
|
||||||
$userSwatch.click();
|
|
||||||
|
|
||||||
const $colorPickerPreview = chrome$('#mycolorpickerpreview');
|
// click on the settings button to make settings visible
|
||||||
|
$userButton = chrome$('.buttonicon-showusers');
|
||||||
|
$userButton.click();
|
||||||
|
|
||||||
expect($colorPickerPreview.css('background-color')).to.be(testColorRGB);
|
$userSwatch = chrome$('#myswatch');
|
||||||
expect($userSwatch.css('background-color')).to.be(testColorRGB);
|
$userSwatch.click();
|
||||||
|
|
||||||
done();
|
$colorPickerPreview = chrome$('#mycolorpickerpreview');
|
||||||
},
|
|
||||||
});
|
expect($colorPickerPreview.css('background-color')).to.be(testColorRGB);
|
||||||
}, 1000);
|
expect($userSwatch.css('background-color')).to.be(testColorRGB);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Own user color is shown when you enter a chat', function (done) {
|
it('Own user color is shown when you enter a chat', function (done) {
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
describe('change username value', function () {
|
describe('change username value', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Remembers the user name after a refresh', async function () {
|
it('Remembers the user name after a refresh', async function () {
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
describe('Chat messages and UI', function () {
|
describe('Chat messages and UI', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('opens chat, sends a message, makes sure it exists ' +
|
it('opens chat, sends a message, makes sure it exists ' +
|
||||||
|
@ -86,34 +86,29 @@ describe('Chat messages and UI', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('Checks showChat=false URL Parameter hides chat then' +
|
xit('Checks showChat=false URL Parameter hides chat then' +
|
||||||
' when removed it shows chat', function (done) {
|
' when removed it shows chat', async function () {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
|
||||||
setTimeout(() => { // give it a second to save the username on the server side
|
// give it a second to save the username on the server side
|
||||||
helper.newPad({ // get a new pad, but don't clear the cookies
|
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||||
clearCookies: false,
|
|
||||||
params: {
|
|
||||||
showChat: 'false',
|
|
||||||
}, cb() {
|
|
||||||
const chrome$ = helper.padChrome$;
|
|
||||||
const chaticon = chrome$('#chaticon');
|
|
||||||
// chat should be hidden.
|
|
||||||
expect(chaticon.is(':visible')).to.be(false);
|
|
||||||
|
|
||||||
setTimeout(() => { // give it a second to save the username on the server side
|
// get a new pad, but don't clear the cookies
|
||||||
helper.newPad({ // get a new pad, but don't clear the cookies
|
await helper.aNewPad({clearCookies: false, params: {showChat: 'false'}});
|
||||||
clearCookies: false,
|
|
||||||
cb() {
|
let chrome$ = helper.padChrome$;
|
||||||
const chrome$ = helper.padChrome$;
|
let chaticon = chrome$('#chaticon');
|
||||||
const chaticon = chrome$('#chaticon');
|
// chat should be hidden.
|
||||||
// chat should be visible.
|
expect(chaticon.is(':visible')).to.be(false);
|
||||||
expect(chaticon.is(':visible')).to.be(true);
|
|
||||||
done();
|
// give it a second to save the username on the server side
|
||||||
},
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
});
|
|
||||||
}, 1000);
|
// get a new pad, but don't clear the cookies
|
||||||
},
|
await helper.aNewPad({clearCookies: false});
|
||||||
});
|
|
||||||
}, 3000);
|
chrome$ = helper.padChrome$;
|
||||||
|
chaticon = chrome$('#chaticon');
|
||||||
|
// chat should be visible.
|
||||||
|
expect(chaticon.is(':visible')).to.be(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
describe('chat-load-messages', function () {
|
describe('chat-load-messages', function () {
|
||||||
let padName;
|
let padName;
|
||||||
|
|
||||||
it('creates a pad', function (done) {
|
it('creates a pad', async function () {
|
||||||
padName = helper.newPad(done);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
padName = await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds a lot of messages', async function () {
|
it('adds a lot of messages', async function () {
|
||||||
|
@ -26,7 +26,7 @@ describe('chat-load-messages', function () {
|
||||||
chatInput.sendkeys('{enter}');
|
chatInput.sendkeys('{enter}');
|
||||||
await helper.waitForPromise(() => chatText.children('p').length === i);
|
await helper.waitForPromise(() => chatText.children('p').length === i);
|
||||||
}
|
}
|
||||||
await new Promise((resolve) => helper.newPad(() => resolve(), padName));
|
await helper.aNewPad({id: padName});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checks initial message count', function (done) {
|
it('checks initial message count', function (done) {
|
||||||
|
|
|
@ -2,20 +2,18 @@
|
||||||
|
|
||||||
describe('clear authorship colors button', function () {
|
describe('clear authorship colors button', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('makes text clear authorship colors', function (done) {
|
it('makes text clear authorship colors', async function () {
|
||||||
this.timeout(2500);
|
this.timeout(2500);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
// override the confirm dialogue functioon
|
// override the confirm dialogue functioon
|
||||||
helper.padChrome$.window.confirm = function () {
|
helper.padChrome$.window.confirm = () => true;
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 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();
|
||||||
|
@ -29,41 +27,31 @@ describe('clear authorship colors button', function () {
|
||||||
$firstTextElement.sendkeys('{rightarrow}');
|
$firstTextElement.sendkeys('{rightarrow}');
|
||||||
|
|
||||||
// wait until we have the full value available
|
// wait until we have the full value available
|
||||||
helper.waitFor(() => inner$('div span').first().attr('class').indexOf('author') !== -1
|
await helper.waitForPromise(
|
||||||
).done(() => {
|
() => inner$('div span').first().attr('class').indexOf('author') !== -1);
|
||||||
// IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship
|
|
||||||
inner$('div').first().focus();
|
|
||||||
|
|
||||||
// get the clear authorship colors button and click it
|
// IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship
|
||||||
const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship');
|
inner$('div').first().focus();
|
||||||
$clearauthorshipcolorsButton.click();
|
|
||||||
|
|
||||||
// does the first div include an author class?
|
// get the clear authorship colors button and click it
|
||||||
const hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship');
|
||||||
expect(hasAuthorClass).to.be(false);
|
$clearauthorshipcolorsButton.click();
|
||||||
|
|
||||||
helper.waitFor(() => {
|
// does the first div include an author class?
|
||||||
const disconnectVisible =
|
const hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||||
chrome$('div.disconnected').attr('class').indexOf('visible') === -1;
|
expect(hasAuthorClass).to.be(false);
|
||||||
return (disconnectVisible === true);
|
|
||||||
});
|
|
||||||
|
|
||||||
const disconnectVisible = chrome$('div.disconnected').attr('class').indexOf('visible') === -1;
|
await helper.waitForPromise(
|
||||||
expect(disconnectVisible).to.be(true);
|
() => chrome$('div.disconnected').attr('class').indexOf('visible') === -1);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("makes text clear authorship colors and checks it can't be undone", function (done) {
|
it("makes text clear authorship colors and checks it can't be undone", async function () {
|
||||||
this.timeout(1500);
|
this.timeout(1500);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
// override the confirm dialogue functioon
|
// override the confirm dialogue functioon
|
||||||
helper.padChrome$.window.confirm = function () {
|
helper.padChrome$.window.confirm = () => true;
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 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();
|
||||||
|
@ -77,47 +65,38 @@ describe('clear authorship colors button', function () {
|
||||||
$firstTextElement.sendkeys('{rightarrow}');
|
$firstTextElement.sendkeys('{rightarrow}');
|
||||||
|
|
||||||
// wait until we have the full value available
|
// wait until we have the full value available
|
||||||
helper.waitFor(
|
await helper.waitForPromise(
|
||||||
() => inner$('div span').first().attr('class').indexOf('author') !== -1
|
() => inner$('div span').first().attr('class').indexOf('author') !== -1);
|
||||||
).done(() => {
|
|
||||||
// IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship
|
|
||||||
inner$('div').first().focus();
|
|
||||||
|
|
||||||
// get the clear authorship colors button and click it
|
// IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship
|
||||||
const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship');
|
inner$('div').first().focus();
|
||||||
$clearauthorshipcolorsButton.click();
|
|
||||||
|
|
||||||
// does the first div include an author class?
|
// get the clear authorship colors button and click it
|
||||||
let hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship');
|
||||||
expect(hasAuthorClass).to.be(false);
|
$clearauthorshipcolorsButton.click();
|
||||||
|
|
||||||
const e = new inner$.Event(helper.evtType);
|
// does the first div include an author class?
|
||||||
e.ctrlKey = true; // Control key
|
let hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||||
e.which = 90; // z
|
expect(hasAuthorClass).to.be(false);
|
||||||
inner$('#innerdocbody').trigger(e); // shouldn't od anything
|
|
||||||
|
|
||||||
// does the first div include an author class?
|
const e = new inner$.Event(helper.evtType);
|
||||||
hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
e.ctrlKey = true; // Control key
|
||||||
expect(hasAuthorClass).to.be(false);
|
e.which = 90; // z
|
||||||
|
inner$('#innerdocbody').trigger(e); // shouldn't od anything
|
||||||
|
|
||||||
// get undo and redo buttons
|
// does the first div include an author class?
|
||||||
const $undoButton = chrome$('.buttonicon-undo');
|
hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||||
|
expect(hasAuthorClass).to.be(false);
|
||||||
|
|
||||||
// click the button
|
// get undo and redo buttons
|
||||||
$undoButton.click(); // shouldn't do anything
|
const $undoButton = chrome$('.buttonicon-undo');
|
||||||
hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
|
||||||
expect(hasAuthorClass).to.be(false);
|
|
||||||
|
|
||||||
helper.waitFor(() => {
|
// click the button
|
||||||
const disconnectVisible =
|
$undoButton.click(); // shouldn't do anything
|
||||||
chrome$('div.disconnected').attr('class').indexOf('visible') === -1;
|
hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||||
return (disconnectVisible === true);
|
expect(hasAuthorClass).to.be(false);
|
||||||
});
|
|
||||||
|
|
||||||
const disconnectVisible = chrome$('div.disconnected').attr('class').indexOf('visible') === -1;
|
await helper.waitForPromise(
|
||||||
expect(disconnectVisible).to.be(true);
|
() => chrome$('div.disconnected').attr('class').indexOf('visible') === -1);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
describe('delete keystroke', function () {
|
describe('delete keystroke', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('makes text delete', function (done) {
|
it('makes text delete', async function () {
|
||||||
this.timeout(50);
|
this.timeout(50);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
|
@ -28,7 +28,5 @@ describe('delete keystroke', function () {
|
||||||
|
|
||||||
// expect it to be one char less in length
|
// expect it to be one char less in length
|
||||||
expect(newElementLength).to.be((elementLength - 1));
|
expect(newElementLength).to.be((elementLength - 1));
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,24 +2,23 @@
|
||||||
|
|
||||||
// WARNING: drag and drop is only simulated on these tests, manual testing might also be necessary
|
// WARNING: drag and drop is only simulated on these tests, manual testing might also be necessary
|
||||||
describe('drag and drop', function () {
|
describe('drag and drop', function () {
|
||||||
before(function (done) {
|
before(async function () {
|
||||||
helper.newPad(() => {
|
|
||||||
createScriptWithSeveralLines(done);
|
|
||||||
});
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
|
await createScriptWithSeveralLines();
|
||||||
});
|
});
|
||||||
|
|
||||||
context('when user drags part of one line and drops it far form its original place', function () {
|
context('when user drags part of one line and drops it far form its original place', function () {
|
||||||
before(function (done) {
|
before(async function () {
|
||||||
selectPartOfSourceLine();
|
selectPartOfSourceLine();
|
||||||
dragSelectedTextAndDropItIntoMiddleOfLine(TARGET_LINE);
|
dragSelectedTextAndDropItIntoMiddleOfLine(TARGET_LINE);
|
||||||
|
|
||||||
// make sure DnD was correctly simulated
|
// make sure DnD was correctly simulated
|
||||||
helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
const $targetLine = getLine(TARGET_LINE);
|
const $targetLine = getLine(TARGET_LINE);
|
||||||
const sourceWasMovedToTarget = $targetLine.text() === 'Target line [line 1]';
|
const sourceWasMovedToTarget = $targetLine.text() === 'Target line [line 1]';
|
||||||
return sourceWasMovedToTarget;
|
return sourceWasMovedToTarget;
|
||||||
}).done(done);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('and user triggers UNDO', function () {
|
context('and user triggers UNDO', function () {
|
||||||
|
@ -30,7 +29,7 @@ describe('drag and drop', function () {
|
||||||
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('moves text back to its original place', function (done) {
|
it('moves text back to its original place', async function () {
|
||||||
this.timeout(50);
|
this.timeout(50);
|
||||||
// test text was removed from drop target
|
// test text was removed from drop target
|
||||||
const $targetLine = getLine(TARGET_LINE);
|
const $targetLine = getLine(TARGET_LINE);
|
||||||
|
@ -41,23 +40,21 @@ describe('drag and drop', function () {
|
||||||
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
||||||
expect($firstSourceLine.text()).to.be('Source line 1.');
|
expect($firstSourceLine.text()).to.be('Source line 1.');
|
||||||
expect($lastSourceLine.text()).to.be('Source line 2.');
|
expect($lastSourceLine.text()).to.be('Source line 2.');
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('when user drags some lines far form its original place', function () {
|
context('when user drags some lines far form its original place', function () {
|
||||||
before(function (done) {
|
before(async function () {
|
||||||
selectMultipleSourceLines();
|
selectMultipleSourceLines();
|
||||||
dragSelectedTextAndDropItIntoMiddleOfLine(TARGET_LINE);
|
dragSelectedTextAndDropItIntoMiddleOfLine(TARGET_LINE);
|
||||||
|
|
||||||
// make sure DnD was correctly simulated
|
// make sure DnD was correctly simulated
|
||||||
helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
const $lineAfterTarget = getLine(TARGET_LINE + 1);
|
const $lineAfterTarget = getLine(TARGET_LINE + 1);
|
||||||
const sourceWasMovedToTarget = $lineAfterTarget.text() !== '...';
|
const sourceWasMovedToTarget = $lineAfterTarget.text() !== '...';
|
||||||
return sourceWasMovedToTarget;
|
return sourceWasMovedToTarget;
|
||||||
}).done(done);
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('and user triggers UNDO', function () {
|
context('and user triggers UNDO', function () {
|
||||||
|
@ -68,7 +65,7 @@ describe('drag and drop', function () {
|
||||||
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('moves text back to its original place', function (done) {
|
it('moves text back to its original place', async function () {
|
||||||
this.timeout(50);
|
this.timeout(50);
|
||||||
// test text was removed from drop target
|
// test text was removed from drop target
|
||||||
const $targetLine = getLine(TARGET_LINE);
|
const $targetLine = getLine(TARGET_LINE);
|
||||||
|
@ -79,8 +76,6 @@ describe('drag and drop', function () {
|
||||||
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
||||||
expect($firstSourceLine.text()).to.be('Source line 1.');
|
expect($firstSourceLine.text()).to.be('Source line 1.');
|
||||||
expect($lastSourceLine.text()).to.be('Source line 2.');
|
expect($lastSourceLine.text()).to.be('Source line 2.');
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -94,17 +89,17 @@ describe('drag and drop', function () {
|
||||||
return $lines.slice(lineNumber, lineNumber + 1);
|
return $lines.slice(lineNumber, lineNumber + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
const createScriptWithSeveralLines = (done) => {
|
const createScriptWithSeveralLines = async () => {
|
||||||
// create some lines to be used on the tests
|
// create some lines to be used on the tests
|
||||||
const $firstLine = helper.padInner$('div').first();
|
const $firstLine = helper.padInner$('div').first();
|
||||||
$firstLine.html('...<br>...<br>Target line []<br>...<br>...<br>' +
|
$firstLine.html('...<br>...<br>Target line []<br>...<br>...<br>' +
|
||||||
'Source line 1.<br>Source line 2.<br>');
|
'Source line 1.<br>Source line 2.<br>');
|
||||||
|
|
||||||
// wait for lines to be split
|
// wait for lines to be split
|
||||||
helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
||||||
return $lastSourceLine.text() === 'Source line 2.';
|
return $lastSourceLine.text() === 'Source line 2.';
|
||||||
}).done(done);
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectPartOfSourceLine = () => {
|
const selectPartOfSourceLine = () => {
|
||||||
|
|
|
@ -50,13 +50,13 @@ describe('embed links', function () {
|
||||||
|
|
||||||
describe('read and write', function () {
|
describe('read and write', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('the share link', function () {
|
describe('the share link', function () {
|
||||||
it('is the actual pad url', function (done) {
|
it('is the actual pad url', async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
@ -67,13 +67,11 @@ describe('embed links', function () {
|
||||||
const shareLink = chrome$('#linkinput').val();
|
const shareLink = chrome$('#linkinput').val();
|
||||||
const padURL = chrome$.window.location.href;
|
const padURL = chrome$.window.location.href;
|
||||||
expect(shareLink).to.be(padURL);
|
expect(shareLink).to.be(padURL);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('the embed as iframe code', function () {
|
describe('the embed as iframe code', function () {
|
||||||
it('is an iframe with the the correct url parameters and correct size', function (done) {
|
it('is an iframe with the the correct url parameters and correct size', async function () {
|
||||||
this.timeout(50);
|
this.timeout(50);
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
@ -84,20 +82,18 @@ describe('embed links', function () {
|
||||||
const embedCode = chrome$('#embedinput').val();
|
const embedCode = chrome$('#embedinput').val();
|
||||||
|
|
||||||
checkiFrameCode(embedCode, false);
|
checkiFrameCode(embedCode, false);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when read only option is set', function () {
|
describe('when read only option is set', function () {
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('the share link', function () {
|
describe('the share link', function () {
|
||||||
it('shows a read only url', function (done) {
|
it('shows a read only url', async function () {
|
||||||
this.timeout(50);
|
this.timeout(50);
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
@ -110,13 +106,11 @@ describe('embed links', function () {
|
||||||
const shareLink = chrome$('#linkinput').val();
|
const shareLink = chrome$('#linkinput').val();
|
||||||
const containsReadOnlyLink = shareLink.indexOf('r.') > 0;
|
const containsReadOnlyLink = shareLink.indexOf('r.') > 0;
|
||||||
expect(containsReadOnlyLink).to.be(true);
|
expect(containsReadOnlyLink).to.be(true);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('the embed as iframe code', function () {
|
describe('the embed as iframe code', function () {
|
||||||
it('is an iframe with the the correct url parameters and correct size', function (done) {
|
it('is an iframe with the the correct url parameters and correct size', async function () {
|
||||||
this.timeout(50);
|
this.timeout(50);
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
@ -131,8 +125,6 @@ describe('embed links', function () {
|
||||||
const embedCode = chrome$('#embedinput').val();
|
const embedCode = chrome$('#embedinput').val();
|
||||||
|
|
||||||
checkiFrameCode(embedCode, true);
|
checkiFrameCode(embedCode, true);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
describe('enter keystroke', function () {
|
describe('enter keystroke', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
it('creates a new line & puts cursor onto a new line', function (done) {
|
|
||||||
|
it('creates a new line & puts cursor onto a new line', async function () {
|
||||||
this.timeout(2000);
|
this.timeout(2000);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
|
@ -19,14 +20,13 @@ describe('enter keystroke', function () {
|
||||||
// simulate key presses to enter content
|
// simulate key presses to enter content
|
||||||
$firstTextElement.sendkeys('{enter}');
|
$firstTextElement.sendkeys('{enter}');
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div').first().text() === '').done(() => {
|
await helper.waitForPromise(() => inner$('div').first().text() === '');
|
||||||
const $newSecondLine = inner$('div').first().next();
|
|
||||||
const newFirstTextElementValue = inner$('div').first().text();
|
const $newSecondLine = inner$('div').first().next();
|
||||||
expect(newFirstTextElementValue).to.be(''); // expect the first line to be blank
|
const newFirstTextElementValue = inner$('div').first().text();
|
||||||
// expect the second line to be the same as the original first line.
|
expect(newFirstTextElementValue).to.be(''); // expect the first line to be blank
|
||||||
expect($newSecondLine.text()).to.be(originalTextValue);
|
// expect the second line to be the same as the original first line.
|
||||||
done();
|
expect($newSecondLine.text()).to.be(originalTextValue);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('enter is always visible after event', async function () {
|
it('enter is always visible after event', async function () {
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
describe('font select', function () {
|
describe('font select', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('makes text RobotoMono', function (done) {
|
it('makes text RobotoMono', async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -29,7 +29,5 @@ describe('font select', function () {
|
||||||
const fontFamily = inner$('body').css('font-family').toLowerCase();
|
const fontFamily = inner$('body').css('font-family').toLowerCase();
|
||||||
const containsStr = fontFamily.indexOf('robotomono');
|
const containsStr = fontFamily.indexOf('robotomono');
|
||||||
expect(containsStr).to.not.be(-1);
|
expect(containsStr).to.not.be(-1);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,23 +2,9 @@
|
||||||
|
|
||||||
describe('the test helper', function () {
|
describe('the test helper', function () {
|
||||||
describe('the newPad method', function () {
|
describe('the newPad method', function () {
|
||||||
xit("doesn't leak memory if you creates iframes over and over again", function (done) {
|
xit("doesn't leak memory if you creates iframes over and over again", async function () {
|
||||||
this.timeout(100000);
|
this.timeout(100000);
|
||||||
|
for (let i = 0; i < 10; ++i) await helper.aNewPad();
|
||||||
let times = 10;
|
|
||||||
|
|
||||||
const loadPad = () => {
|
|
||||||
helper.newPad(() => {
|
|
||||||
times--;
|
|
||||||
if (times > 0) {
|
|
||||||
loadPad();
|
|
||||||
} else {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
loadPad();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gives me 3 jquery instances of chrome, outer and inner', async function () {
|
it('gives me 3 jquery instances of chrome, outer and inner', async function () {
|
||||||
|
@ -252,20 +238,19 @@ describe('the test helper', function () {
|
||||||
.replace(/\s/gi, ' ');
|
.replace(/\s/gi, ' ');
|
||||||
};
|
};
|
||||||
|
|
||||||
before(function (done) {
|
before(async function () {
|
||||||
helper.newPad(() => {
|
|
||||||
// create some lines to be used on the tests
|
|
||||||
const $firstLine = helper.padInner$('div').first();
|
|
||||||
$firstLine.sendkeys('{selectall}some{enter}short{enter}lines{enter}to test{enter}{enter}');
|
|
||||||
|
|
||||||
// wait for lines to be split
|
|
||||||
helper.waitFor(() => {
|
|
||||||
const $fourthLine = helper.padInner$('div').eq(3);
|
|
||||||
return $fourthLine.text() === 'to test';
|
|
||||||
}).done(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
|
|
||||||
|
// create some lines to be used on the tests
|
||||||
|
const $firstLine = helper.padInner$('div').first();
|
||||||
|
$firstLine.sendkeys('{selectall}some{enter}short{enter}lines{enter}to test{enter}{enter}');
|
||||||
|
|
||||||
|
// wait for lines to be split
|
||||||
|
await helper.waitForPromise(() => {
|
||||||
|
const $fourthLine = helper.padInner$('div').eq(3);
|
||||||
|
return $fourthLine.text() === 'to test';
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('changes editor selection to be between startOffset of $startLine ' +
|
it('changes editor selection to be between startOffset of $startLine ' +
|
||||||
|
@ -322,7 +307,7 @@ describe('the test helper', function () {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ends selection at beginning of $endLine when its offset is zero', function (done) {
|
it('ends selection at beginning of $endLine when its offset is zero', async function () {
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
const startOffset = 2;
|
const startOffset = 2;
|
||||||
|
@ -344,8 +329,6 @@ describe('the test helper', function () {
|
||||||
* how I'm covering it in this test.
|
* how I'm covering it in this test.
|
||||||
*/
|
*/
|
||||||
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines ');
|
expect(cleanText(selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('ort lines ');
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('selects full line when offset is longer than line content', function (done) {
|
it('selects full line when offset is longer than line content', function (done) {
|
||||||
|
@ -376,7 +359,7 @@ describe('the test helper', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('selects all text between beginning of $startLine and end of $endLine ' +
|
it('selects all text between beginning of $startLine and end of $endLine ' +
|
||||||
'when no offset is provided', function (done) {
|
'when no offset is provided', async function () {
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
const $lines = inner$('div');
|
const $lines = inner$('div');
|
||||||
|
@ -396,8 +379,6 @@ describe('the test helper', function () {
|
||||||
*/
|
*/
|
||||||
expect(cleanText(
|
expect(cleanText(
|
||||||
selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('short lines to test');
|
selection.toString().replace(/(\r\n|\n|\r)/gm, ''))).to.be('short lines to test');
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -500,8 +500,7 @@ describe('importexport.js', function () {
|
||||||
let confirm;
|
let confirm;
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
await new Promise(
|
await helper.aNewPad();
|
||||||
(resolve, reject) => helper.newPad((err) => err != null ? reject(err) : resolve()));
|
|
||||||
confirm = helper.padChrome$.window.confirm;
|
confirm = helper.padChrome$.window.confirm;
|
||||||
helper.padChrome$.window.confirm = () => true;
|
helper.padChrome$.window.confirm = () => true;
|
||||||
// As of 2021-02-22 a mutable FileList cannot be directly created so DataTransfer is used as a
|
// As of 2021-02-22 a mutable FileList cannot be directly created so DataTransfer is used as a
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('import indents functionality', function () {
|
describe('import indents functionality', function () {
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb); // creates a new pad
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
function getinnertext() {
|
const getinnertext = () => {
|
||||||
const inner = helper.padInner$;
|
const inner = helper.padInner$;
|
||||||
let newtext = '';
|
let newtext = '';
|
||||||
inner('div').each((line, el) => {
|
inner('div').each((line, el) => {
|
||||||
newtext += `${el.innerHTML}\n`;
|
newtext += `${el.innerHTML}\n`;
|
||||||
});
|
});
|
||||||
return newtext;
|
return newtext;
|
||||||
}
|
};
|
||||||
function importrequest(data, importurl, type) {
|
|
||||||
|
const importrequest = (data, importurl, type) => {
|
||||||
let error;
|
let error;
|
||||||
const result = $.ajax({
|
const result = $.ajax({
|
||||||
url: importurl,
|
url: importurl,
|
||||||
|
@ -42,8 +43,9 @@ describe('import indents functionality', function () {
|
||||||
});
|
});
|
||||||
expect(error).to.be(undefined);
|
expect(error).to.be(undefined);
|
||||||
return result;
|
return result;
|
||||||
}
|
};
|
||||||
function exportfunc(link) {
|
|
||||||
|
const exportfunc = (link) => {
|
||||||
const exportresults = [];
|
const exportresults = [];
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
async: false,
|
async: false,
|
||||||
|
@ -58,51 +60,72 @@ describe('import indents functionality', function () {
|
||||||
exportresults.push(['txt', data]);
|
exportresults.push(['txt', data]);
|
||||||
});
|
});
|
||||||
return exportresults;
|
return exportresults;
|
||||||
}
|
};
|
||||||
|
|
||||||
xit('import a pad with indents from html', function (done) {
|
xit('import a pad with indents from html', async function () {
|
||||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||||
/* eslint-disable-next-line max-len */
|
const htmlWithIndents =
|
||||||
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>';
|
'<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');
|
importrequest(htmlWithIndents, importurl, 'html');
|
||||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
await helper.waitForPromise(() => getinnertext() ===
|
||||||
'<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n' +
|
'<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-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 1</span></li></ul>\n' +
|
||||||
'<ul class="list-indent2"><li><span class="">indent2 line 2</span></li></ul>\n' +
|
'<ul class="list-indent2"><li><span class="">indent2 line 2</span></li></ul>\n' +
|
||||||
'<br>\n'));
|
'<br>\n');
|
||||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||||
/* eslint-disable-next-line max-len */
|
expect(results[0][1]).to.be(
|
||||||
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>');
|
'<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])
|
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');
|
.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) {
|
xit('import a pad with indented lists and newlines from html', async function () {
|
||||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||||
/* eslint-disable-next-line max-len */
|
const htmlWithIndents =
|
||||||
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>';
|
'<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');
|
importrequest(htmlWithIndents, importurl, 'html');
|
||||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
await helper.waitForPromise(() => getinnertext() ===
|
||||||
'<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n' +
|
'<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n' +
|
||||||
'<br>\n' +
|
'<br>\n' +
|
||||||
'<ul class="list-indent1"><li><span class="">indent 1 line 2</span></li></ul>\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' +
|
'<ul class="list-indent2"><li><span class="">indent 2 times line 1</span></li></ul>\n' +
|
||||||
'<br>\n' +
|
'<br>\n' +
|
||||||
'<ul class="list-indent2"><li><span class="">indent 2 times line 2</span></li></ul>\n' +
|
'<ul class="list-indent2"><li><span class="">indent 2 times line 2</span></li></ul>\n' +
|
||||||
'<br>\n'));
|
'<br>\n');
|
||||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||||
/* eslint-disable-next-line max-len */
|
expect(results[0][1]).to.be(
|
||||||
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>');
|
'<ul class="indent"><li>indent line 1</li></ul><br>' +
|
||||||
/* eslint-disable-next-line max-len */
|
'<ul class="indent"><li>indent 1 line 2</li>' +
|
||||||
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');
|
'<ul class="indent"><li>indent 2 times line 1</li></ul></ul><br>' +
|
||||||
done();
|
'<ul><ul class="indent"><li>indent 2 times line 2</li></ul></ul><br>');
|
||||||
|
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');
|
||||||
});
|
});
|
||||||
xit('import 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', async function () {
|
||||||
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
const importurl = `${helper.padChrome$.window.location.href}/import`;
|
||||||
/* eslint-disable-next-line max-len */
|
const htmlWithIndents =
|
||||||
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>';
|
'<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');
|
importrequest(htmlWithIndents, importurl, 'html');
|
||||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
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 1</span></li></ul>\n<br>\n' +
|
||||||
|
@ -120,10 +143,17 @@ describe('import indents functionality', function () {
|
||||||
'<ul class="list-indent5"><li><span class="">foobar</span></li></ul>\n' +
|
'<ul class="list-indent5"><li><span class="">foobar</span></li></ul>\n' +
|
||||||
'<br>\n'));
|
'<br>\n'));
|
||||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||||
/* eslint-disable-next-line max-len */
|
expect(results[0][1]).to.be(
|
||||||
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>');
|
'<ul class="indent"><li>indent line 1</li></ul><br><ul class="indent">' +
|
||||||
/* eslint-disable-next-line max-len */
|
'<li>indent line 2</li><ul class="indent"><li>indent2 line 1</li></ul></ul><br>' +
|
||||||
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');
|
'<ul><ul><ul><ul class="indent"><li><strong><em><s><u>indent4 line 2 bisu</u></s>' +
|
||||||
done();
|
'</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>');
|
||||||
|
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');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
describe('indentation button', function () {
|
describe('indentation button', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('indent text with keypress', function (done) {
|
it('indent text with keypress', async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@ describe('indentation button', function () {
|
||||||
e.keyCode = 9; // tab :|
|
e.keyCode = 9; // tab :|
|
||||||
inner$('#innerdocbody').trigger(e);
|
inner$('#innerdocbody').trigger(e);
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div').first().find('ul li').length === 1).done(done);
|
await helper.waitForPromise(() => inner$('div').first().find('ul li').length === 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('indent text with button', function (done) {
|
it('indent text with button', async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -32,10 +32,10 @@ describe('indentation button', function () {
|
||||||
const $indentButton = chrome$('.buttonicon-indent');
|
const $indentButton = chrome$('.buttonicon-indent');
|
||||||
$indentButton.click();
|
$indentButton.click();
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div').first().find('ul li').length === 1).done(done);
|
await helper.waitForPromise(() => inner$('div').first().find('ul li').length === 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('keeps the indent on enter for the new line', function (done) {
|
it('keeps the indent on enter for the new line', async function () {
|
||||||
this.timeout(1200);
|
this.timeout(1200);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -50,18 +50,17 @@ describe('indentation button', function () {
|
||||||
$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(() => {
|
await helper.waitFor(() => inner$('div span').first().text().indexOf('line 2') === -1);
|
||||||
const $newSecondLine = inner$('div').first().next();
|
|
||||||
const hasULElement = $newSecondLine.find('ul li').length === 1;
|
|
||||||
|
|
||||||
expect(hasULElement).to.be(true);
|
const $newSecondLine = inner$('div').first().next();
|
||||||
expect($newSecondLine.text()).to.be('line 2');
|
const hasULElement = $newSecondLine.find('ul li').length === 1;
|
||||||
done();
|
|
||||||
});
|
expect(hasULElement).to.be(true);
|
||||||
|
expect($newSecondLine.text()).to.be('line 2');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('indents text with spaces on enter if previous line ends ' +
|
it('indents text with spaces on enter if previous line ends ' +
|
||||||
"with ':', '[', '(', or '{'", function (done) {
|
"with ':', '[', '(', or '{'", async function () {
|
||||||
this.timeout(1200);
|
this.timeout(1200);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
|
@ -72,48 +71,46 @@ describe('indentation button', function () {
|
||||||
$firstTextElement.sendkeys("line with '('{enter}");
|
$firstTextElement.sendkeys("line with '('{enter}");
|
||||||
$firstTextElement.sendkeys("line with '{{}'{enter}");
|
$firstTextElement.sendkeys("line with '{{}'{enter}");
|
||||||
|
|
||||||
helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
// wait for Etherpad to split four lines into separated divs
|
// wait for Etherpad to split four lines into separated divs
|
||||||
const $fourthLine = inner$('div').first().next().next().next();
|
const $fourthLine = inner$('div').first().next().next().next();
|
||||||
return $fourthLine.text().indexOf("line with '{'") === 0;
|
return $fourthLine.text().indexOf("line with '{'") === 0;
|
||||||
}).done(() => {
|
|
||||||
// we validate bottom to top for easier implementation
|
|
||||||
|
|
||||||
// curly braces
|
|
||||||
const $lineWithCurlyBraces = inner$('div').first().next().next().next();
|
|
||||||
$lineWithCurlyBraces.sendkeys('{{}');
|
|
||||||
// cannot use sendkeys('{enter}') here, browser does not read the command properly
|
|
||||||
pressEnter();
|
|
||||||
const $lineAfterCurlyBraces = inner$('div').first().next().next().next().next();
|
|
||||||
expect($lineAfterCurlyBraces.text()).to.match(/\s{4}/); // tab === 4 spaces
|
|
||||||
|
|
||||||
// parenthesis
|
|
||||||
const $lineWithParenthesis = inner$('div').first().next().next();
|
|
||||||
$lineWithParenthesis.sendkeys('(');
|
|
||||||
pressEnter();
|
|
||||||
const $lineAfterParenthesis = inner$('div').first().next().next().next();
|
|
||||||
expect($lineAfterParenthesis.text()).to.match(/\s{4}/);
|
|
||||||
|
|
||||||
// bracket
|
|
||||||
const $lineWithBracket = inner$('div').first().next();
|
|
||||||
$lineWithBracket.sendkeys('[');
|
|
||||||
pressEnter();
|
|
||||||
const $lineAfterBracket = inner$('div').first().next().next();
|
|
||||||
expect($lineAfterBracket.text()).to.match(/\s{4}/);
|
|
||||||
|
|
||||||
// colon
|
|
||||||
const $lineWithColon = inner$('div').first();
|
|
||||||
$lineWithColon.sendkeys(':');
|
|
||||||
pressEnter();
|
|
||||||
const $lineAfterColon = inner$('div').first().next();
|
|
||||||
expect($lineAfterColon.text()).to.match(/\s{4}/);
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// we validate bottom to top for easier implementation
|
||||||
|
|
||||||
|
// curly braces
|
||||||
|
const $lineWithCurlyBraces = inner$('div').first().next().next().next();
|
||||||
|
$lineWithCurlyBraces.sendkeys('{{}');
|
||||||
|
// cannot use sendkeys('{enter}') here, browser does not read the command properly
|
||||||
|
pressEnter();
|
||||||
|
const $lineAfterCurlyBraces = inner$('div').first().next().next().next().next();
|
||||||
|
expect($lineAfterCurlyBraces.text()).to.match(/\s{4}/); // tab === 4 spaces
|
||||||
|
|
||||||
|
// parenthesis
|
||||||
|
const $lineWithParenthesis = inner$('div').first().next().next();
|
||||||
|
$lineWithParenthesis.sendkeys('(');
|
||||||
|
pressEnter();
|
||||||
|
const $lineAfterParenthesis = inner$('div').first().next().next().next();
|
||||||
|
expect($lineAfterParenthesis.text()).to.match(/\s{4}/);
|
||||||
|
|
||||||
|
// bracket
|
||||||
|
const $lineWithBracket = inner$('div').first().next();
|
||||||
|
$lineWithBracket.sendkeys('[');
|
||||||
|
pressEnter();
|
||||||
|
const $lineAfterBracket = inner$('div').first().next().next();
|
||||||
|
expect($lineAfterBracket.text()).to.match(/\s{4}/);
|
||||||
|
|
||||||
|
// colon
|
||||||
|
const $lineWithColon = inner$('div').first();
|
||||||
|
$lineWithColon.sendkeys(':');
|
||||||
|
pressEnter();
|
||||||
|
const $lineAfterColon = inner$('div').first().next();
|
||||||
|
expect($lineAfterColon.text()).to.match(/\s{4}/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('appends indentation to the indent of previous line if previous line ends ' +
|
it('appends indentation to the indent of previous line if previous line ends ' +
|
||||||
"with ':', '[', '(', or '{'", function (done) {
|
"with ':', '[', '(', or '{'", async function () {
|
||||||
this.timeout(1200);
|
this.timeout(1200);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
|
@ -122,20 +119,18 @@ describe('indentation button', function () {
|
||||||
$firstTextElement.sendkeys(" line with some indentation and ':'{enter}");
|
$firstTextElement.sendkeys(" line with some indentation and ':'{enter}");
|
||||||
$firstTextElement.sendkeys('line 2{enter}');
|
$firstTextElement.sendkeys('line 2{enter}');
|
||||||
|
|
||||||
helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
// wait for Etherpad to split two lines into separated divs
|
// wait for Etherpad to split two lines into separated divs
|
||||||
const $secondLine = inner$('div').first().next();
|
const $secondLine = inner$('div').first().next();
|
||||||
return $secondLine.text().indexOf('line 2') === 0;
|
return $secondLine.text().indexOf('line 2') === 0;
|
||||||
}).done(() => {
|
|
||||||
const $lineWithColon = inner$('div').first();
|
|
||||||
$lineWithColon.sendkeys(':');
|
|
||||||
pressEnter();
|
|
||||||
const $lineAfterColon = inner$('div').first().next();
|
|
||||||
// previous line indentation + regular tab (4 spaces)
|
|
||||||
expect($lineAfterColon.text()).to.match(/\s{6}/);
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const $lineWithColon = inner$('div').first();
|
||||||
|
$lineWithColon.sendkeys(':');
|
||||||
|
pressEnter();
|
||||||
|
const $lineAfterColon = inner$('div').first().next();
|
||||||
|
// previous line indentation + regular tab (4 spaces)
|
||||||
|
expect($lineAfterColon.text()).to.match(/\s{6}/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("issue #2772 shows '*' when multiple indented lines " +
|
it("issue #2772 shows '*' when multiple indented lines " +
|
||||||
|
@ -175,97 +170,94 @@ describe('indentation button', function () {
|
||||||
expect($secondLine.text().trim()).to.be('Second');
|
expect($secondLine.text().trim()).to.be('Second');
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
xit('makes text indented and outdented', async function () {
|
||||||
|
// get the inner iframe
|
||||||
|
const $inner = helper.$getPadInner();
|
||||||
|
|
||||||
it("makes text indented and outdented", function() {
|
// get the first text element out of the inner iframe
|
||||||
|
let firstTextElement = $inner.find('div').first();
|
||||||
|
|
||||||
//get the inner iframe
|
// select this text element
|
||||||
var $inner = testHelper.$getPadInner();
|
helper.selectText(firstTextElement[0], $inner);
|
||||||
|
|
||||||
//get the first text element out of the inner iframe
|
// get the indentation button and click it
|
||||||
var firstTextElement = $inner.find("div").first();
|
const $indentButton = helper.$getPadChrome().find('.buttonicon-indent');
|
||||||
|
|
||||||
//select this text element
|
|
||||||
testHelper.selectText(firstTextElement[0], $inner);
|
|
||||||
|
|
||||||
//get the indentation button and click it
|
|
||||||
var $indentButton = testHelper.$getPadChrome().find(".buttonicon-indent");
|
|
||||||
$indentButton.click();
|
$indentButton.click();
|
||||||
|
|
||||||
var newFirstTextElement = $inner.find("div").first();
|
let newFirstTextElement = $inner.find('div').first();
|
||||||
|
|
||||||
// is there a list-indent class element now?
|
// is there a list-indent class element now?
|
||||||
var firstChild = newFirstTextElement.children(":first");
|
let firstChild = newFirstTextElement.children(':first');
|
||||||
var isUL = firstChild.is('ul');
|
let isUL = firstChild.is('ul');
|
||||||
|
|
||||||
//expect it to be the beginning of a list
|
// expect it to be the beginning of a list
|
||||||
expect(isUL).to.be(true);
|
expect(isUL).to.be(true);
|
||||||
|
|
||||||
var secondChild = firstChild.children(":first");
|
let secondChild = firstChild.children(':first');
|
||||||
var isLI = secondChild.is('li');
|
let isLI = secondChild.is('li');
|
||||||
//expect it to be part of a list
|
// expect it to be part of a list
|
||||||
expect(isLI).to.be(true);
|
expect(isLI).to.be(true);
|
||||||
|
|
||||||
//indent again
|
// indent again
|
||||||
$indentButton.click();
|
$indentButton.click();
|
||||||
|
|
||||||
var newFirstTextElement = $inner.find("div").first();
|
newFirstTextElement = $inner.find('div').first();
|
||||||
|
|
||||||
// is there a list-indent class element now?
|
// is there a list-indent class element now?
|
||||||
var firstChild = newFirstTextElement.children(":first");
|
firstChild = newFirstTextElement.children(':first');
|
||||||
var hasListIndent2 = firstChild.hasClass('list-indent2');
|
const hasListIndent2 = firstChild.hasClass('list-indent2');
|
||||||
|
|
||||||
//expect it to be part of a list
|
// expect it to be part of a list
|
||||||
expect(hasListIndent2).to.be(true);
|
expect(hasListIndent2).to.be(true);
|
||||||
|
|
||||||
//make sure the text hasn't changed
|
// make sure the text hasn't changed
|
||||||
expect(newFirstTextElement.text()).to.eql(firstTextElement.text());
|
expect(newFirstTextElement.text()).to.eql(firstTextElement.text());
|
||||||
|
|
||||||
|
|
||||||
// test outdent
|
// test outdent
|
||||||
|
|
||||||
//get the unindentation button and click it twice
|
// get the unindentation button and click it twice
|
||||||
var $outdentButton = testHelper.$getPadChrome().find(".buttonicon-outdent");
|
const $outdentButton = helper.$getPadChrome().find('.buttonicon-outdent');
|
||||||
$outdentButton.click();
|
$outdentButton.click();
|
||||||
$outdentButton.click();
|
$outdentButton.click();
|
||||||
|
|
||||||
var newFirstTextElement = $inner.find("div").first();
|
newFirstTextElement = $inner.find('div').first();
|
||||||
|
|
||||||
// is there a list-indent class element now?
|
// is there a list-indent class element now?
|
||||||
var firstChild = newFirstTextElement.children(":first");
|
firstChild = newFirstTextElement.children(':first');
|
||||||
var isUL = firstChild.is('ul');
|
isUL = firstChild.is('ul');
|
||||||
|
|
||||||
//expect it not to be the beginning of a list
|
// expect it not to be the beginning of a list
|
||||||
expect(isUL).to.be(false);
|
expect(isUL).to.be(false);
|
||||||
|
|
||||||
var secondChild = firstChild.children(":first");
|
secondChild = firstChild.children(':first');
|
||||||
var isLI = secondChild.is('li');
|
isLI = secondChild.is('li');
|
||||||
//expect it to not be part of a list
|
// expect it to not be part of a list
|
||||||
expect(isLI).to.be(false);
|
expect(isLI).to.be(false);
|
||||||
|
|
||||||
//make sure the text hasn't changed
|
// make sure the text hasn't changed
|
||||||
expect(newFirstTextElement.text()).to.eql(firstTextElement.text());
|
expect(newFirstTextElement.text()).to.eql(firstTextElement.text());
|
||||||
|
|
||||||
|
|
||||||
// Next test tests multiple line indentation
|
// Next test tests multiple line indentation
|
||||||
|
|
||||||
//select this text element
|
// select this text element
|
||||||
testHelper.selectText(firstTextElement[0], $inner);
|
helper.selectText(firstTextElement[0], $inner);
|
||||||
|
|
||||||
//indent twice
|
// indent twice
|
||||||
$indentButton.click();
|
$indentButton.click();
|
||||||
$indentButton.click();
|
$indentButton.click();
|
||||||
|
|
||||||
//get the first text element out of the inner iframe
|
// get the first text element out of the inner iframe
|
||||||
var firstTextElement = $inner.find("div").first();
|
firstTextElement = $inner.find('div').first();
|
||||||
|
|
||||||
//select this text element
|
// select this text element
|
||||||
testHelper.selectText(firstTextElement[0], $inner);
|
helper.selectText(firstTextElement[0], $inner);
|
||||||
|
|
||||||
/* this test creates the below content, both should have double indentation
|
/* this test creates the below content, both should have double indentation
|
||||||
line1
|
line1
|
||||||
line2
|
line2
|
||||||
|
*/
|
||||||
|
|
||||||
firstTextElement.sendkeys('{rightarrow}'); // simulate a keypress of enter
|
firstTextElement.sendkeys('{rightarrow}'); // simulate a keypress of enter
|
||||||
firstTextElement.sendkeys('{enter}'); // simulate a keypress of enter
|
firstTextElement.sendkeys('{enter}'); // simulate a keypress of enter
|
||||||
|
@ -273,44 +265,44 @@ describe('indentation button', function () {
|
||||||
firstTextElement.sendkeys('{enter}'); // simulate a keypress of enter
|
firstTextElement.sendkeys('{enter}'); // simulate a keypress of enter
|
||||||
firstTextElement.sendkeys('line 2'); // simulate writing the second line
|
firstTextElement.sendkeys('line 2'); // simulate writing the second line
|
||||||
|
|
||||||
//get the second text element out of the inner iframe
|
// get the second text element out of the inner iframe
|
||||||
setTimeout(function(){ // THIS IS REALLY BAD
|
await new Promise((resolve) => setTimeout(resolve, 1000)); // THIS IS REALLY BAD
|
||||||
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?
|
const secondTextElement = $('iframe').contents()
|
||||||
var firstChild = secondTextElement.children(":first");
|
.find('iframe').contents()
|
||||||
var isUL = firstChild.is('ul');
|
.find('iframe').contents().find('body > div').get(1); // THIS IS UGLY
|
||||||
|
|
||||||
//expect it to be the beginning of a list
|
// is there a list-indent class element now?
|
||||||
expect(isUL).to.be(true);
|
firstChild = secondTextElement.children(':first');
|
||||||
|
isUL = firstChild.is('ul');
|
||||||
|
|
||||||
var secondChild = secondChild.children(":first");
|
// expect it to be the beginning of a list
|
||||||
var isLI = secondChild.is('li');
|
expect(isUL).to.be(true);
|
||||||
//expect it to be part of a list
|
|
||||||
expect(isLI).to.be(true);
|
|
||||||
|
|
||||||
//get the first text element out of the inner iframe
|
secondChild = secondChild.children(':first');
|
||||||
var thirdTextElement = $('iframe').contents()
|
isLI = secondChild.is('li');
|
||||||
.find('iframe').contents()
|
// expect it to be part of a list
|
||||||
.find('iframe').contents()
|
expect(isLI).to.be(true);
|
||||||
.find('body > div').get(2); // THIS IS UGLY TOO
|
|
||||||
|
|
||||||
// is there a list-indent class element now?
|
// get the first text element out of the inner iframe
|
||||||
var firstChild = thirdTextElement.children(":first");
|
const thirdTextElement = $('iframe').contents()
|
||||||
var isUL = firstChild.is('ul');
|
.find('iframe').contents()
|
||||||
|
.find('iframe').contents()
|
||||||
|
.find('body > div').get(2); // THIS IS UGLY TOO
|
||||||
|
|
||||||
//expect it to be the beginning of a list
|
// is there a list-indent class element now?
|
||||||
expect(isUL).to.be(true);
|
firstChild = thirdTextElement.children(':first');
|
||||||
|
isUL = firstChild.is('ul');
|
||||||
|
|
||||||
var secondChild = firstChild.children(":first");
|
// expect it to be the beginning of a list
|
||||||
var isLI = secondChild.is('li');
|
expect(isUL).to.be(true);
|
||||||
|
|
||||||
//expect it to be part of a list
|
secondChild = firstChild.children(':first');
|
||||||
expect(isLI).to.be(true);
|
isLI = secondChild.is('li');
|
||||||
},1000);
|
|
||||||
});*/
|
// expect it to be part of a list
|
||||||
|
expect(isLI).to.be(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const pressEnter = () => {
|
const pressEnter = () => {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('height regression after ace.js refactoring', function () {
|
describe('height regression after ace.js refactoring', function () {
|
||||||
before(function (cb) {
|
before(async function () {
|
||||||
helper.newPad(cb);
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
// everything fits inside the viewport
|
// everything fits inside the viewport
|
||||||
it('clientHeight should equal scrollHeight with few lines', function() {
|
it('clientHeight should equal scrollHeight with few lines', async function () {
|
||||||
const aceOuter = helper.padChrome$('iframe')[0].contentDocument;
|
const aceOuter = helper.padChrome$('iframe')[0].contentDocument;
|
||||||
const clientHeight = aceOuter.documentElement.clientHeight;
|
const clientHeight = aceOuter.documentElement.clientHeight;
|
||||||
const scrollHeight = aceOuter.documentElement.scrollHeight;
|
const scrollHeight = aceOuter.documentElement.scrollHeight;
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
describe('italic some text', function () {
|
describe('italic some text', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('makes text italic using button', function (done) {
|
it('makes text italic using button', async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -33,11 +33,9 @@ describe('italic some text', function () {
|
||||||
|
|
||||||
// make sure the text hasn't changed
|
// make sure the text hasn't changed
|
||||||
expect($newFirstTextElement.text()).to.eql($firstTextElement.text());
|
expect($newFirstTextElement.text()).to.eql($firstTextElement.text());
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('makes text italic using keypress', function (done) {
|
it('makes text italic using keypress', async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
|
@ -63,7 +61,5 @@ describe('italic some text', function () {
|
||||||
|
|
||||||
// make sure the text hasn't changed
|
// make sure the text hasn't changed
|
||||||
expect($newFirstTextElement.text()).to.eql($firstTextElement.text());
|
expect($newFirstTextElement.text()).to.eql($firstTextElement.text());
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,13 +5,13 @@ describe('Language select and change', function () {
|
||||||
window.Cookies.remove('language');
|
window.Cookies.remove('language');
|
||||||
|
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Destroy language cookies
|
// Destroy language cookies
|
||||||
it('makes text german', function (done) {
|
it('makes text german', async function () {
|
||||||
this.timeout(1000);
|
this.timeout(1000);
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
@ -27,21 +27,20 @@ describe('Language select and change', function () {
|
||||||
$languageoption.attr('selected', 'selected');
|
$languageoption.attr('selected', 'selected');
|
||||||
$language.change();
|
$language.change();
|
||||||
|
|
||||||
helper.waitFor(() => chrome$('.buttonicon-bold').parent()[0].title === 'Fett (Strg-B)')
|
await helper.waitForPromise(
|
||||||
.done(() => {
|
() => chrome$('.buttonicon-bold').parent()[0].title === 'Fett (Strg-B)');
|
||||||
// get the value of the bold button
|
|
||||||
const $boldButton = chrome$('.buttonicon-bold').parent();
|
|
||||||
|
|
||||||
// get the title of the bold button
|
// get the value of the bold button
|
||||||
const boldButtonTitle = $boldButton[0].title;
|
const $boldButton = chrome$('.buttonicon-bold').parent();
|
||||||
|
|
||||||
// check if the language is now german
|
// get the title of the bold button
|
||||||
expect(boldButtonTitle).to.be('Fett (Strg-B)');
|
const boldButtonTitle = $boldButton[0].title;
|
||||||
done();
|
|
||||||
});
|
// check if the language is now german
|
||||||
|
expect(boldButtonTitle).to.be('Fett (Strg-B)');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('makes text English', function (done) {
|
it('makes text English', async function () {
|
||||||
this.timeout(1000);
|
this.timeout(1000);
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
@ -56,23 +55,21 @@ describe('Language select and change', function () {
|
||||||
$language.change();
|
$language.change();
|
||||||
|
|
||||||
// get the value of the bold button
|
// get the value of the bold button
|
||||||
const $boldButton = chrome$('.buttonicon-bold').parent();
|
let $boldButton = chrome$('.buttonicon-bold').parent();
|
||||||
|
|
||||||
helper.waitFor(() => $boldButton[0].title !== 'Fett (Strg+B)')
|
await helper.waitForPromise(() => $boldButton[0].title !== 'Fett (Strg+B)');
|
||||||
.done(() => {
|
|
||||||
// get the value of the bold button
|
|
||||||
const $boldButton = chrome$('.buttonicon-bold').parent();
|
|
||||||
|
|
||||||
// get the title of the bold button
|
// get the value of the bold button
|
||||||
const boldButtonTitle = $boldButton[0].title;
|
$boldButton = chrome$('.buttonicon-bold').parent();
|
||||||
|
|
||||||
// check if the language is now English
|
// get the title of the bold button
|
||||||
expect(boldButtonTitle).to.be('Bold (Ctrl+B)');
|
const boldButtonTitle = $boldButton[0].title;
|
||||||
done();
|
|
||||||
});
|
// check if the language is now English
|
||||||
|
expect(boldButtonTitle).to.be('Bold (Ctrl+B)');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('changes direction when picking an rtl lang', function (done) {
|
it('changes direction when picking an rtl lang', async function () {
|
||||||
this.timeout(1000);
|
this.timeout(1000);
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
@ -89,15 +86,13 @@ describe('Language select and change', function () {
|
||||||
$language.val('ar');
|
$language.val('ar');
|
||||||
$languageoption.change();
|
$languageoption.change();
|
||||||
|
|
||||||
helper.waitFor(() => chrome$('html')[0].dir !== 'ltr')
|
await helper.waitForPromise(() => chrome$('html')[0].dir !== 'ltr');
|
||||||
.done(() => {
|
|
||||||
// check if the document's direction was changed
|
// check if the document's direction was changed
|
||||||
expect(chrome$('html')[0].dir).to.be('rtl');
|
expect(chrome$('html')[0].dir).to.be('rtl');
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('changes direction when picking an ltr lang', function (done) {
|
it('changes direction when picking an ltr lang', async function () {
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
// click on the settings button to make settings visible
|
// click on the settings button to make settings visible
|
||||||
|
@ -114,11 +109,9 @@ describe('Language select and change', function () {
|
||||||
$language.val('en');
|
$language.val('en');
|
||||||
$languageoption.change();
|
$languageoption.change();
|
||||||
|
|
||||||
helper.waitFor(() => chrome$('html')[0].dir !== 'rtl')
|
await helper.waitForPromise(() => chrome$('html')[0].dir !== 'rtl');
|
||||||
.done(() => {
|
|
||||||
// check if the document's direction was changed
|
// check if the document's direction was changed
|
||||||
expect(chrome$('html')[0].dir).to.be('ltr');
|
expect(chrome$('html')[0].dir).to.be('ltr');
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
describe('ordered_list.js', function () {
|
describe('ordered_list.js', function () {
|
||||||
describe('assign ordered list', function () {
|
describe('assign ordered list', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inserts ordered list text', function (done) {
|
it('inserts ordered list text', async function () {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -16,7 +16,7 @@ describe('ordered_list.js', function () {
|
||||||
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
||||||
$insertorderedlistButton.click();
|
$insertorderedlistButton.click();
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div').first().find('ol li').length === 1).done(done);
|
await helper.waitForPromise(() => inner$('div').first().find('ol li').length === 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
context('when user presses Ctrl+Shift+N', function () {
|
context('when user presses Ctrl+Shift+N', function () {
|
||||||
|
@ -28,10 +28,10 @@ describe('ordered_list.js', function () {
|
||||||
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inserts unordered list', function (done) {
|
it('inserts unordered list', async function () {
|
||||||
this.timeout(50);
|
this.timeout(50);
|
||||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
await helper.waitForPromise(
|
||||||
.done(done);
|
() => helper.padInner$('div').first().find('ol li').length === 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,15 +53,15 @@ describe('ordered_list.js', function () {
|
||||||
expect(helper.padInner$('body').html()).to.be(originalHTML);
|
expect(helper.padInner$('body').html()).to.be(originalHTML);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not insert unordered list', function (done) {
|
it('does not insert unordered list', async function () {
|
||||||
this.timeout(3000);
|
this.timeout(3000);
|
||||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
try {
|
||||||
.done(() => {
|
await helper.waitForPromise(
|
||||||
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
() => helper.padInner$('div').first().find('ol li').length === 1);
|
||||||
})
|
} catch (err) {
|
||||||
.fail(() => {
|
return;
|
||||||
done();
|
}
|
||||||
});
|
expect().fail('Unordered list inserted, should ignore shortcut');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -75,10 +75,9 @@ describe('ordered_list.js', function () {
|
||||||
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inserts unordered list', function (done) {
|
it('inserts unordered list', async function () {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
helper.waitForPromise(() => helper.padInner$('div').first().find('ol li').length === 1);
|
||||||
.done(done);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -100,20 +99,20 @@ describe('ordered_list.js', function () {
|
||||||
expect(helper.padInner$('body').html()).to.be(originalHTML);
|
expect(helper.padInner$('body').html()).to.be(originalHTML);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not insert unordered list', function (done) {
|
it('does not insert unordered list', async function () {
|
||||||
this.timeout(3000);
|
this.timeout(3000);
|
||||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
try {
|
||||||
.done(() => {
|
await helper.waitForPromise(
|
||||||
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
() => helper.padInner$('div').first().find('ol li').length === 1);
|
||||||
})
|
} catch (err) {
|
||||||
.fail(() => {
|
return;
|
||||||
done();
|
}
|
||||||
});
|
expect().fail('Unordered list inserted, should ignore shortcut');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('issue #4748 keeps numbers increment on OL', function (done) {
|
it('issue #4748 keeps numbers increment on OL', async function () {
|
||||||
this.timeout(5000);
|
this.timeout(5000);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -125,10 +124,9 @@ describe('ordered_list.js', function () {
|
||||||
$secondLine.sendkeys('{selectall}');
|
$secondLine.sendkeys('{selectall}');
|
||||||
$insertorderedlistButton.click();
|
$insertorderedlistButton.click();
|
||||||
expect($secondLine.find('ol').attr('start') === 2);
|
expect($secondLine.find('ol').attr('start') === 2);
|
||||||
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', async function () {
|
||||||
// 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$;
|
||||||
|
@ -143,16 +141,15 @@ describe('ordered_list.js', function () {
|
||||||
$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(() => {
|
await helper.waitForPromise(() => inner$('div span').first().text().indexOf('line 2') === -1);
|
||||||
const $newSecondLine = inner$('div').first().next();
|
|
||||||
const hasOLElement = $newSecondLine.find('ol li').length === 1;
|
const $newSecondLine = inner$('div').first().next();
|
||||||
expect(hasOLElement).to.be(true);
|
const hasOLElement = $newSecondLine.find('ol li').length === 1;
|
||||||
expect($newSecondLine.text()).to.be('line 2');
|
expect(hasOLElement).to.be(true);
|
||||||
const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2;
|
expect($newSecondLine.text()).to.be('line 2');
|
||||||
// This doesn't work because pasting in content doesn't work
|
const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2;
|
||||||
expect(hasLineNumber).to.be(true);
|
// This doesn't work because pasting in content doesn't work
|
||||||
done();
|
expect(hasLineNumber).to.be(true);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const triggerCtrlShiftShortcut = (shortcutChar) => {
|
const triggerCtrlShiftShortcut = (shortcutChar) => {
|
||||||
|
@ -174,12 +171,12 @@ describe('ordered_list.js', function () {
|
||||||
|
|
||||||
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(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('indent and de-indent list item with keypress', function (done) {
|
it('indent and de-indent list item with keypress', async function () {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -202,7 +199,7 @@ describe('ordered_list.js', function () {
|
||||||
e.keyCode = 9; // tab
|
e.keyCode = 9; // tab
|
||||||
inner$('#innerdocbody').trigger(e);
|
inner$('#innerdocbody').trigger(e);
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div').first().find('.list-number1').length === 1).done(done);
|
await helper.waitForPromise(() => inner$('div').first().find('.list-number1').length === 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -210,12 +207,12 @@ describe('ordered_list.js', function () {
|
||||||
describe('Pressing indent/outdent button in an OL increases and ' +
|
describe('Pressing indent/outdent button in an OL increases and ' +
|
||||||
'decreases indentation and bullet / ol formatting', function () {
|
'decreases indentation and bullet / ol formatting', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('indent and de-indent list item with indent button', function (done) {
|
it('indent and de-indent list item with indent button', async function () {
|
||||||
this.timeout(1000);
|
this.timeout(1000);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -237,7 +234,7 @@ describe('ordered_list.js', function () {
|
||||||
const $outdentButton = chrome$('.buttonicon-outdent');
|
const $outdentButton = chrome$('.buttonicon-outdent');
|
||||||
$outdentButton.click(); // make it deindented to 1
|
$outdentButton.click(); // make it deindented to 1
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div').first().find('.list-number1').length === 1).done(done);
|
await helper.waitForPromise(() => inner$('div').first().find('.list-number1').length === 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,49 +4,42 @@ describe('Pad modal', function () {
|
||||||
context('when modal is a "force reconnect" message', function () {
|
context('when modal is a "force reconnect" message', function () {
|
||||||
const MODAL_SELECTOR = '#connectivity';
|
const MODAL_SELECTOR = '#connectivity';
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(async function () {
|
||||||
helper.newPad(() => {
|
|
||||||
// force a "slowcommit" error
|
|
||||||
helper.padChrome$.window.pad.handleChannelStateChange('DISCONNECTED', 'slowcommit');
|
|
||||||
|
|
||||||
// wait for modal to be displayed
|
|
||||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
|
||||||
helper.waitFor(() => $modal.hasClass('popup-show'), 50000).done(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
|
|
||||||
|
// force a "slowcommit" error
|
||||||
|
helper.padChrome$.window.pad.handleChannelStateChange('DISCONNECTED', 'slowcommit');
|
||||||
|
|
||||||
|
// wait for modal to be displayed
|
||||||
|
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||||
|
await helper.waitForPromise(() => $modal.hasClass('popup-show'), 50000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('disables editor', function (done) {
|
it('disables editor', async function () {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
expect(isEditorDisabled()).to.be(true);
|
expect(isEditorDisabled()).to.be(true);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
context('and user clicks on editor', function () {
|
context('and user clicks on editor', function () {
|
||||||
it('does not close the modal', function (done) {
|
it('does not close the modal', async function () {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
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');
|
||||||
|
|
||||||
expect(modalIsVisible).to.be(true);
|
expect(modalIsVisible).to.be(true);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
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', async function () {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
clickOnPadOuter();
|
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');
|
||||||
|
|
||||||
expect(modalIsVisible).to.be(true);
|
expect(modalIsVisible).to.be(true);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -55,20 +48,17 @@ describe('Pad modal', function () {
|
||||||
context('when modal is not an error message', function () {
|
context('when modal is not an error message', function () {
|
||||||
const MODAL_SELECTOR = '#settings';
|
const MODAL_SELECTOR = '#settings';
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(async function () {
|
||||||
helper.newPad(() => {
|
|
||||||
openSettingsAndWaitForModalToBeVisible(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
|
await openSettingsAndWaitForModalToBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
// This test breaks safari testing
|
// This test breaks safari testing
|
||||||
/*
|
xit('does not disable editor', async function () {
|
||||||
it('does not disable editor', function(done) {
|
|
||||||
expect(isEditorDisabled()).to.be(false);
|
expect(isEditorDisabled()).to.be(false);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
context('and user clicks on editor', function () {
|
context('and user clicks on editor', function () {
|
||||||
it('closes the modal', async function () {
|
it('closes the modal', async function () {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
|
@ -96,12 +86,12 @@ describe('Pad modal', function () {
|
||||||
$lineNumbersColumn.click();
|
$lineNumbersColumn.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openSettingsAndWaitForModalToBeVisible = (done) => {
|
const openSettingsAndWaitForModalToBeVisible = async () => {
|
||||||
helper.padChrome$('.buttonicon-settings').click();
|
helper.padChrome$('.buttonicon-settings').click();
|
||||||
|
|
||||||
// wait for modal to be displayed
|
// wait for modal to be displayed
|
||||||
const modalSelector = '#settings';
|
const modalSelector = '#settings';
|
||||||
helper.waitFor(() => isModalOpened(modalSelector), 10000).done(done);
|
await helper.waitForPromise(() => isModalOpened(modalSelector), 10000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isEditorDisabled = () => {
|
const isEditorDisabled = () => {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('undo button then redo button', function () {
|
describe('undo button then redo button', function () {
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb); // creates a new pad
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('redo some typing with button', function (done) {
|
it('redo some typing with button', async function () {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -27,14 +27,12 @@ describe('undo button then redo button', function () {
|
||||||
$undoButton.click(); // removes foo
|
$undoButton.click(); // removes foo
|
||||||
$redoButton.click(); // resends foo
|
$redoButton.click(); // resends foo
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div span').first().text() === newString).done(() => {
|
await helper.waitForPromise(() => inner$('div span').first().text() === newString);
|
||||||
const finalValue = inner$('div').first().text();
|
const finalValue = inner$('div').first().text();
|
||||||
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('redo some typing with keypress', function (done) {
|
it('redo some typing with keypress', async function () {
|
||||||
this.timeout(200);
|
this.timeout(200);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
|
@ -57,10 +55,8 @@ describe('undo button then redo button', function () {
|
||||||
e.which = 121; // y
|
e.which = 121; // y
|
||||||
inner$('#innerdocbody').trigger(e);
|
inner$('#innerdocbody').trigger(e);
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div span').first().text() === newString).done(() => {
|
await helper.waitForPromise(() => inner$('div span').first().text() === newString);
|
||||||
const finalValue = inner$('div').first().text();
|
const finalValue = inner$('div').first().text();
|
||||||
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,17 +20,18 @@
|
||||||
|
|
||||||
xdescribe('Responsiveness of Editor', function () {
|
xdescribe('Responsiveness of Editor', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(6000);
|
this.timeout(6000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
// JM commented out on 8th Sep 2020 for a release, after release this needs uncommenting
|
// 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.
|
// 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
|
// I am not sure why it fails on this specific platform
|
||||||
// The errors show this.timeout... then crash the browser but
|
// The errors show this.timeout... then crash the browser but
|
||||||
// I am sure something is actually causing the stack trace and
|
// I am sure something is actually causing the stack trace and
|
||||||
// I just need to narrow down what, offers to help accepted.
|
// 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) {
|
it('Fast response to keypress in pad with large amount of contents', async function () {
|
||||||
// skip on Windows Firefox 52.0
|
// skip on Windows Firefox 52.0
|
||||||
if (window.bowser &&
|
if (window.bowser &&
|
||||||
window.bowser.windows && window.bowser.firefox && window.bowser.version === '52.0') {
|
window.bowser.windows && window.bowser.firefox && window.bowser.version === '52.0') {
|
||||||
|
@ -60,32 +61,31 @@ xdescribe('Responsiveness of Editor', function () {
|
||||||
inner$('div').first().text(text); // Put the text contents into the pad
|
inner$('div').first().text(text); // Put the text contents into the pad
|
||||||
|
|
||||||
// Wait for the new contents to be on the pad
|
// Wait for the new contents to be on the pad
|
||||||
helper.waitFor(() => inner$('div').text().length > length).done(() => {
|
await helper.waitForPromise(() => inner$('div').text().length > length, 10000);
|
||||||
// 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)
|
// has the text changed?
|
||||||
const el = inner$('div').first();
|
expect(inner$('div').text().length).to.be.greaterThan(length);
|
||||||
for (let i = 0; i < keysToSend.length; ++i) {
|
const start = Date.now(); // get the start time
|
||||||
const x = keysToSend.charCodeAt(i);
|
|
||||||
['keyup', 'keypress', 'keydown'].forEach((type) => {
|
|
||||||
const e = new $.Event(type);
|
|
||||||
e.keyCode = x;
|
|
||||||
el.trigger(e);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
helper.waitFor(() => { // Wait for the ability to process
|
// send some new text to the screen (ensure all 3 key events are sent)
|
||||||
const el = inner$('body');
|
const el = inner$('div').first();
|
||||||
if (el[0].textContent.length > amount) return true;
|
for (let i = 0; i < keysToSend.length; ++i) {
|
||||||
}).done(() => {
|
const x = keysToSend.charCodeAt(i);
|
||||||
const end = Date.now(); // get the current time
|
['keyup', 'keypress', 'keydown'].forEach((type) => {
|
||||||
const delay = end - start; // get the delay as the current time minus the start time
|
const e = new $.Event(type);
|
||||||
|
e.keyCode = x;
|
||||||
|
el.trigger(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
expect(delay).to.be.below(600);
|
await helper.waitForPromise(() => { // Wait for the ability to process
|
||||||
done();
|
const el = inner$('body');
|
||||||
}, 5000);
|
if (el[0].textContent.length > amount) return true;
|
||||||
}, 10000);
|
}, 5000);
|
||||||
|
|
||||||
|
const end = Date.now(); // get the current time
|
||||||
|
const delay = end - start; // get the delay as the current time minus the start time
|
||||||
|
|
||||||
|
expect(delay).to.be.below(600);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,10 +5,7 @@ describe('scrollTo.js', function () {
|
||||||
// create a new pad with URL hash set before each test run
|
// create a new pad with URL hash set before each test run
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
await new Promise((resolve, reject) => helper.newPad({
|
await helper.aNewPad({hash: 'L4'});
|
||||||
cb: (err) => (err != null) ? reject(err) : resolve(),
|
|
||||||
hash: 'L4',
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Scrolls down to Line 4', async function () {
|
it('Scrolls down to Line 4', async function () {
|
||||||
|
@ -26,10 +23,7 @@ describe('scrollTo.js', function () {
|
||||||
// create a new pad with URL hash set before each test run
|
// create a new pad with URL hash set before each test run
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
await new Promise((resolve, reject) => helper.newPad({
|
await helper.aNewPad({hash: '#DEEZ123123NUTS'});
|
||||||
cb: (err) => (err != null) ? reject(err) : resolve(),
|
|
||||||
hash: '#DEEZ123123NUTS',
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Does NOT change scroll', async function () {
|
it('Does NOT change scroll', async function () {
|
||||||
|
|
|
@ -5,9 +5,9 @@ describe('select formatting buttons when selection has style applied', function
|
||||||
const SHORTCUT_KEYS = ['I', 'B', 'U', '5']; // italic, bold, underline, strikethrough
|
const SHORTCUT_KEYS = ['I', 'B', 'U', '5']; // italic, bold, underline, strikethrough
|
||||||
const FIRST_LINE = 0;
|
const FIRST_LINE = 0;
|
||||||
|
|
||||||
before(function (cb) {
|
before(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
const applyStyleOnLine = function (style, line) {
|
const applyStyleOnLine = function (style, line) {
|
||||||
|
@ -43,45 +43,42 @@ describe('select formatting buttons when selection has style applied', function
|
||||||
};
|
};
|
||||||
|
|
||||||
const testIfFormattingButtonIsDeselected = function (style) {
|
const testIfFormattingButtonIsDeselected = function (style) {
|
||||||
it(`deselects the ${style} button`, function (done) {
|
it(`deselects the ${style} button`, async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
helper.waitFor(() => isButtonSelected(style) === false).done(done);
|
await helper.waitForPromise(() => !isButtonSelected(style));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const testIfFormattingButtonIsSelected = function (style) {
|
const testIfFormattingButtonIsSelected = function (style) {
|
||||||
it(`selects the ${style} button`, function (done) {
|
it(`selects the ${style} button`, async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
helper.waitFor(() => isButtonSelected(style)).done(done);
|
await helper.waitForPromise(() => isButtonSelected(style));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyStyleOnLineAndSelectIt = function (line, style, cb) {
|
const applyStyleOnLineAndSelectIt = async function (line, style) {
|
||||||
applyStyleOnLineOnFullLineAndRemoveSelection(line, style, selectLine, cb);
|
await applyStyleOnLineOnFullLineAndRemoveSelection(line, style, selectLine);
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyStyleOnLineAndPlaceCaretOnit = function (line, style, cb) {
|
const applyStyleOnLineAndPlaceCaretOnit = async function (line, style) {
|
||||||
applyStyleOnLineOnFullLineAndRemoveSelection(line, style, placeCaretOnLine, cb);
|
await applyStyleOnLineOnFullLineAndRemoveSelection(line, style, placeCaretOnLine);
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyStyleOnLineOnFullLineAndRemoveSelection = function (line, style, selectTarget, cb) {
|
const applyStyleOnLineOnFullLineAndRemoveSelection = async function (line, style, selectTarget) {
|
||||||
// see if line html has changed
|
// see if line html has changed
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const oldLineHTML = inner$.find('div')[line];
|
const oldLineHTML = inner$.find('div')[line];
|
||||||
applyStyleOnLine(style, line);
|
applyStyleOnLine(style, line);
|
||||||
|
|
||||||
helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
const lineHTML = inner$.find('div')[line];
|
const lineHTML = inner$.find('div')[line];
|
||||||
return lineHTML !== oldLineHTML;
|
return lineHTML !== oldLineHTML;
|
||||||
});
|
});
|
||||||
// remove selection from previous line
|
// remove selection from previous line
|
||||||
selectLine(line + 1);
|
selectLine(line + 1);
|
||||||
// setTimeout(function() {
|
|
||||||
// select the text or place the caret on a position that
|
// select the text or place the caret on a position that
|
||||||
// has the formatting text applied previously
|
// has the formatting text applied previously
|
||||||
selectTarget(line);
|
selectTarget(line);
|
||||||
cb();
|
|
||||||
// }, 1000);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const pressFormattingShortcutOnSelection = async function (key) {
|
const pressFormattingShortcutOnSelection = async function (key) {
|
||||||
|
@ -103,9 +100,9 @@ describe('select formatting buttons when selection has style applied', function
|
||||||
|
|
||||||
STYLES.forEach((style) => {
|
STYLES.forEach((style) => {
|
||||||
context(`when selection is in a text with ${style} applied`, function () {
|
context(`when selection is in a text with ${style} applied`, function () {
|
||||||
before(function (done) {
|
before(async function () {
|
||||||
this.timeout(4000);
|
this.timeout(4000);
|
||||||
applyStyleOnLineAndSelectIt(FIRST_LINE, style, done);
|
await applyStyleOnLineAndSelectIt(FIRST_LINE, style);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
@ -116,9 +113,9 @@ describe('select formatting buttons when selection has style applied', function
|
||||||
});
|
});
|
||||||
|
|
||||||
context(`when caret is in a position with ${style} applied`, function () {
|
context(`when caret is in a position with ${style} applied`, function () {
|
||||||
before(function (done) {
|
before(async function () {
|
||||||
this.timeout(4000);
|
this.timeout(4000);
|
||||||
applyStyleOnLineAndPlaceCaretOnit(FIRST_LINE, style, done);
|
await applyStyleOnLineAndPlaceCaretOnit(FIRST_LINE, style);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
describe('strikethrough button', function () {
|
describe('strikethrough button', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('makes text strikethrough', function (done) {
|
it('makes text strikethrough', async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -33,7 +33,5 @@ describe('strikethrough button', function () {
|
||||||
|
|
||||||
// make sure the text hasn't changed
|
// make sure the text hasn't changed
|
||||||
expect($newFirstTextElement.text()).to.eql($firstTextElement.text());
|
expect($newFirstTextElement.text()).to.eql($firstTextElement.text());
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
// deactivated, we need a nice way to get the timeslider, this is ugly
|
// deactivated, we need a nice way to get the timeslider, this is ugly
|
||||||
xdescribe('timeslider button takes you to the timeslider of a pad', function () {
|
xdescribe('timeslider button takes you to the timeslider of a pad', function () {
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb); // creates a new pad
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('timeslider contained in URL', function (done) {
|
it('timeslider contained in URL', async function () {
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
|
||||||
|
@ -19,25 +19,24 @@ xdescribe('timeslider button takes you to the timeslider of a pad', function ()
|
||||||
const modifiedValue = $firstTextElement.text(); // get the modified value
|
const modifiedValue = $firstTextElement.text(); // get the modified value
|
||||||
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
|
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
|
||||||
|
|
||||||
helper.waitFor(() => modifiedValue !== originalValue // The value has changed so we can..
|
// The value has changed so we can..
|
||||||
).done(() => {
|
await helper.waitForPromise(() => modifiedValue !== originalValue);
|
||||||
const $timesliderButton = chrome$('#timesliderlink');
|
|
||||||
$timesliderButton.click(); // So click the timeslider link
|
|
||||||
|
|
||||||
helper.waitFor(() => {
|
const $timesliderButton = chrome$('#timesliderlink');
|
||||||
const iFrameURL = chrome$.window.location.href;
|
$timesliderButton.click(); // So click the timeslider link
|
||||||
if (iFrameURL) {
|
|
||||||
return iFrameURL.indexOf('timeslider') !== -1;
|
await helper.waitForPromise(() => {
|
||||||
} else {
|
const iFrameURL = chrome$.window.location.href;
|
||||||
return false; // the URL hasnt been set yet
|
if (iFrameURL) {
|
||||||
}
|
return iFrameURL.indexOf('timeslider') !== -1;
|
||||||
}).done(() => {
|
} else {
|
||||||
// click the buttons
|
return false; // the URL hasnt been set yet
|
||||||
const iFrameURL = chrome$.window.location.href; // get the url
|
}
|
||||||
const inTimeslider = iFrameURL.indexOf('timeslider') !== -1;
|
|
||||||
expect(inTimeslider).to.be(true); // expect the value to change
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// click the buttons
|
||||||
|
const iFrameURL = chrome$.window.location.href; // get the url
|
||||||
|
const inTimeslider = iFrameURL.indexOf('timeslider') !== -1;
|
||||||
|
expect(inTimeslider).to.be(true); // expect the value to change
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
describe('timeslider follow', function () {
|
describe('timeslider follow', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO needs test if content is also followed, when user a makes edits
|
// TODO needs test if content is also followed, when user a makes edits
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
describe('timeslider', function () {
|
describe('timeslider', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,8 +4,8 @@ describe('timeslider', function () {
|
||||||
const padId = 735773577357 + (Math.round(Math.random() * 1000));
|
const padId = 735773577357 + (Math.round(Math.random() * 1000));
|
||||||
|
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb, padId);
|
await helper.aNewPad({id: padId});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Makes sure the export URIs are as expected when the padID is numeric', async function () {
|
it('Makes sure the export URIs are as expected when the padID is numeric', async function () {
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
describe('timeslider', function () {
|
describe('timeslider', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('loads adds a hundred revisions', function (done) { // passes
|
it('loads adds a hundred revisions', async function () {
|
||||||
this.timeout(100000);
|
this.timeout(100000);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -17,58 +17,54 @@ describe('timeslider', function () {
|
||||||
const revs = 99;
|
const revs = 99;
|
||||||
this.timeout(revs * timePerRev + 10000);
|
this.timeout(revs * timePerRev + 10000);
|
||||||
for (let i = 0; i < revs; i++) {
|
for (let i = 0; i < revs; i++) {
|
||||||
setTimeout(() => {
|
await new Promise((resolve) => setTimeout(resolve, timePerRev));
|
||||||
// enter 'a' in the first text element
|
// enter 'a' in the first text element
|
||||||
inner$('div').first().sendkeys('a');
|
inner$('div').first().sendkeys('a');
|
||||||
}, timePerRev * i);
|
|
||||||
}
|
}
|
||||||
chrome$('.buttonicon-savedRevision').click();
|
chrome$('.buttonicon-savedRevision').click();
|
||||||
|
|
||||||
setTimeout(() => {
|
// go to timeslider
|
||||||
// go to timeslider
|
$('#iframe-container iframe')
|
||||||
$('#iframe-container iframe').attr('src',
|
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||||
`${$('#iframe-container iframe').attr('src')}/timeslider`);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
await new Promise((resolve) => setTimeout(resolve, 6000));
|
||||||
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
|
||||||
const $sliderBar = timeslider$('#ui-slider-bar');
|
|
||||||
|
|
||||||
const latestContents = timeslider$('#innerdocbody').text();
|
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||||
|
const $sliderBar = timeslider$('#ui-slider-bar');
|
||||||
|
|
||||||
// Click somewhere on the timeslider
|
const latestContents = timeslider$('#innerdocbody').text();
|
||||||
let e = new jQuery.Event('mousedown');
|
|
||||||
// sets y co-ordinate of the pad slider modal.
|
|
||||||
const base = (timeslider$('#ui-slider-bar').offset().top - 24);
|
|
||||||
e.clientX = e.pageX = 150;
|
|
||||||
e.clientY = e.pageY = base + 5;
|
|
||||||
$sliderBar.trigger(e);
|
|
||||||
|
|
||||||
e = new jQuery.Event('mousedown');
|
// Click somewhere on the timeslider
|
||||||
e.clientX = e.pageX = 150;
|
let e = new jQuery.Event('mousedown');
|
||||||
e.clientY = e.pageY = base;
|
// sets y co-ordinate of the pad slider modal.
|
||||||
$sliderBar.trigger(e);
|
const base = (timeslider$('#ui-slider-bar').offset().top - 24);
|
||||||
|
e.clientX = e.pageX = 150;
|
||||||
|
e.clientY = e.pageY = base + 5;
|
||||||
|
$sliderBar.trigger(e);
|
||||||
|
|
||||||
e = new jQuery.Event('mousedown');
|
e = new jQuery.Event('mousedown');
|
||||||
e.clientX = e.pageX = 150;
|
e.clientX = e.pageX = 150;
|
||||||
e.clientY = e.pageY = base - 5;
|
e.clientY = e.pageY = base;
|
||||||
$sliderBar.trigger(e);
|
$sliderBar.trigger(e);
|
||||||
|
|
||||||
$sliderBar.trigger('mouseup');
|
e = new jQuery.Event('mousedown');
|
||||||
|
e.clientX = e.pageX = 150;
|
||||||
|
e.clientY = e.pageY = base - 5;
|
||||||
|
$sliderBar.trigger(e);
|
||||||
|
|
||||||
setTimeout(() => {
|
$sliderBar.trigger('mouseup');
|
||||||
// make sure the text has changed
|
|
||||||
expect(timeslider$('#innerdocbody').text()).not.to.eql(latestContents);
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
const starIsVisible = timeslider$('.star').is(':visible');
|
|
||||||
expect(starIsVisible).to.eql(true);
|
// make sure the text has changed
|
||||||
done();
|
expect(timeslider$('#innerdocbody').text()).not.to.eql(latestContents);
|
||||||
}, 1000);
|
const starIsVisible = timeslider$('.star').is(':visible');
|
||||||
}, 6000);
|
expect(starIsVisible).to.eql(true);
|
||||||
}, revs * timePerRev);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Disabled as jquery trigger no longer works properly
|
// Disabled as jquery trigger no longer works properly
|
||||||
xit('changes the url when clicking on the timeslider', function (done) {
|
xit('changes the url when clicking on the timeslider', async function () {
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
// make some changes to produce 7 revisions
|
// make some changes to produce 7 revisions
|
||||||
|
@ -76,110 +72,94 @@ describe('timeslider', function () {
|
||||||
const revs = 20;
|
const revs = 20;
|
||||||
this.timeout(revs * timePerRev + 10000);
|
this.timeout(revs * timePerRev + 10000);
|
||||||
for (let i = 0; i < revs; i++) {
|
for (let i = 0; i < revs; i++) {
|
||||||
setTimeout(() => {
|
await new Promise((resolve) => setTimeout(resolve, timePerRev));
|
||||||
// enter 'a' in the first text element
|
// enter 'a' in the first text element
|
||||||
inner$('div').first().sendkeys('a');
|
inner$('div').first().sendkeys('a');
|
||||||
}, timePerRev * i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
// go to timeslider
|
||||||
// go to timeslider
|
$('#iframe-container iframe')
|
||||||
$('#iframe-container iframe').attr('src',
|
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||||
`${$('#iframe-container iframe').attr('src')}/timeslider`);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
await new Promise((resolve) => setTimeout(resolve, 6000));
|
||||||
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
|
||||||
const $sliderBar = timeslider$('#ui-slider-bar');
|
|
||||||
|
|
||||||
const oldUrl = $('#iframe-container iframe')[0].contentWindow.location.hash;
|
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||||
|
const $sliderBar = timeslider$('#ui-slider-bar');
|
||||||
|
|
||||||
// Click somewhere on the timeslider
|
const oldUrl = $('#iframe-container iframe')[0].contentWindow.location.hash;
|
||||||
const e = new jQuery.Event('mousedown');
|
|
||||||
e.clientX = e.pageX = 150;
|
|
||||||
e.clientY = e.pageY = 60;
|
|
||||||
$sliderBar.trigger(e);
|
|
||||||
|
|
||||||
helper.waitFor(
|
// Click somewhere on the timeslider
|
||||||
() => $('#iframe-container iframe')[0].contentWindow.location.hash !== oldUrl, 6000)
|
const e = new jQuery.Event('mousedown');
|
||||||
.always(() => {
|
e.clientX = e.pageX = 150;
|
||||||
expect(
|
e.clientY = e.pageY = 60;
|
||||||
$('#iframe-container iframe')[0].contentWindow.location.hash
|
$sliderBar.trigger(e);
|
||||||
).not.to.eql(oldUrl);
|
|
||||||
done();
|
await helper.waitForPromise(
|
||||||
});
|
() => $('#iframe-container iframe')[0].contentWindow.location.hash !== oldUrl, 6000);
|
||||||
}, 6000);
|
|
||||||
}, revs * timePerRev);
|
|
||||||
});
|
});
|
||||||
it('jumps to a revision given in the url', function (done) {
|
|
||||||
|
it('jumps to a revision given in the url', async function () {
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
this.timeout(40000);
|
this.timeout(40000);
|
||||||
|
|
||||||
// wait for the text to be loaded
|
// wait for the text to be loaded
|
||||||
helper.waitFor(() => inner$('body').text().length !== 0, 10000).always(() => {
|
await helper.waitForPromise(() => inner$('body').text().length !== 0, 10000);
|
||||||
const newLines = inner$('body div').length;
|
|
||||||
const oldLength = inner$('body').text().length + newLines / 2;
|
|
||||||
expect(oldLength).to.not.eql(0);
|
|
||||||
inner$('div').first().sendkeys('a');
|
|
||||||
let timeslider$;
|
|
||||||
|
|
||||||
// wait for our additional revision to be added
|
const newLines = inner$('body div').length;
|
||||||
helper.waitFor(() => {
|
const oldLength = inner$('body').text().length + newLines / 2;
|
||||||
// newLines takes the new lines into account which are strippen when using
|
expect(oldLength).to.not.eql(0);
|
||||||
// inner$('body').text(), one <div> is used for one line in ACE.
|
inner$('div').first().sendkeys('a');
|
||||||
const lenOkay = inner$('body').text().length + newLines / 2 !== oldLength;
|
let timeslider$;
|
||||||
// this waits for the color to be added to our <span>, which means that the revision
|
|
||||||
// was accepted by the server.
|
|
||||||
const colorOkay = inner$('span').first().attr('class').indexOf('author-') === 0;
|
|
||||||
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`);
|
|
||||||
|
|
||||||
// wait for the timeslider to be loaded
|
// wait for our additional revision to be added
|
||||||
helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
try {
|
// newLines takes the new lines into account which are strippen when using
|
||||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
// inner$('body').text(), one <div> is used for one line in ACE.
|
||||||
} catch (e) {
|
const lenOkay = inner$('body').text().length + newLines / 2 !== oldLength;
|
||||||
// Empty catch block <3
|
// this waits for the color to be added to our <span>, which means that the revision
|
||||||
}
|
// was accepted by the server.
|
||||||
if (timeslider$) {
|
const colorOkay = inner$('span').first().attr('class').indexOf('author-') === 0;
|
||||||
return timeslider$('#innerdocbody').text().length === oldLength;
|
return lenOkay && colorOkay;
|
||||||
}
|
}, 10000);
|
||||||
}, 10000).always(() => {
|
|
||||||
expect(timeslider$('#innerdocbody').text().length).to.eql(oldLength);
|
// go to timeslider with a specific revision set
|
||||||
done();
|
$('#iframe-container iframe')
|
||||||
});
|
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||||
});
|
|
||||||
});
|
// wait for the timeslider to be loaded
|
||||||
|
await helper.waitForPromise(() => {
|
||||||
|
try {
|
||||||
|
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||||
|
} catch (e) {
|
||||||
|
// Empty catch block <3
|
||||||
|
}
|
||||||
|
return timeslider$ && timeslider$('#innerdocbody').text().length === oldLength;
|
||||||
|
}, 10000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checks the export url', function (done) {
|
it('checks the export url', async function () {
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
this.timeout(11000);
|
this.timeout(11000);
|
||||||
inner$('div').first().sendkeys('a');
|
inner$('div').first().sendkeys('a');
|
||||||
|
|
||||||
setTimeout(() => {
|
await new Promise((resolve) => setTimeout(resolve, 2500));
|
||||||
// go to timeslider
|
|
||||||
$('#iframe-container iframe').attr('src',
|
|
||||||
`${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
|
||||||
let timeslider$;
|
|
||||||
let exportLink;
|
|
||||||
|
|
||||||
helper.waitFor(() => {
|
// go to timeslider
|
||||||
try {
|
$('#iframe-container iframe')
|
||||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||||
} catch (e) {
|
let timeslider$;
|
||||||
// Empty catch block <3
|
let exportLink;
|
||||||
}
|
|
||||||
if (!timeslider$) return false;
|
await helper.waitForPromise(() => {
|
||||||
exportLink = timeslider$('#exportplaina').attr('href');
|
try {
|
||||||
if (!exportLink) return false;
|
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||||
return exportLink.substr(exportLink.length - 12) === '0/export/txt';
|
} catch (e) {
|
||||||
}, 6000).always(() => {
|
// Empty catch block <3
|
||||||
expect(exportLink.substr(exportLink.length - 12)).to.eql('0/export/txt');
|
}
|
||||||
done();
|
if (!timeslider$) return false;
|
||||||
});
|
exportLink = timeslider$('#exportplaina').attr('href');
|
||||||
}, 2500);
|
if (!exportLink) return false;
|
||||||
|
return exportLink.substr(exportLink.length - 12) === '0/export/txt';
|
||||||
|
}, 6000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('undo button', function () {
|
describe('undo button', function () {
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb); // creates a new pad
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('undo some typing by clicking undo button', function (done) {
|
it('undo some typing by clicking undo button', async function () {
|
||||||
this.timeout(100);
|
this.timeout(100);
|
||||||
this.timeout(150);
|
this.timeout(150);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
@ -25,14 +25,10 @@ describe('undo button', function () {
|
||||||
// click the button
|
// click the button
|
||||||
$undoButton.click();
|
$undoButton.click();
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div span').first().text() === originalValue).done(() => {
|
await helper.waitForPromise(() => inner$('div span').first().text() === originalValue);
|
||||||
const finalValue = inner$('div span').first().text();
|
|
||||||
expect(finalValue).to.be(originalValue); // expect the value to change
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('undo some typing using a keypress', function (done) {
|
it('undo some typing using a keypress', async function () {
|
||||||
this.timeout(150);
|
this.timeout(150);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
|
|
||||||
|
@ -49,10 +45,6 @@ describe('undo button', function () {
|
||||||
e.which = 90; // z
|
e.which = 90; // z
|
||||||
inner$('#innerdocbody').trigger(e);
|
inner$('#innerdocbody').trigger(e);
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div span').first().text() === originalValue).done(() => {
|
await helper.waitForPromise(() => inner$('div span').first().text() === originalValue);
|
||||||
const finalValue = inner$('div span').first().text();
|
|
||||||
expect(finalValue).to.be(originalValue); // expect the value to change
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
describe('unordered_list.js', function () {
|
describe('unordered_list.js', function () {
|
||||||
describe('assign unordered list', function () {
|
describe('assign unordered list', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('insert unordered list text then removes by outdent', function (done) {
|
it('insert unordered list text then removes by outdent', async function () {
|
||||||
this.timeout(150);
|
this.timeout(150);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -17,32 +17,25 @@ describe('unordered_list.js', function () {
|
||||||
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
|
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
|
||||||
$insertunorderedlistButton.click();
|
$insertunorderedlistButton.click();
|
||||||
|
|
||||||
helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
const newText = inner$('div').first().text();
|
const newText = inner$('div').first().text();
|
||||||
if (newText === originalText) {
|
return newText === originalText && inner$('div').first().find('ul li').length === 1;
|
||||||
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(() => {
|
|
||||||
const newText = inner$('div').first().text();
|
|
||||||
return (newText === originalText);
|
|
||||||
}).done(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// remove indentation by bullet and ensure text string remains the same
|
||||||
|
chrome$('.buttonicon-outdent').click();
|
||||||
|
await helper.waitForPromise(() => inner$('div').first().text() === originalText);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('unassign unordered list', function () {
|
describe('unassign unordered list', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('insert unordered list text then remove by clicking list again', function (done) {
|
it('insert unordered list text then remove by clicking list again', async function () {
|
||||||
this.timeout(150);
|
this.timeout(150);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -51,34 +44,26 @@ describe('unordered_list.js', function () {
|
||||||
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
|
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
|
||||||
$insertunorderedlistButton.click();
|
$insertunorderedlistButton.click();
|
||||||
|
|
||||||
helper.waitFor(() => {
|
await helper.waitForPromise(() => {
|
||||||
const newText = inner$('div').first().text();
|
const newText = inner$('div').first().text();
|
||||||
if (newText === originalText) {
|
return newText === originalText && inner$('div').first().find('ul li').length === 1;
|
||||||
return inner$('div').first().find('ul li').length === 1;
|
|
||||||
}
|
|
||||||
}).done(() => {
|
|
||||||
// remove indentation by bullet and ensure text string remains the same
|
|
||||||
$insertunorderedlistButton.click();
|
|
||||||
helper.waitFor(() => {
|
|
||||||
const isList = inner$('div').find('ul').length === 1;
|
|
||||||
// sohuldn't be list
|
|
||||||
return (isList === false);
|
|
||||||
}).done(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// remove indentation by bullet and ensure text string remains the same
|
||||||
|
$insertunorderedlistButton.click();
|
||||||
|
await helper.waitForPromise(() => inner$('div').find('ul').length !== 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('keep unordered list on enter key', function () {
|
describe('keep unordered list on enter key', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Keeps the unordered list on enter for the new line', function (done) {
|
it('Keeps the unordered list on enter for the new line', async function () {
|
||||||
this.timeout(250);
|
this.timeout(250);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -93,24 +78,23 @@ describe('unordered_list.js', function () {
|
||||||
$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(() => {
|
await helper.waitForPromise(() => inner$('div span').first().text().indexOf('line 2') === -1);
|
||||||
const $newSecondLine = inner$('div').first().next();
|
|
||||||
const hasULElement = $newSecondLine.find('ul li').length === 1;
|
const $newSecondLine = inner$('div').first().next();
|
||||||
expect(hasULElement).to.be(true);
|
const hasULElement = $newSecondLine.find('ul li').length === 1;
|
||||||
expect($newSecondLine.text()).to.be('line 2');
|
expect(hasULElement).to.be(true);
|
||||||
done();
|
expect($newSecondLine.text()).to.be('line 2');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Pressing Tab in an UL increases and decreases indentation', function () {
|
describe('Pressing Tab in an UL 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(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('indent and de-indent list item with keypress', function (done) {
|
it('indent and de-indent list item with keypress', async function () {
|
||||||
this.timeout(150);
|
this.timeout(150);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -133,19 +117,19 @@ describe('unordered_list.js', function () {
|
||||||
e.keyCode = 9; // tab
|
e.keyCode = 9; // tab
|
||||||
inner$('#innerdocbody').trigger(e);
|
inner$('#innerdocbody').trigger(e);
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div').first().find('.list-bullet1').length === 1).done(done);
|
await helper.waitForPromise(() => inner$('div').first().find('.list-bullet1').length === 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Pressing indent/outdent button in an UL increases and decreases indentation ' +
|
describe('Pressing indent/outdent button in an UL increases and decreases indentation ' +
|
||||||
'and bullet / ol formatting', function () {
|
'and bullet / ol formatting', function () {
|
||||||
// create a new pad before each test run
|
// create a new pad before each test run
|
||||||
beforeEach(function (cb) {
|
beforeEach(async function () {
|
||||||
helper.newPad(cb);
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
await helper.aNewPad();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('indent and de-indent list item with indent button', function (done) {
|
it('indent and de-indent list item with indent button', async function () {
|
||||||
this.timeout(150);
|
this.timeout(150);
|
||||||
const inner$ = helper.padInner$;
|
const inner$ = helper.padInner$;
|
||||||
const chrome$ = helper.padChrome$;
|
const chrome$ = helper.padChrome$;
|
||||||
|
@ -166,7 +150,7 @@ describe('unordered_list.js', function () {
|
||||||
const $outdentButton = chrome$('.buttonicon-outdent');
|
const $outdentButton = chrome$('.buttonicon-outdent');
|
||||||
$outdentButton.click(); // make it deindented to 1
|
$outdentButton.click(); // make it deindented to 1
|
||||||
|
|
||||||
helper.waitFor(() => inner$('div').first().find('.list-bullet1').length === 1).done(done);
|
await helper.waitForPromise(() => inner$('div').first().find('.list-bullet1').length === 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,10 +7,7 @@ describe('urls', function () {
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
await new Promise((resolve, reject) => helper.newPad((err) => {
|
await helper.aNewPad();
|
||||||
if (err != null) return reject(err);
|
|
||||||
resolve();
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
|
|
|
@ -3,34 +3,31 @@
|
||||||
describe('Automatic pad reload on Force Reconnect message', function () {
|
describe('Automatic pad reload on Force Reconnect message', function () {
|
||||||
let padId, $originalPadFrame;
|
let padId, $originalPadFrame;
|
||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(async function () {
|
||||||
padId = helper.newPad(() => {
|
|
||||||
// enable userdup error to have timer to force reconnect
|
|
||||||
const $errorMessageModal = helper.padChrome$('#connectivity .userdup');
|
|
||||||
$errorMessageModal.addClass('with_reconnect_timer');
|
|
||||||
|
|
||||||
// make sure there's a timeout set, otherwise automatic reconnect won't be enabled
|
|
||||||
helper.padChrome$.window.clientVars.automaticReconnectionTimeout = 2;
|
|
||||||
|
|
||||||
// open same pad on another iframe, to force userdup error
|
|
||||||
const $otherIframeWithSamePad = $(`<iframe src="/p/${padId}" style="height: 1px;"></iframe>`);
|
|
||||||
$originalPadFrame = $('#iframe-container iframe');
|
|
||||||
$otherIframeWithSamePad.insertAfter($originalPadFrame);
|
|
||||||
|
|
||||||
// wait for modal to be displayed
|
|
||||||
helper.waitFor(() => $errorMessageModal.is(':visible'), 50000).done(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
padId = await helper.aNewPad();
|
||||||
|
|
||||||
|
// enable userdup error to have timer to force reconnect
|
||||||
|
const $errorMessageModal = helper.padChrome$('#connectivity .userdup');
|
||||||
|
$errorMessageModal.addClass('with_reconnect_timer');
|
||||||
|
|
||||||
|
// make sure there's a timeout set, otherwise automatic reconnect won't be enabled
|
||||||
|
helper.padChrome$.window.clientVars.automaticReconnectionTimeout = 2;
|
||||||
|
|
||||||
|
// open same pad on another iframe, to force userdup error
|
||||||
|
const $otherIframeWithSamePad = $(`<iframe src="/p/${padId}" style="height: 1px;"></iframe>`);
|
||||||
|
$originalPadFrame = $('#iframe-container iframe');
|
||||||
|
$otherIframeWithSamePad.insertAfter($originalPadFrame);
|
||||||
|
|
||||||
|
// wait for modal to be displayed
|
||||||
|
await helper.waitForPromise(() => $errorMessageModal.is(':visible'), 50000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('displays a count down timer to automatically reconnect', function (done) {
|
it('displays a count down timer to automatically reconnect', async function () {
|
||||||
const $errorMessageModal = helper.padChrome$('#connectivity .userdup');
|
const $errorMessageModal = helper.padChrome$('#connectivity .userdup');
|
||||||
const $countDownTimer = $errorMessageModal.find('.reconnecttimer');
|
const $countDownTimer = $errorMessageModal.find('.reconnecttimer');
|
||||||
|
|
||||||
expect($countDownTimer.is(':visible')).to.be(true);
|
expect($countDownTimer.is(':visible')).to.be(true);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
context('and user clicks on Cancel', function () {
|
context('and user clicks on Cancel', function () {
|
||||||
|
@ -41,31 +38,20 @@ describe('Automatic pad reload on Force Reconnect message', function () {
|
||||||
() => helper.padChrome$('#connectivity .userdup').is(':visible') === true);
|
() => helper.padChrome$('#connectivity .userdup').is(':visible') === true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not show Cancel button nor timer anymore', function (done) {
|
it('does not show Cancel button nor timer anymore', async function () {
|
||||||
const $errorMessageModal = helper.padChrome$('#connectivity .userdup');
|
const $errorMessageModal = helper.padChrome$('#connectivity .userdup');
|
||||||
const $countDownTimer = $errorMessageModal.find('.reconnecttimer');
|
const $countDownTimer = $errorMessageModal.find('.reconnecttimer');
|
||||||
const $cancelButton = $errorMessageModal.find('#cancelreconnect');
|
const $cancelButton = $errorMessageModal.find('#cancelreconnect');
|
||||||
|
|
||||||
expect($countDownTimer.is(':visible')).to.be(false);
|
expect($countDownTimer.is(':visible')).to.be(false);
|
||||||
expect($cancelButton.is(':visible')).to.be(false);
|
expect($cancelButton.is(':visible')).to.be(false);
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('and user does not click on Cancel until timer expires', function () {
|
context('and user does not click on Cancel until timer expires', function () {
|
||||||
let padWasReloaded = false;
|
it('reloads the pad', async function () {
|
||||||
|
|
||||||
beforeEach(async function () {
|
|
||||||
$originalPadFrame.one('load', () => {
|
|
||||||
padWasReloaded = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('reloads the pad', function (done) {
|
|
||||||
helper.waitFor(() => padWasReloaded, 10000).done(done);
|
|
||||||
|
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
|
await new Promise((resolve) => $originalPadFrame.one('load', resolve));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue