mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +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';
|
||||
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('when you enter any char it appears right', function (done) {
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
describe('bold button', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('makes text bold on click', function (done) {
|
||||
|
|
|
@ -2,26 +2,26 @@
|
|||
|
||||
describe('change user color', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('Color picker matches original color and remembers the user color' +
|
||||
' after a refresh', function (done) {
|
||||
' after a refresh', async function () {
|
||||
this.timeout(10000);
|
||||
const chrome$ = helper.padChrome$;
|
||||
let chrome$ = helper.padChrome$;
|
||||
|
||||
// click on the settings button to make settings visible
|
||||
const $userButton = chrome$('.buttonicon-showusers');
|
||||
let $userButton = chrome$('.buttonicon-showusers');
|
||||
$userButton.click();
|
||||
|
||||
const $userSwatch = chrome$('#myswatch');
|
||||
let $userSwatch = chrome$('#myswatch');
|
||||
$userSwatch.click();
|
||||
|
||||
const fb = chrome$.farbtastic('#colorpicker');
|
||||
const $colorPickerSave = chrome$('#mycolorpickersave');
|
||||
const $colorPickerPreview = chrome$('#mycolorpickerpreview');
|
||||
let $colorPickerPreview = chrome$('#mycolorpickerpreview');
|
||||
|
||||
// Same color represented in two different ways
|
||||
const testColorHash = '#abcdef';
|
||||
|
@ -38,28 +38,25 @@ describe('change user color', function () {
|
|||
$colorPickerSave.click();
|
||||
expect($userSwatch.css('background-color')).to.be(testColorRGB);
|
||||
|
||||
setTimeout(() => { // give it a second to save the color on the server side
|
||||
helper.newPad({ // get a new pad, but don't clear the cookies
|
||||
clearCookies: false,
|
||||
cb() {
|
||||
const chrome$ = helper.padChrome$;
|
||||
// give it a second to save the color on the server side
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
|
||||
// click on the settings button to make settings visible
|
||||
const $userButton = chrome$('.buttonicon-showusers');
|
||||
$userButton.click();
|
||||
// get a new pad, but don't clear the cookies
|
||||
await helper.aNewPad({clearCookies: false});
|
||||
|
||||
const $userSwatch = chrome$('#myswatch');
|
||||
$userSwatch.click();
|
||||
chrome$ = helper.padChrome$;
|
||||
|
||||
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);
|
||||
expect($userSwatch.css('background-color')).to.be(testColorRGB);
|
||||
$userSwatch = chrome$('#myswatch');
|
||||
$userSwatch.click();
|
||||
|
||||
done();
|
||||
},
|
||||
});
|
||||
}, 1000);
|
||||
$colorPickerPreview = chrome$('#mycolorpickerpreview');
|
||||
|
||||
expect($colorPickerPreview.css('background-color')).to.be(testColorRGB);
|
||||
expect($userSwatch.css('background-color')).to.be(testColorRGB);
|
||||
});
|
||||
|
||||
it('Own user color is shown when you enter a chat', function (done) {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
describe('change username value', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('Remembers the user name after a refresh', async function () {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
describe('Chat messages and UI', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
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' +
|
||||
' when removed it shows chat', function (done) {
|
||||
' when removed it shows chat', async function () {
|
||||
this.timeout(60000);
|
||||
|
||||
setTimeout(() => { // give it a second to save the username on the server side
|
||||
helper.newPad({ // get a new pad, but don't clear the cookies
|
||||
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);
|
||||
// give it a second to save the username on the server side
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||
|
||||
setTimeout(() => { // give it a second to save the username on the server side
|
||||
helper.newPad({ // get a new pad, but don't clear the cookies
|
||||
clearCookies: false,
|
||||
cb() {
|
||||
const chrome$ = helper.padChrome$;
|
||||
const chaticon = chrome$('#chaticon');
|
||||
// chat should be visible.
|
||||
expect(chaticon.is(':visible')).to.be(true);
|
||||
done();
|
||||
},
|
||||
});
|
||||
}, 1000);
|
||||
},
|
||||
});
|
||||
}, 3000);
|
||||
// get a new pad, but don't clear the cookies
|
||||
await helper.aNewPad({clearCookies: false, params: {showChat: 'false'}});
|
||||
|
||||
let chrome$ = helper.padChrome$;
|
||||
let chaticon = chrome$('#chaticon');
|
||||
// chat should be hidden.
|
||||
expect(chaticon.is(':visible')).to.be(false);
|
||||
|
||||
// give it a second to save the username on the server side
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
|
||||
// get a new pad, but don't clear the cookies
|
||||
await helper.aNewPad({clearCookies: false});
|
||||
|
||||
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 () {
|
||||
let padName;
|
||||
|
||||
it('creates a pad', function (done) {
|
||||
padName = helper.newPad(done);
|
||||
it('creates a pad', async function () {
|
||||
this.timeout(60000);
|
||||
padName = await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('adds a lot of messages', async function () {
|
||||
|
@ -26,7 +26,7 @@ describe('chat-load-messages', function () {
|
|||
chatInput.sendkeys('{enter}');
|
||||
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) {
|
||||
|
|
|
@ -2,20 +2,18 @@
|
|||
|
||||
describe('clear authorship colors button', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
// override the confirm dialogue functioon
|
||||
helper.padChrome$.window.confirm = function () {
|
||||
return true;
|
||||
};
|
||||
helper.padChrome$.window.confirm = () => true;
|
||||
|
||||
// get the first text element out of the inner iframe
|
||||
const $firstTextElement = inner$('div').first();
|
||||
|
@ -29,41 +27,31 @@ describe('clear authorship colors button', function () {
|
|||
$firstTextElement.sendkeys('{rightarrow}');
|
||||
|
||||
// wait until we have the full value available
|
||||
helper.waitFor(() => 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();
|
||||
await helper.waitForPromise(
|
||||
() => inner$('div span').first().attr('class').indexOf('author') !== -1);
|
||||
|
||||
// get the clear authorship colors button and click it
|
||||
const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship');
|
||||
$clearauthorshipcolorsButton.click();
|
||||
// IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship
|
||||
inner$('div').first().focus();
|
||||
|
||||
// does the first div include an author class?
|
||||
const hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||
expect(hasAuthorClass).to.be(false);
|
||||
// get the clear authorship colors button and click it
|
||||
const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship');
|
||||
$clearauthorshipcolorsButton.click();
|
||||
|
||||
helper.waitFor(() => {
|
||||
const disconnectVisible =
|
||||
chrome$('div.disconnected').attr('class').indexOf('visible') === -1;
|
||||
return (disconnectVisible === true);
|
||||
});
|
||||
// does the first div include an author class?
|
||||
const hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||
expect(hasAuthorClass).to.be(false);
|
||||
|
||||
const disconnectVisible = chrome$('div.disconnected').attr('class').indexOf('visible') === -1;
|
||||
expect(disconnectVisible).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
await helper.waitForPromise(
|
||||
() => chrome$('div.disconnected').attr('class').indexOf('visible') === -1);
|
||||
});
|
||||
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
// override the confirm dialogue functioon
|
||||
helper.padChrome$.window.confirm = function () {
|
||||
return true;
|
||||
};
|
||||
helper.padChrome$.window.confirm = () => true;
|
||||
|
||||
// get the first text element out of the inner iframe
|
||||
const $firstTextElement = inner$('div').first();
|
||||
|
@ -77,47 +65,38 @@ describe('clear authorship colors button', function () {
|
|||
$firstTextElement.sendkeys('{rightarrow}');
|
||||
|
||||
// wait until we have the full value available
|
||||
helper.waitFor(
|
||||
() => 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();
|
||||
await helper.waitForPromise(
|
||||
() => inner$('div span').first().attr('class').indexOf('author') !== -1);
|
||||
|
||||
// get the clear authorship colors button and click it
|
||||
const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship');
|
||||
$clearauthorshipcolorsButton.click();
|
||||
// IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship
|
||||
inner$('div').first().focus();
|
||||
|
||||
// does the first div include an author class?
|
||||
let hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||
expect(hasAuthorClass).to.be(false);
|
||||
// get the clear authorship colors button and click it
|
||||
const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship');
|
||||
$clearauthorshipcolorsButton.click();
|
||||
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.ctrlKey = true; // Control key
|
||||
e.which = 90; // z
|
||||
inner$('#innerdocbody').trigger(e); // shouldn't od anything
|
||||
// does the first div include an author class?
|
||||
let hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||
expect(hasAuthorClass).to.be(false);
|
||||
|
||||
// does the first div include an author class?
|
||||
hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||
expect(hasAuthorClass).to.be(false);
|
||||
const e = new inner$.Event(helper.evtType);
|
||||
e.ctrlKey = true; // Control key
|
||||
e.which = 90; // z
|
||||
inner$('#innerdocbody').trigger(e); // shouldn't od anything
|
||||
|
||||
// get undo and redo buttons
|
||||
const $undoButton = chrome$('.buttonicon-undo');
|
||||
// does the first div include an author class?
|
||||
hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||
expect(hasAuthorClass).to.be(false);
|
||||
|
||||
// click the button
|
||||
$undoButton.click(); // shouldn't do anything
|
||||
hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||
expect(hasAuthorClass).to.be(false);
|
||||
// get undo and redo buttons
|
||||
const $undoButton = chrome$('.buttonicon-undo');
|
||||
|
||||
helper.waitFor(() => {
|
||||
const disconnectVisible =
|
||||
chrome$('div.disconnected').attr('class').indexOf('visible') === -1;
|
||||
return (disconnectVisible === true);
|
||||
});
|
||||
// click the button
|
||||
$undoButton.click(); // shouldn't do anything
|
||||
hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1;
|
||||
expect(hasAuthorClass).to.be(false);
|
||||
|
||||
const disconnectVisible = chrome$('div.disconnected').attr('class').indexOf('visible') === -1;
|
||||
expect(disconnectVisible).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
await helper.waitForPromise(
|
||||
() => chrome$('div.disconnected').attr('class').indexOf('visible') === -1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
describe('delete keystroke', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('makes text delete', function (done) {
|
||||
it('makes text delete', async function () {
|
||||
this.timeout(50);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -28,7 +28,5 @@ describe('delete keystroke', function () {
|
|||
|
||||
// expect it to be one char less in length
|
||||
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
|
||||
describe('drag and drop', function () {
|
||||
before(function (done) {
|
||||
helper.newPad(() => {
|
||||
createScriptWithSeveralLines(done);
|
||||
});
|
||||
before(async function () {
|
||||
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 () {
|
||||
before(function (done) {
|
||||
before(async function () {
|
||||
selectPartOfSourceLine();
|
||||
dragSelectedTextAndDropItIntoMiddleOfLine(TARGET_LINE);
|
||||
|
||||
// make sure DnD was correctly simulated
|
||||
helper.waitFor(() => {
|
||||
await helper.waitForPromise(() => {
|
||||
const $targetLine = getLine(TARGET_LINE);
|
||||
const sourceWasMovedToTarget = $targetLine.text() === 'Target line [line 1]';
|
||||
return sourceWasMovedToTarget;
|
||||
}).done(done);
|
||||
});
|
||||
});
|
||||
|
||||
context('and user triggers UNDO', function () {
|
||||
|
@ -30,7 +29,7 @@ describe('drag and drop', function () {
|
|||
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);
|
||||
// test text was removed from drop target
|
||||
const $targetLine = getLine(TARGET_LINE);
|
||||
|
@ -41,23 +40,21 @@ describe('drag and drop', function () {
|
|||
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
||||
expect($firstSourceLine.text()).to.be('Source line 1.');
|
||||
expect($lastSourceLine.text()).to.be('Source line 2.');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('when user drags some lines far form its original place', function () {
|
||||
before(function (done) {
|
||||
before(async function () {
|
||||
selectMultipleSourceLines();
|
||||
dragSelectedTextAndDropItIntoMiddleOfLine(TARGET_LINE);
|
||||
|
||||
// make sure DnD was correctly simulated
|
||||
helper.waitFor(() => {
|
||||
await helper.waitForPromise(() => {
|
||||
const $lineAfterTarget = getLine(TARGET_LINE + 1);
|
||||
const sourceWasMovedToTarget = $lineAfterTarget.text() !== '...';
|
||||
return sourceWasMovedToTarget;
|
||||
}).done(done);
|
||||
});
|
||||
});
|
||||
|
||||
context('and user triggers UNDO', function () {
|
||||
|
@ -68,7 +65,7 @@ describe('drag and drop', function () {
|
|||
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);
|
||||
// test text was removed from drop target
|
||||
const $targetLine = getLine(TARGET_LINE);
|
||||
|
@ -79,8 +76,6 @@ describe('drag and drop', function () {
|
|||
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
||||
expect($firstSourceLine.text()).to.be('Source line 1.');
|
||||
expect($lastSourceLine.text()).to.be('Source line 2.');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -94,17 +89,17 @@ describe('drag and drop', function () {
|
|||
return $lines.slice(lineNumber, lineNumber + 1);
|
||||
};
|
||||
|
||||
const createScriptWithSeveralLines = (done) => {
|
||||
const createScriptWithSeveralLines = async () => {
|
||||
// create some lines to be used on the tests
|
||||
const $firstLine = helper.padInner$('div').first();
|
||||
$firstLine.html('...<br>...<br>Target line []<br>...<br>...<br>' +
|
||||
'Source line 1.<br>Source line 2.<br>');
|
||||
|
||||
// wait for lines to be split
|
||||
helper.waitFor(() => {
|
||||
await helper.waitForPromise(() => {
|
||||
const $lastSourceLine = getLine(FIRST_SOURCE_LINE + 1);
|
||||
return $lastSourceLine.text() === 'Source line 2.';
|
||||
}).done(done);
|
||||
});
|
||||
};
|
||||
|
||||
const selectPartOfSourceLine = () => {
|
||||
|
|
|
@ -50,13 +50,13 @@ describe('embed links', function () {
|
|||
|
||||
describe('read and write', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
describe('the share link', function () {
|
||||
it('is the actual pad url', function (done) {
|
||||
it('is the actual pad url', async function () {
|
||||
this.timeout(100);
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -67,13 +67,11 @@ describe('embed links', function () {
|
|||
const shareLink = chrome$('#linkinput').val();
|
||||
const padURL = chrome$.window.location.href;
|
||||
expect(shareLink).to.be(padURL);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -84,20 +82,18 @@ describe('embed links', function () {
|
|||
const embedCode = chrome$('#embedinput').val();
|
||||
|
||||
checkiFrameCode(embedCode, false);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when read only option is set', function () {
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
describe('the share link', function () {
|
||||
it('shows a read only url', function (done) {
|
||||
it('shows a read only url', async function () {
|
||||
this.timeout(50);
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -110,13 +106,11 @@ describe('embed links', function () {
|
|||
const shareLink = chrome$('#linkinput').val();
|
||||
const containsReadOnlyLink = shareLink.indexOf('r.') > 0;
|
||||
expect(containsReadOnlyLink).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -131,8 +125,6 @@ describe('embed links', function () {
|
|||
const embedCode = chrome$('#embedinput').val();
|
||||
|
||||
checkiFrameCode(embedCode, true);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
describe('enter keystroke', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -19,14 +20,13 @@ describe('enter keystroke', function () {
|
|||
// simulate key presses to enter content
|
||||
$firstTextElement.sendkeys('{enter}');
|
||||
|
||||
helper.waitFor(() => inner$('div').first().text() === '').done(() => {
|
||||
const $newSecondLine = inner$('div').first().next();
|
||||
const newFirstTextElementValue = inner$('div').first().text();
|
||||
expect(newFirstTextElementValue).to.be(''); // expect the first line to be blank
|
||||
// expect the second line to be the same as the original first line.
|
||||
expect($newSecondLine.text()).to.be(originalTextValue);
|
||||
done();
|
||||
});
|
||||
await helper.waitForPromise(() => inner$('div').first().text() === '');
|
||||
|
||||
const $newSecondLine = inner$('div').first().next();
|
||||
const newFirstTextElementValue = inner$('div').first().text();
|
||||
expect(newFirstTextElementValue).to.be(''); // expect the first line to be blank
|
||||
// expect the second line to be the same as the original first line.
|
||||
expect($newSecondLine.text()).to.be(originalTextValue);
|
||||
});
|
||||
|
||||
it('enter is always visible after event', async function () {
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
describe('font select', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('makes text RobotoMono', function (done) {
|
||||
it('makes text RobotoMono', async function () {
|
||||
this.timeout(100);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -29,7 +29,5 @@ describe('font select', function () {
|
|||
const fontFamily = inner$('body').css('font-family').toLowerCase();
|
||||
const containsStr = fontFamily.indexOf('robotomono');
|
||||
expect(containsStr).to.not.be(-1);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,23 +2,9 @@
|
|||
|
||||
describe('the test helper', 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);
|
||||
|
||||
let times = 10;
|
||||
|
||||
const loadPad = () => {
|
||||
helper.newPad(() => {
|
||||
times--;
|
||||
if (times > 0) {
|
||||
loadPad();
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
loadPad();
|
||||
for (let i = 0; i < 10; ++i) await helper.aNewPad();
|
||||
});
|
||||
|
||||
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, ' ');
|
||||
};
|
||||
|
||||
before(function (done) {
|
||||
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);
|
||||
});
|
||||
|
||||
before(async function () {
|
||||
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 ' +
|
||||
|
@ -322,7 +307,7 @@ describe('the test helper', function () {
|
|||
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 startOffset = 2;
|
||||
|
@ -344,8 +329,6 @@ describe('the test helper', function () {
|
|||
* how I'm covering it in this test.
|
||||
*/
|
||||
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) {
|
||||
|
@ -376,7 +359,7 @@ describe('the test helper', function () {
|
|||
});
|
||||
|
||||
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 $lines = inner$('div');
|
||||
|
@ -396,8 +379,6 @@ describe('the test helper', function () {
|
|||
*/
|
||||
expect(cleanText(
|
||||
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;
|
||||
before(async function () {
|
||||
this.timeout(60000);
|
||||
await new Promise(
|
||||
(resolve, reject) => helper.newPad((err) => err != null ? reject(err) : resolve()));
|
||||
await helper.aNewPad();
|
||||
confirm = helper.padChrome$.window.confirm;
|
||||
helper.padChrome$.window.confirm = () => true;
|
||||
// As of 2021-02-22 a mutable FileList cannot be directly created so DataTransfer is used as a
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
describe('import indents functionality', function () {
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb); // creates a new pad
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
function getinnertext() {
|
||||
const getinnertext = () => {
|
||||
const inner = helper.padInner$;
|
||||
let newtext = '';
|
||||
inner('div').each((line, el) => {
|
||||
newtext += `${el.innerHTML}\n`;
|
||||
});
|
||||
return newtext;
|
||||
}
|
||||
function importrequest(data, importurl, type) {
|
||||
};
|
||||
|
||||
const importrequest = (data, importurl, type) => {
|
||||
let error;
|
||||
const result = $.ajax({
|
||||
url: importurl,
|
||||
|
@ -42,8 +43,9 @@ describe('import indents functionality', function () {
|
|||
});
|
||||
expect(error).to.be(undefined);
|
||||
return result;
|
||||
}
|
||||
function exportfunc(link) {
|
||||
};
|
||||
|
||||
const exportfunc = (link) => {
|
||||
const exportresults = [];
|
||||
$.ajaxSetup({
|
||||
async: false,
|
||||
|
@ -58,51 +60,72 @@ describe('import indents functionality', function () {
|
|||
exportresults.push(['txt', data]);
|
||||
});
|
||||
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`;
|
||||
/* eslint-disable-next-line max-len */
|
||||
const htmlWithIndents = '<html><body><ul class="list-indent1"><li>indent line 1</li><li>indent line 2</li><ul class="list-indent2"><li>indent2 line 1</li><li>indent2 line 2</li></ul></ul></body></html>';
|
||||
const htmlWithIndents =
|
||||
'<html><body><ul class="list-indent1"><li>indent line 1</li><li>indent line 2</li>' +
|
||||
'<ul class="list-indent2"><li>indent2 line 1</li><li>indent2 line 2</li></ul></ul>' +
|
||||
'</body></html>';
|
||||
importrequest(htmlWithIndents, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
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 2</span></li></ul>\n' +
|
||||
'<ul class="list-indent2"><li><span class="">indent2 line 1</span></li></ul>\n' +
|
||||
'<ul class="list-indent2"><li><span class="">indent2 line 2</span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
'<br>\n');
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[0][1]).to.be('<ul class="indent"><li>indent line 1</li><li>indent line 2</li><ul class="indent"><li>indent2 line 1</li><li>indent2 line 2</li></ul></ul><br>');
|
||||
expect(results[0][1]).to.be(
|
||||
'<ul class="indent"><li>indent line 1</li><li>indent line 2</li>' +
|
||||
'<ul class="indent"><li>indent2 line 1</li><li>indent2 line 2</li></ul></ul><br>');
|
||||
expect(results[1][1])
|
||||
.to.be('\tindent line 1\n\tindent line 2\n\t\tindent2 line 1\n\t\tindent2 line 2\n\n');
|
||||
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`;
|
||||
/* eslint-disable-next-line max-len */
|
||||
const htmlWithIndents = '<html><body><ul class="list-indent1"><li>indent line 1</li></ul><br/><ul class="list-indent1"><li>indent 1 line 2</li><ul class="list-indent2"><li>indent 2 times line 1</li></ul></ul><br/><ul class="list-indent1"><ul class="list-indent2"><li>indent 2 times line 2</li></ul></ul></body></html>';
|
||||
const htmlWithIndents =
|
||||
'<html><body><ul class="list-indent1"><li>indent line 1</li></ul><br/>' +
|
||||
'<ul class="list-indent1"><li>indent 1 line 2</li>' +
|
||||
'<ul class="list-indent2"><li>indent 2 times line 1</li></ul></ul><br/>' +
|
||||
'<ul class="list-indent1"><ul class="list-indent2"><li>indent 2 times line 2</li>' +
|
||||
'</ul></ul></body></html>';
|
||||
importrequest(htmlWithIndents, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
await helper.waitForPromise(() => getinnertext() ===
|
||||
'<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n' +
|
||||
'<br>\n' +
|
||||
'<ul class="list-indent1"><li><span class="">indent 1 line 2</span></li></ul>\n' +
|
||||
'<ul class="list-indent2"><li><span class="">indent 2 times line 1</span></li></ul>\n' +
|
||||
'<br>\n' +
|
||||
'<ul class="list-indent2"><li><span class="">indent 2 times line 2</span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
'<br>\n');
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[0][1]).to.be('<ul class="indent"><li>indent line 1</li></ul><br><ul class="indent"><li>indent 1 line 2</li><ul class="indent"><li>indent 2 times line 1</li></ul></ul><br><ul><ul class="indent"><li>indent 2 times line 2</li></ul></ul><br>');
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[1][1]).to.be('\tindent line 1\n\n\tindent 1 line 2\n\t\tindent 2 times line 1\n\n\t\tindent 2 times line 2\n\n');
|
||||
done();
|
||||
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>');
|
||||
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`;
|
||||
/* eslint-disable-next-line max-len */
|
||||
const htmlWithIndents = '<html><body><ul class="list-indent1"><li>indent line 1</li></ul><br/><ul class="list-indent1"><li>indent line 2</li><ul class="list-indent2"><li>indent2 line 1</li></ul></ul><br/><ul class="list-indent1"><ul class="list-indent2"><ul class="list-indent3"><ul class="list-indent4"><li><span class="b s i u"><b><i><s><u>indent4 line 2 bisu</u></s></i></b></span></li><li><span class="b s "><b><s>indent4 line 2 bs</s></b></span></li><li><span class="u"><u>indent4 line 2 u</u></span><span class="u i s"><i><s><u>uis</u></s></i></span></li><ul class="list-indent5"><ul class="list-indent6"><ul class="list-indent7"><ul class="list-indent8"><li><span class="">foo</span></li><li><span class="b s"><b><s>foobar bs</b></s></span></li></ul></ul></ul></ul><ul class="list-indent5"><li>foobar</li></ul></ul></ul></ul></body></html>';
|
||||
const htmlWithIndents =
|
||||
'<html><body><ul class="list-indent1"><li>indent line 1</li></ul><br/>' +
|
||||
'<ul class="list-indent1"><li>indent line 2</li>' +
|
||||
'<ul class="list-indent2"><li>indent2 line 1</li></ul></ul><br/>' +
|
||||
'<ul class="list-indent1"><ul class="list-indent2"><ul class="list-indent3">' +
|
||||
'<ul class="list-indent4"><li><span class="b s i u"><b><i><s>' +
|
||||
'<u>indent4 line 2 bisu</u></s></i></b></span></li><li><span class="b s ">' +
|
||||
'<b><s>indent4 line 2 bs</s></b></span></li><li><span class="u">' +
|
||||
'<u>indent4 line 2 u</u></span><span class="u i s"><i><s><u>uis</u></s></i></span></li>' +
|
||||
'<ul class="list-indent5"><ul class="list-indent6"><ul class="list-indent7">' +
|
||||
'<ul class="list-indent8"><li><span class="">foo</span></li><li><span class="b s">' +
|
||||
'<b><s>foobar bs</b></s></span></li></ul></ul></ul></ul><ul class="list-indent5">' +
|
||||
'<li>foobar</li></ul></ul></ul></ul></body></html>';
|
||||
importrequest(htmlWithIndents, importurl, 'html');
|
||||
helper.waitFor(() => expect(getinnertext()).to.be(
|
||||
'<ul class="list-indent1"><li><span class="">indent line 1</span></li></ul>\n<br>\n' +
|
||||
|
@ -120,10 +143,17 @@ describe('import indents functionality', function () {
|
|||
'<ul class="list-indent5"><li><span class="">foobar</span></li></ul>\n' +
|
||||
'<br>\n'));
|
||||
const results = exportfunc(helper.padChrome$.window.location.href);
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[0][1]).to.be('<ul class="indent"><li>indent line 1</li></ul><br><ul class="indent"><li>indent line 2</li><ul class="indent"><li>indent2 line 1</li></ul></ul><br><ul><ul><ul><ul class="indent"><li><strong><em><s><u>indent4 line 2 bisu</u></s></em></strong></li><li><strong><s>indent4 line 2 bs</s></strong></li><li><u>indent4 line 2 u<em><s>uis</s></em></u></li><ul><ul><ul><ul class="indent"><li>foo</li><li><strong><s>foobar bs</s></strong></li></ul></ul></ul><li>foobar</li></ul></ul></ul></ul></ul><br>');
|
||||
/* eslint-disable-next-line max-len */
|
||||
expect(results[1][1]).to.be('\tindent line 1\n\n\tindent line 2\n\t\tindent2 line 1\n\n\t\t\t\tindent4 line 2 bisu\n\t\t\t\tindent4 line 2 bs\n\t\t\t\tindent4 line 2 uuis\n\t\t\t\t\t\t\t\tfoo\n\t\t\t\t\t\t\t\tfoobar bs\n\t\t\t\t\tfoobar\n\n');
|
||||
done();
|
||||
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>');
|
||||
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 () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('indent text with keypress', function (done) {
|
||||
it('indent text with keypress', async function () {
|
||||
this.timeout(100);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -21,10 +21,10 @@ describe('indentation button', function () {
|
|||
e.keyCode = 9; // tab :|
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -32,10 +32,10 @@ describe('indentation button', function () {
|
|||
const $indentButton = chrome$('.buttonicon-indent');
|
||||
$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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -50,18 +50,17 @@ describe('indentation button', function () {
|
|||
$firstTextElement.sendkeys('line 2');
|
||||
$firstTextElement.sendkeys('{enter}');
|
||||
|
||||
helper.waitFor(() => inner$('div span').first().text().indexOf('line 2') === -1).done(() => {
|
||||
const $newSecondLine = inner$('div').first().next();
|
||||
const hasULElement = $newSecondLine.find('ul li').length === 1;
|
||||
await helper.waitFor(() => inner$('div span').first().text().indexOf('line 2') === -1);
|
||||
|
||||
expect(hasULElement).to.be(true);
|
||||
expect($newSecondLine.text()).to.be('line 2');
|
||||
done();
|
||||
});
|
||||
const $newSecondLine = inner$('div').first().next();
|
||||
const hasULElement = $newSecondLine.find('ul li').length === 1;
|
||||
|
||||
expect(hasULElement).to.be(true);
|
||||
expect($newSecondLine.text()).to.be('line 2');
|
||||
});
|
||||
|
||||
it('indents text with spaces on enter if previous line ends ' +
|
||||
"with ':', '[', '(', or '{'", function (done) {
|
||||
"with ':', '[', '(', or '{'", async function () {
|
||||
this.timeout(1200);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -72,48 +71,46 @@ describe('indentation button', function () {
|
|||
$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
|
||||
const $fourthLine = inner$('div').first().next().next().next();
|
||||
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 ' +
|
||||
"with ':', '[', '(', or '{'", function (done) {
|
||||
"with ':', '[', '(', or '{'", async function () {
|
||||
this.timeout(1200);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -122,20 +119,18 @@ describe('indentation button', function () {
|
|||
$firstTextElement.sendkeys(" line with some indentation and ':'{enter}");
|
||||
$firstTextElement.sendkeys('line 2{enter}');
|
||||
|
||||
helper.waitFor(() => {
|
||||
await helper.waitForPromise(() => {
|
||||
// wait for Etherpad to split two lines into separated divs
|
||||
const $secondLine = inner$('div').first().next();
|
||||
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 " +
|
||||
|
@ -175,97 +170,94 @@ describe('indentation button', function () {
|
|||
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
|
||||
var $inner = testHelper.$getPadInner();
|
||||
// select this text element
|
||||
helper.selectText(firstTextElement[0], $inner);
|
||||
|
||||
//get the first text element out of the inner iframe
|
||||
var firstTextElement = $inner.find("div").first();
|
||||
|
||||
//select this text element
|
||||
testHelper.selectText(firstTextElement[0], $inner);
|
||||
|
||||
//get the indentation button and click it
|
||||
var $indentButton = testHelper.$getPadChrome().find(".buttonicon-indent");
|
||||
// get the indentation button and click it
|
||||
const $indentButton = helper.$getPadChrome().find('.buttonicon-indent');
|
||||
$indentButton.click();
|
||||
|
||||
var newFirstTextElement = $inner.find("div").first();
|
||||
let newFirstTextElement = $inner.find('div').first();
|
||||
|
||||
// is there a list-indent class element now?
|
||||
var firstChild = newFirstTextElement.children(":first");
|
||||
var isUL = firstChild.is('ul');
|
||||
let firstChild = newFirstTextElement.children(':first');
|
||||
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);
|
||||
|
||||
var secondChild = firstChild.children(":first");
|
||||
var isLI = secondChild.is('li');
|
||||
//expect it to be part of a list
|
||||
let secondChild = firstChild.children(':first');
|
||||
let isLI = secondChild.is('li');
|
||||
// expect it to be part of a list
|
||||
expect(isLI).to.be(true);
|
||||
|
||||
//indent again
|
||||
// indent again
|
||||
$indentButton.click();
|
||||
|
||||
var newFirstTextElement = $inner.find("div").first();
|
||||
newFirstTextElement = $inner.find('div').first();
|
||||
|
||||
// is there a list-indent class element now?
|
||||
var firstChild = newFirstTextElement.children(":first");
|
||||
var hasListIndent2 = firstChild.hasClass('list-indent2');
|
||||
firstChild = newFirstTextElement.children(':first');
|
||||
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);
|
||||
|
||||
//make sure the text hasn't changed
|
||||
// make sure the text hasn't changed
|
||||
expect(newFirstTextElement.text()).to.eql(firstTextElement.text());
|
||||
|
||||
|
||||
// test outdent
|
||||
|
||||
//get the unindentation button and click it twice
|
||||
var $outdentButton = testHelper.$getPadChrome().find(".buttonicon-outdent");
|
||||
// get the unindentation button and click it twice
|
||||
const $outdentButton = helper.$getPadChrome().find('.buttonicon-outdent');
|
||||
$outdentButton.click();
|
||||
$outdentButton.click();
|
||||
|
||||
var newFirstTextElement = $inner.find("div").first();
|
||||
newFirstTextElement = $inner.find('div').first();
|
||||
|
||||
// is there a list-indent class element now?
|
||||
var firstChild = newFirstTextElement.children(":first");
|
||||
var isUL = firstChild.is('ul');
|
||||
firstChild = newFirstTextElement.children(':first');
|
||||
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);
|
||||
|
||||
var secondChild = firstChild.children(":first");
|
||||
var isLI = secondChild.is('li');
|
||||
//expect it to not be part of a list
|
||||
secondChild = firstChild.children(':first');
|
||||
isLI = secondChild.is('li');
|
||||
// expect it to not be part of a list
|
||||
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());
|
||||
|
||||
|
||||
// Next test tests multiple line indentation
|
||||
|
||||
//select this text element
|
||||
testHelper.selectText(firstTextElement[0], $inner);
|
||||
// select this text element
|
||||
helper.selectText(firstTextElement[0], $inner);
|
||||
|
||||
//indent twice
|
||||
// indent twice
|
||||
$indentButton.click();
|
||||
$indentButton.click();
|
||||
|
||||
//get the first text element out of the inner iframe
|
||||
var firstTextElement = $inner.find("div").first();
|
||||
// get the first text element out of the inner iframe
|
||||
firstTextElement = $inner.find('div').first();
|
||||
|
||||
//select this text element
|
||||
testHelper.selectText(firstTextElement[0], $inner);
|
||||
// select this text element
|
||||
helper.selectText(firstTextElement[0], $inner);
|
||||
|
||||
/* this test creates the below content, both should have double indentation
|
||||
line1
|
||||
line2
|
||||
|
||||
*/
|
||||
|
||||
firstTextElement.sendkeys('{rightarrow}'); // 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('line 2'); // simulate writing the second line
|
||||
|
||||
//get the second text element out of the inner iframe
|
||||
setTimeout(function(){ // THIS IS REALLY BAD
|
||||
var secondTextElement = $('iframe').contents()
|
||||
.find('iframe').contents()
|
||||
.find('iframe').contents().find('body > div').get(1); // THIS IS UGLY
|
||||
// get the second text element out of the inner iframe
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000)); // THIS IS REALLY BAD
|
||||
|
||||
// is there a list-indent class element now?
|
||||
var firstChild = secondTextElement.children(":first");
|
||||
var isUL = firstChild.is('ul');
|
||||
const secondTextElement = $('iframe').contents()
|
||||
.find('iframe').contents()
|
||||
.find('iframe').contents().find('body > div').get(1); // THIS IS UGLY
|
||||
|
||||
//expect it to be the beginning of a list
|
||||
expect(isUL).to.be(true);
|
||||
// is there a list-indent class element now?
|
||||
firstChild = secondTextElement.children(':first');
|
||||
isUL = firstChild.is('ul');
|
||||
|
||||
var secondChild = secondChild.children(":first");
|
||||
var isLI = secondChild.is('li');
|
||||
//expect it to be part of a list
|
||||
expect(isLI).to.be(true);
|
||||
// expect it to be the beginning of a list
|
||||
expect(isUL).to.be(true);
|
||||
|
||||
//get the first text element out of the inner iframe
|
||||
var thirdTextElement = $('iframe').contents()
|
||||
.find('iframe').contents()
|
||||
.find('iframe').contents()
|
||||
.find('body > div').get(2); // THIS IS UGLY TOO
|
||||
secondChild = secondChild.children(':first');
|
||||
isLI = secondChild.is('li');
|
||||
// expect it to be part of a list
|
||||
expect(isLI).to.be(true);
|
||||
|
||||
// is there a list-indent class element now?
|
||||
var firstChild = thirdTextElement.children(":first");
|
||||
var isUL = firstChild.is('ul');
|
||||
// get the first text element out of the inner iframe
|
||||
const thirdTextElement = $('iframe').contents()
|
||||
.find('iframe').contents()
|
||||
.find('iframe').contents()
|
||||
.find('body > div').get(2); // THIS IS UGLY TOO
|
||||
|
||||
//expect it to be the beginning of a list
|
||||
expect(isUL).to.be(true);
|
||||
// is there a list-indent class element now?
|
||||
firstChild = thirdTextElement.children(':first');
|
||||
isUL = firstChild.is('ul');
|
||||
|
||||
var secondChild = firstChild.children(":first");
|
||||
var isLI = secondChild.is('li');
|
||||
// expect it to be the beginning of a list
|
||||
expect(isUL).to.be(true);
|
||||
|
||||
//expect it to be part of a list
|
||||
expect(isLI).to.be(true);
|
||||
},1000);
|
||||
});*/
|
||||
secondChild = firstChild.children(':first');
|
||||
isLI = secondChild.is('li');
|
||||
|
||||
// expect it to be part of a list
|
||||
expect(isLI).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
const pressEnter = () => {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
describe('height regression after ace.js refactoring', function () {
|
||||
before(function (cb) {
|
||||
helper.newPad(cb);
|
||||
before(async function () {
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
// 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 clientHeight = aceOuter.documentElement.clientHeight;
|
||||
const scrollHeight = aceOuter.documentElement.scrollHeight;
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
describe('italic some text', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -33,11 +33,9 @@ describe('italic some text', function () {
|
|||
|
||||
// make sure the text hasn't changed
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -63,7 +61,5 @@ describe('italic some text', function () {
|
|||
|
||||
// make sure the text hasn't changed
|
||||
expect($newFirstTextElement.text()).to.eql($firstTextElement.text());
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,13 +5,13 @@ describe('Language select and change', function () {
|
|||
window.Cookies.remove('language');
|
||||
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
// Destroy language cookies
|
||||
it('makes text german', function (done) {
|
||||
it('makes text german', async function () {
|
||||
this.timeout(1000);
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -27,21 +27,20 @@ describe('Language select and change', function () {
|
|||
$languageoption.attr('selected', 'selected');
|
||||
$language.change();
|
||||
|
||||
helper.waitFor(() => chrome$('.buttonicon-bold').parent()[0].title === 'Fett (Strg-B)')
|
||||
.done(() => {
|
||||
// get the value of the bold button
|
||||
const $boldButton = chrome$('.buttonicon-bold').parent();
|
||||
await helper.waitForPromise(
|
||||
() => chrome$('.buttonicon-bold').parent()[0].title === 'Fett (Strg-B)');
|
||||
|
||||
// get the title of the bold button
|
||||
const boldButtonTitle = $boldButton[0].title;
|
||||
// get the value of the bold button
|
||||
const $boldButton = chrome$('.buttonicon-bold').parent();
|
||||
|
||||
// check if the language is now german
|
||||
expect(boldButtonTitle).to.be('Fett (Strg-B)');
|
||||
done();
|
||||
});
|
||||
// get the title of the bold button
|
||||
const boldButtonTitle = $boldButton[0].title;
|
||||
|
||||
// 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);
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -56,23 +55,21 @@ describe('Language select and change', function () {
|
|||
$language.change();
|
||||
|
||||
// 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)')
|
||||
.done(() => {
|
||||
// get the value of the bold button
|
||||
const $boldButton = chrome$('.buttonicon-bold').parent();
|
||||
await helper.waitForPromise(() => $boldButton[0].title !== 'Fett (Strg+B)');
|
||||
|
||||
// get the title of the bold button
|
||||
const boldButtonTitle = $boldButton[0].title;
|
||||
// get the value of the bold button
|
||||
$boldButton = chrome$('.buttonicon-bold').parent();
|
||||
|
||||
// check if the language is now English
|
||||
expect(boldButtonTitle).to.be('Bold (Ctrl+B)');
|
||||
done();
|
||||
});
|
||||
// get the title of the bold button
|
||||
const boldButtonTitle = $boldButton[0].title;
|
||||
|
||||
// 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);
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -89,15 +86,13 @@ describe('Language select and change', function () {
|
|||
$language.val('ar');
|
||||
$languageoption.change();
|
||||
|
||||
helper.waitFor(() => chrome$('html')[0].dir !== 'ltr')
|
||||
.done(() => {
|
||||
// check if the document's direction was changed
|
||||
expect(chrome$('html')[0].dir).to.be('rtl');
|
||||
done();
|
||||
});
|
||||
await helper.waitForPromise(() => chrome$('html')[0].dir !== 'ltr');
|
||||
|
||||
// check if the document's direction was changed
|
||||
expect(chrome$('html')[0].dir).to.be('rtl');
|
||||
});
|
||||
|
||||
it('changes direction when picking an ltr lang', function (done) {
|
||||
it('changes direction when picking an ltr lang', async function () {
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
// click on the settings button to make settings visible
|
||||
|
@ -114,11 +109,9 @@ describe('Language select and change', function () {
|
|||
$language.val('en');
|
||||
$languageoption.change();
|
||||
|
||||
helper.waitFor(() => chrome$('html')[0].dir !== 'rtl')
|
||||
.done(() => {
|
||||
// check if the document's direction was changed
|
||||
expect(chrome$('html')[0].dir).to.be('ltr');
|
||||
done();
|
||||
});
|
||||
await helper.waitForPromise(() => chrome$('html')[0].dir !== 'rtl');
|
||||
|
||||
// check if the document's direction was changed
|
||||
expect(chrome$('html')[0].dir).to.be('ltr');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
describe('ordered_list.js', function () {
|
||||
describe('assign ordered list', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('inserts ordered list text', function (done) {
|
||||
it('inserts ordered list text', async function () {
|
||||
this.timeout(200);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -16,7 +16,7 @@ describe('ordered_list.js', function () {
|
|||
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
||||
$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 () {
|
||||
|
@ -28,10 +28,10 @@ describe('ordered_list.js', function () {
|
|||
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
|
||||
});
|
||||
|
||||
it('inserts unordered list', function (done) {
|
||||
it('inserts unordered list', async function () {
|
||||
this.timeout(50);
|
||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
||||
.done(done);
|
||||
await helper.waitForPromise(
|
||||
() => 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);
|
||||
});
|
||||
|
||||
it('does not insert unordered list', function (done) {
|
||||
it('does not insert unordered list', async function () {
|
||||
this.timeout(3000);
|
||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
||||
.done(() => {
|
||||
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
||||
})
|
||||
.fail(() => {
|
||||
done();
|
||||
});
|
||||
try {
|
||||
await helper.waitForPromise(
|
||||
() => helper.padInner$('div').first().find('ol li').length === 1);
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
});
|
||||
|
||||
it('inserts unordered list', function (done) {
|
||||
it('inserts unordered list', async function () {
|
||||
this.timeout(200);
|
||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
||||
.done(done);
|
||||
helper.waitForPromise(() => helper.padInner$('div').first().find('ol li').length === 1);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -100,20 +99,20 @@ describe('ordered_list.js', function () {
|
|||
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);
|
||||
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
|
||||
.done(() => {
|
||||
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
||||
})
|
||||
.fail(() => {
|
||||
done();
|
||||
});
|
||||
try {
|
||||
await helper.waitForPromise(
|
||||
() => helper.padInner$('div').first().find('ol li').length === 1);
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -125,10 +124,9 @@ describe('ordered_list.js', function () {
|
|||
$secondLine.sendkeys('{selectall}');
|
||||
$insertorderedlistButton.click();
|
||||
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
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -143,16 +141,15 @@ describe('ordered_list.js', function () {
|
|||
$firstTextElement.sendkeys('line 2');
|
||||
$firstTextElement.sendkeys('{enter}');
|
||||
|
||||
helper.waitFor(() => inner$('div span').first().text().indexOf('line 2') === -1).done(() => {
|
||||
const $newSecondLine = inner$('div').first().next();
|
||||
const hasOLElement = $newSecondLine.find('ol li').length === 1;
|
||||
expect(hasOLElement).to.be(true);
|
||||
expect($newSecondLine.text()).to.be('line 2');
|
||||
const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2;
|
||||
// This doesn't work because pasting in content doesn't work
|
||||
expect(hasLineNumber).to.be(true);
|
||||
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;
|
||||
expect(hasOLElement).to.be(true);
|
||||
expect($newSecondLine.text()).to.be('line 2');
|
||||
const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2;
|
||||
// This doesn't work because pasting in content doesn't work
|
||||
expect(hasLineNumber).to.be(true);
|
||||
});
|
||||
|
||||
const triggerCtrlShiftShortcut = (shortcutChar) => {
|
||||
|
@ -174,12 +171,12 @@ describe('ordered_list.js', function () {
|
|||
|
||||
describe('Pressing Tab in an OL increases and decreases indentation', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -202,7 +199,7 @@ describe('ordered_list.js', function () {
|
|||
e.keyCode = 9; // tab
|
||||
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 ' +
|
||||
'decreases indentation and bullet / ol formatting', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -237,7 +234,7 @@ describe('ordered_list.js', function () {
|
|||
const $outdentButton = chrome$('.buttonicon-outdent');
|
||||
$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 () {
|
||||
const MODAL_SELECTOR = '#connectivity';
|
||||
|
||||
beforeEach(function (done) {
|
||||
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);
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
expect(isEditorDisabled()).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
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);
|
||||
clickOnPadInner();
|
||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||
const modalIsVisible = $modal.hasClass('popup-show');
|
||||
|
||||
expect(modalIsVisible).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
clickOnPadOuter();
|
||||
const $modal = helper.padChrome$(MODAL_SELECTOR);
|
||||
const modalIsVisible = $modal.hasClass('popup-show');
|
||||
|
||||
expect(modalIsVisible).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -55,20 +48,17 @@ describe('Pad modal', function () {
|
|||
context('when modal is not an error message', function () {
|
||||
const MODAL_SELECTOR = '#settings';
|
||||
|
||||
beforeEach(function (done) {
|
||||
helper.newPad(() => {
|
||||
openSettingsAndWaitForModalToBeVisible(done);
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
await openSettingsAndWaitForModalToBeVisible();
|
||||
});
|
||||
|
||||
// This test breaks safari testing
|
||||
/*
|
||||
it('does not disable editor', function(done) {
|
||||
xit('does not disable editor', async function () {
|
||||
expect(isEditorDisabled()).to.be(false);
|
||||
done();
|
||||
});
|
||||
*/
|
||||
|
||||
context('and user clicks on editor', function () {
|
||||
it('closes the modal', async function () {
|
||||
this.timeout(200);
|
||||
|
@ -96,12 +86,12 @@ describe('Pad modal', function () {
|
|||
$lineNumbersColumn.click();
|
||||
};
|
||||
|
||||
const openSettingsAndWaitForModalToBeVisible = (done) => {
|
||||
const openSettingsAndWaitForModalToBeVisible = async () => {
|
||||
helper.padChrome$('.buttonicon-settings').click();
|
||||
|
||||
// wait for modal to be displayed
|
||||
const modalSelector = '#settings';
|
||||
helper.waitFor(() => isModalOpened(modalSelector), 10000).done(done);
|
||||
await helper.waitForPromise(() => isModalOpened(modalSelector), 10000);
|
||||
};
|
||||
|
||||
const isEditorDisabled = () => {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
describe('undo button then redo button', function () {
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb); // creates a new pad
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -27,14 +27,12 @@ describe('undo button then redo button', function () {
|
|||
$undoButton.click(); // removes foo
|
||||
$redoButton.click(); // resends foo
|
||||
|
||||
helper.waitFor(() => inner$('div span').first().text() === newString).done(() => {
|
||||
const finalValue = inner$('div').first().text();
|
||||
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
||||
done();
|
||||
});
|
||||
await helper.waitForPromise(() => inner$('div span').first().text() === newString);
|
||||
const finalValue = inner$('div').first().text();
|
||||
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
||||
});
|
||||
|
||||
it('redo some typing with keypress', function (done) {
|
||||
it('redo some typing with keypress', async function () {
|
||||
this.timeout(200);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -57,10 +55,8 @@ describe('undo button then redo button', function () {
|
|||
e.which = 121; // y
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
|
||||
helper.waitFor(() => inner$('div span').first().text() === newString).done(() => {
|
||||
const finalValue = inner$('div').first().text();
|
||||
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
||||
done();
|
||||
});
|
||||
await helper.waitForPromise(() => inner$('div span').first().text() === newString);
|
||||
const finalValue = inner$('div').first().text();
|
||||
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,17 +20,18 @@
|
|||
|
||||
xdescribe('Responsiveness of Editor', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(6000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
// JM commented out on 8th Sep 2020 for a release, after release this needs uncommenting
|
||||
// And the test needs to be fixed to work in Firefox 52 on Windows 7.
|
||||
// I am not sure why it fails on this specific platform
|
||||
// The errors show this.timeout... then crash the browser but
|
||||
// I am sure something is actually causing the stack trace and
|
||||
// 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
|
||||
if (window.bowser &&
|
||||
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
|
||||
|
||||
// Wait for the new contents to be on the pad
|
||||
helper.waitFor(() => inner$('div').text().length > length).done(() => {
|
||||
// has the text changed?
|
||||
expect(inner$('div').text().length).to.be.greaterThan(length);
|
||||
const start = Date.now(); // get the start time
|
||||
await helper.waitForPromise(() => inner$('div').text().length > length, 10000);
|
||||
|
||||
// send some new text to the screen (ensure all 3 key events are sent)
|
||||
const el = inner$('div').first();
|
||||
for (let i = 0; i < keysToSend.length; ++i) {
|
||||
const x = keysToSend.charCodeAt(i);
|
||||
['keyup', 'keypress', 'keydown'].forEach((type) => {
|
||||
const e = new $.Event(type);
|
||||
e.keyCode = x;
|
||||
el.trigger(e);
|
||||
});
|
||||
}
|
||||
// has the text changed?
|
||||
expect(inner$('div').text().length).to.be.greaterThan(length);
|
||||
const start = Date.now(); // get the start time
|
||||
|
||||
helper.waitFor(() => { // Wait for the ability to process
|
||||
const el = inner$('body');
|
||||
if (el[0].textContent.length > amount) return true;
|
||||
}).done(() => {
|
||||
const end = Date.now(); // get the current time
|
||||
const delay = end - start; // get the delay as the current time minus the start time
|
||||
// send some new text to the screen (ensure all 3 key events are sent)
|
||||
const el = inner$('div').first();
|
||||
for (let i = 0; i < keysToSend.length; ++i) {
|
||||
const x = keysToSend.charCodeAt(i);
|
||||
['keyup', 'keypress', 'keydown'].forEach((type) => {
|
||||
const e = new $.Event(type);
|
||||
e.keyCode = x;
|
||||
el.trigger(e);
|
||||
});
|
||||
}
|
||||
|
||||
expect(delay).to.be.below(600);
|
||||
done();
|
||||
}, 5000);
|
||||
}, 10000);
|
||||
await helper.waitForPromise(() => { // Wait for the ability to process
|
||||
const el = inner$('body');
|
||||
if (el[0].textContent.length > amount) return true;
|
||||
}, 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
|
||||
before(async function () {
|
||||
this.timeout(60000);
|
||||
await new Promise((resolve, reject) => helper.newPad({
|
||||
cb: (err) => (err != null) ? reject(err) : resolve(),
|
||||
hash: 'L4',
|
||||
}));
|
||||
await helper.aNewPad({hash: 'L4'});
|
||||
});
|
||||
|
||||
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
|
||||
before(async function () {
|
||||
this.timeout(60000);
|
||||
await new Promise((resolve, reject) => helper.newPad({
|
||||
cb: (err) => (err != null) ? reject(err) : resolve(),
|
||||
hash: '#DEEZ123123NUTS',
|
||||
}));
|
||||
await helper.aNewPad({hash: '#DEEZ123123NUTS'});
|
||||
});
|
||||
|
||||
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 FIRST_LINE = 0;
|
||||
|
||||
before(function (cb) {
|
||||
helper.newPad(cb);
|
||||
before(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
const applyStyleOnLine = function (style, line) {
|
||||
|
@ -43,45 +43,42 @@ describe('select formatting buttons when selection has style applied', function
|
|||
};
|
||||
|
||||
const testIfFormattingButtonIsDeselected = function (style) {
|
||||
it(`deselects the ${style} button`, function (done) {
|
||||
it(`deselects the ${style} button`, async function () {
|
||||
this.timeout(100);
|
||||
helper.waitFor(() => isButtonSelected(style) === false).done(done);
|
||||
await helper.waitForPromise(() => !isButtonSelected(style));
|
||||
});
|
||||
};
|
||||
|
||||
const testIfFormattingButtonIsSelected = function (style) {
|
||||
it(`selects the ${style} button`, function (done) {
|
||||
it(`selects the ${style} button`, async function () {
|
||||
this.timeout(100);
|
||||
helper.waitFor(() => isButtonSelected(style)).done(done);
|
||||
await helper.waitForPromise(() => isButtonSelected(style));
|
||||
});
|
||||
};
|
||||
|
||||
const applyStyleOnLineAndSelectIt = function (line, style, cb) {
|
||||
applyStyleOnLineOnFullLineAndRemoveSelection(line, style, selectLine, cb);
|
||||
const applyStyleOnLineAndSelectIt = async function (line, style) {
|
||||
await applyStyleOnLineOnFullLineAndRemoveSelection(line, style, selectLine);
|
||||
};
|
||||
|
||||
const applyStyleOnLineAndPlaceCaretOnit = function (line, style, cb) {
|
||||
applyStyleOnLineOnFullLineAndRemoveSelection(line, style, placeCaretOnLine, cb);
|
||||
const applyStyleOnLineAndPlaceCaretOnit = async function (line, style) {
|
||||
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
|
||||
const inner$ = helper.padInner$;
|
||||
const oldLineHTML = inner$.find('div')[line];
|
||||
applyStyleOnLine(style, line);
|
||||
|
||||
helper.waitFor(() => {
|
||||
await helper.waitForPromise(() => {
|
||||
const lineHTML = inner$.find('div')[line];
|
||||
return lineHTML !== oldLineHTML;
|
||||
});
|
||||
// remove selection from previous line
|
||||
selectLine(line + 1);
|
||||
// setTimeout(function() {
|
||||
// select the text or place the caret on a position that
|
||||
// has the formatting text applied previously
|
||||
selectTarget(line);
|
||||
cb();
|
||||
// }, 1000);
|
||||
};
|
||||
|
||||
const pressFormattingShortcutOnSelection = async function (key) {
|
||||
|
@ -103,9 +100,9 @@ describe('select formatting buttons when selection has style applied', function
|
|||
|
||||
STYLES.forEach((style) => {
|
||||
context(`when selection is in a text with ${style} applied`, function () {
|
||||
before(function (done) {
|
||||
before(async function () {
|
||||
this.timeout(4000);
|
||||
applyStyleOnLineAndSelectIt(FIRST_LINE, style, done);
|
||||
await applyStyleOnLineAndSelectIt(FIRST_LINE, style);
|
||||
});
|
||||
|
||||
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 () {
|
||||
before(function (done) {
|
||||
before(async function () {
|
||||
this.timeout(4000);
|
||||
applyStyleOnLineAndPlaceCaretOnit(FIRST_LINE, style, done);
|
||||
await applyStyleOnLineAndPlaceCaretOnit(FIRST_LINE, style);
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
describe('strikethrough button', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
this.timeout(60000);
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
it('makes text strikethrough', function (done) {
|
||||
it('makes text strikethrough', async function () {
|
||||
this.timeout(100);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -33,7 +33,5 @@ describe('strikethrough button', function () {
|
|||
|
||||
// make sure the text hasn't changed
|
||||
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
|
||||
xdescribe('timeslider button takes you to the timeslider of a pad', function () {
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb); // creates a new pad
|
||||
beforeEach(async function () {
|
||||
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 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
|
||||
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
|
||||
|
||||
helper.waitFor(() => modifiedValue !== originalValue // The value has changed so we can..
|
||||
).done(() => {
|
||||
const $timesliderButton = chrome$('#timesliderlink');
|
||||
$timesliderButton.click(); // So click the timeslider link
|
||||
// The value has changed so we can..
|
||||
await helper.waitForPromise(() => modifiedValue !== originalValue);
|
||||
|
||||
helper.waitFor(() => {
|
||||
const iFrameURL = chrome$.window.location.href;
|
||||
if (iFrameURL) {
|
||||
return iFrameURL.indexOf('timeslider') !== -1;
|
||||
} else {
|
||||
return false; // the URL hasnt been set yet
|
||||
}
|
||||
}).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
|
||||
done();
|
||||
});
|
||||
const $timesliderButton = chrome$('#timesliderlink');
|
||||
$timesliderButton.click(); // So click the timeslider link
|
||||
|
||||
await helper.waitForPromise(() => {
|
||||
const iFrameURL = chrome$.window.location.href;
|
||||
if (iFrameURL) {
|
||||
return iFrameURL.indexOf('timeslider') !== -1;
|
||||
} else {
|
||||
return false; // the URL hasnt been set yet
|
||||
}
|
||||
});
|
||||
|
||||
// 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 () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
// TODO needs test if content is also followed, when user a makes edits
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
describe('timeslider', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,8 +4,8 @@ describe('timeslider', function () {
|
|||
const padId = 735773577357 + (Math.round(Math.random() * 1000));
|
||||
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb, padId);
|
||||
beforeEach(async function () {
|
||||
await helper.aNewPad({id: padId});
|
||||
});
|
||||
|
||||
it('Makes sure the export URIs are as expected when the padID is numeric', async function () {
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
describe('timeslider', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -17,58 +17,54 @@ describe('timeslider', function () {
|
|||
const revs = 99;
|
||||
this.timeout(revs * timePerRev + 10000);
|
||||
for (let i = 0; i < revs; i++) {
|
||||
setTimeout(() => {
|
||||
// enter 'a' in the first text element
|
||||
inner$('div').first().sendkeys('a');
|
||||
}, timePerRev * i);
|
||||
await new Promise((resolve) => setTimeout(resolve, timePerRev));
|
||||
// enter 'a' in the first text element
|
||||
inner$('div').first().sendkeys('a');
|
||||
}
|
||||
chrome$('.buttonicon-savedRevision').click();
|
||||
|
||||
setTimeout(() => {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe').attr('src',
|
||||
`${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
|
||||
setTimeout(() => {
|
||||
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
const $sliderBar = timeslider$('#ui-slider-bar');
|
||||
await new Promise((resolve) => setTimeout(resolve, 6000));
|
||||
|
||||
const latestContents = timeslider$('#innerdocbody').text();
|
||||
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
const $sliderBar = timeslider$('#ui-slider-bar');
|
||||
|
||||
// Click somewhere on the timeslider
|
||||
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);
|
||||
const latestContents = timeslider$('#innerdocbody').text();
|
||||
|
||||
e = new jQuery.Event('mousedown');
|
||||
e.clientX = e.pageX = 150;
|
||||
e.clientY = e.pageY = base;
|
||||
$sliderBar.trigger(e);
|
||||
// Click somewhere on the timeslider
|
||||
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');
|
||||
e.clientX = e.pageX = 150;
|
||||
e.clientY = e.pageY = base - 5;
|
||||
$sliderBar.trigger(e);
|
||||
e = new jQuery.Event('mousedown');
|
||||
e.clientX = e.pageX = 150;
|
||||
e.clientY = e.pageY = base;
|
||||
$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(() => {
|
||||
// make sure the text has changed
|
||||
expect(timeslider$('#innerdocbody').text()).not.to.eql(latestContents);
|
||||
const starIsVisible = timeslider$('.star').is(':visible');
|
||||
expect(starIsVisible).to.eql(true);
|
||||
done();
|
||||
}, 1000);
|
||||
}, 6000);
|
||||
}, revs * timePerRev);
|
||||
$sliderBar.trigger('mouseup');
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
|
||||
// make sure the text has changed
|
||||
expect(timeslider$('#innerdocbody').text()).not.to.eql(latestContents);
|
||||
const starIsVisible = timeslider$('.star').is(':visible');
|
||||
expect(starIsVisible).to.eql(true);
|
||||
});
|
||||
|
||||
|
||||
// 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$;
|
||||
|
||||
// make some changes to produce 7 revisions
|
||||
|
@ -76,110 +72,94 @@ describe('timeslider', function () {
|
|||
const revs = 20;
|
||||
this.timeout(revs * timePerRev + 10000);
|
||||
for (let i = 0; i < revs; i++) {
|
||||
setTimeout(() => {
|
||||
// enter 'a' in the first text element
|
||||
inner$('div').first().sendkeys('a');
|
||||
}, timePerRev * i);
|
||||
await new Promise((resolve) => setTimeout(resolve, timePerRev));
|
||||
// enter 'a' in the first text element
|
||||
inner$('div').first().sendkeys('a');
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe').attr('src',
|
||||
`${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
|
||||
setTimeout(() => {
|
||||
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
const $sliderBar = timeslider$('#ui-slider-bar');
|
||||
await new Promise((resolve) => setTimeout(resolve, 6000));
|
||||
|
||||
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 e = new jQuery.Event('mousedown');
|
||||
e.clientX = e.pageX = 150;
|
||||
e.clientY = e.pageY = 60;
|
||||
$sliderBar.trigger(e);
|
||||
const oldUrl = $('#iframe-container iframe')[0].contentWindow.location.hash;
|
||||
|
||||
helper.waitFor(
|
||||
() => $('#iframe-container iframe')[0].contentWindow.location.hash !== oldUrl, 6000)
|
||||
.always(() => {
|
||||
expect(
|
||||
$('#iframe-container iframe')[0].contentWindow.location.hash
|
||||
).not.to.eql(oldUrl);
|
||||
done();
|
||||
});
|
||||
}, 6000);
|
||||
}, revs * timePerRev);
|
||||
// Click somewhere on the timeslider
|
||||
const e = new jQuery.Event('mousedown');
|
||||
e.clientX = e.pageX = 150;
|
||||
e.clientY = e.pageY = 60;
|
||||
$sliderBar.trigger(e);
|
||||
|
||||
await helper.waitForPromise(
|
||||
() => $('#iframe-container iframe')[0].contentWindow.location.hash !== oldUrl, 6000);
|
||||
});
|
||||
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$;
|
||||
this.timeout(40000);
|
||||
|
||||
// wait for the text to be loaded
|
||||
helper.waitFor(() => inner$('body').text().length !== 0, 10000).always(() => {
|
||||
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$;
|
||||
await helper.waitForPromise(() => inner$('body').text().length !== 0, 10000);
|
||||
|
||||
// wait for our additional revision to be added
|
||||
helper.waitFor(() => {
|
||||
// newLines takes the new lines into account which are strippen when using
|
||||
// inner$('body').text(), one <div> is used for one line in ACE.
|
||||
const lenOkay = inner$('body').text().length + newLines / 2 !== oldLength;
|
||||
// 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`);
|
||||
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 the timeslider to be loaded
|
||||
helper.waitFor(() => {
|
||||
try {
|
||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
} catch (e) {
|
||||
// Empty catch block <3
|
||||
}
|
||||
if (timeslider$) {
|
||||
return timeslider$('#innerdocbody').text().length === oldLength;
|
||||
}
|
||||
}, 10000).always(() => {
|
||||
expect(timeslider$('#innerdocbody').text().length).to.eql(oldLength);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
// wait for our additional revision to be added
|
||||
await helper.waitForPromise(() => {
|
||||
// newLines takes the new lines into account which are strippen when using
|
||||
// inner$('body').text(), one <div> is used for one line in ACE.
|
||||
const lenOkay = inner$('body').text().length + newLines / 2 !== oldLength;
|
||||
// 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);
|
||||
|
||||
// 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
|
||||
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$;
|
||||
this.timeout(11000);
|
||||
inner$('div').first().sendkeys('a');
|
||||
|
||||
setTimeout(() => {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe').attr('src',
|
||||
`${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
let timeslider$;
|
||||
let exportLink;
|
||||
await new Promise((resolve) => setTimeout(resolve, 2500));
|
||||
|
||||
helper.waitFor(() => {
|
||||
try {
|
||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
} catch (e) {
|
||||
// Empty catch block <3
|
||||
}
|
||||
if (!timeslider$) return false;
|
||||
exportLink = timeslider$('#exportplaina').attr('href');
|
||||
if (!exportLink) return false;
|
||||
return exportLink.substr(exportLink.length - 12) === '0/export/txt';
|
||||
}, 6000).always(() => {
|
||||
expect(exportLink.substr(exportLink.length - 12)).to.eql('0/export/txt');
|
||||
done();
|
||||
});
|
||||
}, 2500);
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
let timeslider$;
|
||||
let exportLink;
|
||||
|
||||
await helper.waitForPromise(() => {
|
||||
try {
|
||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
} catch (e) {
|
||||
// Empty catch block <3
|
||||
}
|
||||
if (!timeslider$) return false;
|
||||
exportLink = timeslider$('#exportplaina').attr('href');
|
||||
if (!exportLink) return false;
|
||||
return exportLink.substr(exportLink.length - 12) === '0/export/txt';
|
||||
}, 6000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
describe('undo button', function () {
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb); // creates a new pad
|
||||
beforeEach(async function () {
|
||||
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(150);
|
||||
const inner$ = helper.padInner$;
|
||||
|
@ -25,14 +25,10 @@ describe('undo button', function () {
|
|||
// click the button
|
||||
$undoButton.click();
|
||||
|
||||
helper.waitFor(() => inner$('div span').first().text() === originalValue).done(() => {
|
||||
const finalValue = inner$('div span').first().text();
|
||||
expect(finalValue).to.be(originalValue); // expect the value to change
|
||||
done();
|
||||
});
|
||||
await helper.waitForPromise(() => inner$('div span').first().text() === originalValue);
|
||||
});
|
||||
|
||||
it('undo some typing using a keypress', function (done) {
|
||||
it('undo some typing using a keypress', async function () {
|
||||
this.timeout(150);
|
||||
const inner$ = helper.padInner$;
|
||||
|
||||
|
@ -49,10 +45,6 @@ describe('undo button', function () {
|
|||
e.which = 90; // z
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
|
||||
helper.waitFor(() => inner$('div span').first().text() === originalValue).done(() => {
|
||||
const finalValue = inner$('div span').first().text();
|
||||
expect(finalValue).to.be(originalValue); // expect the value to change
|
||||
done();
|
||||
});
|
||||
await helper.waitForPromise(() => inner$('div span').first().text() === originalValue);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
describe('unordered_list.js', function () {
|
||||
describe('assign unordered list', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -17,32 +17,25 @@ describe('unordered_list.js', function () {
|
|||
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
|
||||
$insertunorderedlistButton.click();
|
||||
|
||||
helper.waitFor(() => {
|
||||
await helper.waitForPromise(() => {
|
||||
const newText = inner$('div').first().text();
|
||||
if (newText === originalText) {
|
||||
return inner$('div').first().find('ul li').length === 1;
|
||||
}
|
||||
}).done(() => {
|
||||
// remove indentation by bullet and ensure text string remains the same
|
||||
chrome$('.buttonicon-outdent').click();
|
||||
helper.waitFor(() => {
|
||||
const newText = inner$('div').first().text();
|
||||
return (newText === originalText);
|
||||
}).done(() => {
|
||||
done();
|
||||
});
|
||||
return newText === originalText && inner$('div').first().find('ul li').length === 1;
|
||||
});
|
||||
|
||||
// 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 () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -51,34 +44,26 @@ describe('unordered_list.js', function () {
|
|||
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
|
||||
$insertunorderedlistButton.click();
|
||||
|
||||
helper.waitFor(() => {
|
||||
await helper.waitForPromise(() => {
|
||||
const newText = inner$('div').first().text();
|
||||
if (newText === originalText) {
|
||||
return inner$('div').first().find('ul li').length === 1;
|
||||
}
|
||||
}).done(() => {
|
||||
// remove indentation by bullet and ensure text string remains the same
|
||||
$insertunorderedlistButton.click();
|
||||
helper.waitFor(() => {
|
||||
const isList = inner$('div').find('ul').length === 1;
|
||||
// sohuldn't be list
|
||||
return (isList === false);
|
||||
}).done(() => {
|
||||
done();
|
||||
});
|
||||
return newText === originalText && inner$('div').first().find('ul li').length === 1;
|
||||
});
|
||||
|
||||
// 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 () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -93,24 +78,23 @@ describe('unordered_list.js', function () {
|
|||
$firstTextElement.sendkeys('line 2');
|
||||
$firstTextElement.sendkeys('{enter}');
|
||||
|
||||
helper.waitFor(() => inner$('div span').first().text().indexOf('line 2') === -1).done(() => {
|
||||
const $newSecondLine = inner$('div').first().next();
|
||||
const hasULElement = $newSecondLine.find('ul li').length === 1;
|
||||
expect(hasULElement).to.be(true);
|
||||
expect($newSecondLine.text()).to.be('line 2');
|
||||
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;
|
||||
expect(hasULElement).to.be(true);
|
||||
expect($newSecondLine.text()).to.be('line 2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Pressing Tab in an UL increases and decreases indentation', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -133,19 +117,19 @@ describe('unordered_list.js', function () {
|
|||
e.keyCode = 9; // tab
|
||||
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 ' +
|
||||
'and bullet / ol formatting', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
beforeEach(async function () {
|
||||
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);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
@ -166,7 +150,7 @@ describe('unordered_list.js', function () {
|
|||
const $outdentButton = chrome$('.buttonicon-outdent');
|
||||
$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 () {
|
||||
this.timeout(60000);
|
||||
await new Promise((resolve, reject) => helper.newPad((err) => {
|
||||
if (err != null) return reject(err);
|
||||
resolve();
|
||||
}));
|
||||
await helper.aNewPad();
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
|
|
|
@ -3,34 +3,31 @@
|
|||
describe('Automatic pad reload on Force Reconnect message', function () {
|
||||
let padId, $originalPadFrame;
|
||||
|
||||
beforeEach(function (done) {
|
||||
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);
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
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 $countDownTimer = $errorMessageModal.find('.reconnecttimer');
|
||||
|
||||
expect($countDownTimer.is(':visible')).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
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 $countDownTimer = $errorMessageModal.find('.reconnecttimer');
|
||||
const $cancelButton = $errorMessageModal.find('#cancelreconnect');
|
||||
|
||||
expect($countDownTimer.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 () {
|
||||
let padWasReloaded = false;
|
||||
|
||||
beforeEach(async function () {
|
||||
$originalPadFrame.one('load', () => {
|
||||
padWasReloaded = true;
|
||||
});
|
||||
});
|
||||
|
||||
it('reloads the pad', function (done) {
|
||||
helper.waitFor(() => padWasReloaded, 10000).done(done);
|
||||
|
||||
it('reloads the pad', async function () {
|
||||
this.timeout(10000);
|
||||
await new Promise((resolve) => $originalPadFrame.one('load', resolve));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue