tests: Wait for commit rather than sleep

This commit is contained in:
Richard Hansen 2021-04-01 03:10:18 -04:00 committed by webzwo0i
parent 2776946627
commit dd9c08d821
2 changed files with 11 additions and 19 deletions

View file

@ -17,10 +17,9 @@ describe('author of pad edition', function () {
$firstLine.html(threeLines); $firstLine.html(threeLines);
// wait for lines to be processed by Etherpad // wait for lines to be processed by Etherpad
await helper.waitForPromise(() => { await helper.waitForPromise(() => (
const $lineWithUnorderedList = getLine(LINE_WITH_UNORDERED_LIST); getLine(LINE_WITH_UNORDERED_LIST).text() === 'line with unordered list' &&
return $lineWithUnorderedList.text() === 'line with unordered list'; helper.commits.length === 1));
});
// create the unordered list // create the unordered list
const $lineWithUnorderedList = getLine(LINE_WITH_UNORDERED_LIST); const $lineWithUnorderedList = getLine(LINE_WITH_UNORDERED_LIST);
@ -29,10 +28,9 @@ describe('author of pad edition', function () {
const $insertUnorderedListButton = helper.padChrome$('.buttonicon-insertunorderedlist'); const $insertUnorderedListButton = helper.padChrome$('.buttonicon-insertunorderedlist');
$insertUnorderedListButton.click(); $insertUnorderedListButton.click();
await helper.waitForPromise(() => { await helper.waitForPromise(() => (
const $lineWithUnorderedList = getLine(LINE_WITH_UNORDERED_LIST); getLine(LINE_WITH_UNORDERED_LIST).find('ul li').length === 1 &&
return $lineWithUnorderedList.find('ul li').length === 1; helper.commits.length === 2));
});
// create the ordered list // create the ordered list
const $lineWithOrderedList = getLine(LINE_WITH_ORDERED_LIST); const $lineWithOrderedList = getLine(LINE_WITH_ORDERED_LIST);
@ -41,13 +39,9 @@ describe('author of pad edition', function () {
const $insertOrderedListButton = helper.padChrome$('.buttonicon-insertorderedlist'); const $insertOrderedListButton = helper.padChrome$('.buttonicon-insertorderedlist');
$insertOrderedListButton.click(); $insertOrderedListButton.click();
await helper.waitForPromise(() => { await helper.waitForPromise(() => (
const $lineWithOrderedList = getLine(LINE_WITH_ORDERED_LIST); getLine(LINE_WITH_ORDERED_LIST).find('ol li').length === 1 &&
return $lineWithOrderedList.find('ol li').length === 1; helper.commits.length === 3));
});
// Need a timeout here to make sure all changes were saved.
await new Promise((resolve) => setTimeout(resolve, 1000));
// Expire cookie, so author is changed after reloading the pad. // Expire cookie, so author is changed after reloading the pad.
const {Cookies} = helper.padChrome$.window.require('ep_etherpad-lite/static/js/pad_utils'); const {Cookies} = helper.padChrome$.window.require('ep_etherpad-lite/static/js/pad_utils');

View file

@ -11,10 +11,8 @@ describe('author of pad edition', function () {
$firstLine.html('Hello World'); $firstLine.html('Hello World');
// wait for lines to be processed by Etherpad // wait for lines to be processed by Etherpad
await helper.waitForPromise(() => $firstLine.text() === 'Hello World'); await helper.waitForPromise(() => (
$firstLine.text() === 'Hello World' && helper.commits.length === 1));
// Need a timeout here to make sure all changes were saved.
await new Promise((resolve) => setTimeout(resolve, 1000));
// Delete token cookie, so author is changed after reloading the pad. // Delete token cookie, so author is changed after reloading the pad.
const {Cookies} = helper.padChrome$.window.require('ep_etherpad-lite/static/js/pad_utils'); const {Cookies} = helper.padChrome$.window.require('ep_etherpad-lite/static/js/pad_utils');