From 79630c7ab6cbb00cf0a4b39af5f0b04bbe3c7c7f Mon Sep 17 00:00:00 2001 From: John McLear Date: Thu, 7 Jan 2021 20:49:48 +0000 Subject: [PATCH] linted tests --- tests/frontend/specs/pageupdown.js | 204 -------------- .../frontend/specs/pageupdownlineintegrity.js | 110 ++++---- tests/frontend/specs/pageupdownlongline.js | 190 ++++++------- .../frontend/specs/pageupdownpressandhold.js | 72 ++--- tests/frontend/specs/pageupdownshift.js | 260 +++++++++--------- tests/frontend/specs/pageupdownviewport.js | 82 +++--- 6 files changed, 357 insertions(+), 561 deletions(-) diff --git a/tests/frontend/specs/pageupdown.js b/tests/frontend/specs/pageupdown.js index 4c3047bce..b8740dbb4 100644 --- a/tests/frontend/specs/pageupdown.js +++ b/tests/frontend/specs/pageupdown.js @@ -51,207 +51,3 @@ describe('Page Up & Page Down', function () { await helper.waitForPromise(() => currentLineNumber < helper.caretLineNumber()); }); }); - -describe('Viewport based Page Up/Down', function () { - beforeEach(function (cb) { - helper.newPad({ - cb: async () => { - await helper.clearPad(); - // 200 lines - await helper.edit( - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); - cb(); - }, - }); - }); - it('page up when top is at 100 and caret is at bottom', async function () { - // by default page down when caret is at end of the document will leave it in the same place. - // viewport based pageup/down changes that - const initialLineNumber = helper.caretLineNumber(); - helper.pageDown(); - helper.padOuter$('#outerdocbody').parent().scrollTop(100); - helper.pageUp(); - await helper.waitForPromise(() => helper.caretLineNumber() < initialLineNumber); - }); - - it('page down when top is at 0 and caret is at bottom', async function () { - // by default page down when caret is at end of the document will leave it in the same place. - // viewport based pageup/down changes that - const initialLineNumber = helper.caretLineNumber(); - helper.padOuter$('#outerdocbody').parent().scrollTop(0); - await helper.waitForPromise(() => helper.padOuter$('#outerdocbody').parent().scrollTop() === 0); - helper.pageUp(); // I think this might not be right.. - helper.pageDown(); - - await helper.waitForPromise(() => (helper - .caretLineNumber() < initialLineNumber) && (helper.caretLineNumber() > 1)); - }); -}); - -describe('Shift Page Up/Down', function () { - beforeEach(function (cb) { - helper.newPad({ - cb: async () => { - await helper.clearPad(); - // 200 lines - await helper.edit( - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); - cb(); - }, - }); - }); - - it('highlights lines on shift page down and releases them on page up', async function () { - await helper.edit('xxx', 1); // caret is offset 6 - - helper.pageUp(); - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Caret'); - }); - it('highlights lines on shift pg down and maintains first selection on pg up', async function () { - await helper.edit('xxx', 1); // caret is offset 6 - - helper.pageUp(); - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - }); - - it(`Highlights from end of document on pg up - then releases them on shift pg down`, async function () { - // TODO: JM NEEDS HELP: Why isn't this working? It works if you do the same in browser.. - - await helper.waitForPromise(() => helper.caretLineNumber() >= 201); - // make sure we're at bottom - helper.pageDown({ - pressAndHold: true, - }); - await helper.waitForPromise(() => helper.caretLineNumber() >= 201); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Caret'); - throw new Error('I NEED HELPZ PLZ'); - }); - it(`highlights from end of document on pg up twice - and retains on single pg down`, async function () { - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - }); - - it(`highlights from 3rd line on page up twice - should keep highlight`, async function () { - await helper.edit('xxx', 3); // caret is offset 6 - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - }); - xit(`highlights range forward then hit page up, selStart should be prior to initial - selStart and selEnd should be the original selStart`, async function () { - // TODO: JM Needs help, need a way to just select this line but it needs direction - // {select} wont cut the mustard - // selStartFocus is internal to rep - }); - - xit(`highlights (a few lines) range forwards then hit page down, selStart should be initial - selStart and selEnd further than original selEnd`, async function () { - throw new Error('JM TO DO'); - }); - - xit(`highlights (a few lines) range backwards (rep.selFocusAtStart) then hit page up, selEnd - should be initial selStart, - selStart should be less than original selStart`, async function () { - throw new Error('JM TO DO'); - }); - - xit(`highlights (a few lines) range backwards (rep.selFocusAtStart) then hit page down, selStart - should be initial selEnd and selEnd further than original selEnd`, async function () { - throw new Error('JM TO DO'); - }); -}); - -describe('Press and Hold Page Up/Down', function () { - beforeEach(function (cb) { - helper.newPad({ - cb: async () => { - await helper.clearPad(); - // 200 lines - await helper.edit( - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); - cb(); - }, - }); - }); - it('page up press and hold to top', async function () { - // by default page down when caret is at end of the document will leave it in the same place. - // viewport based pageup/down changes that - helper.pageUp({ - pressAndHold: true, - }); - await helper.waitForPromise(() => helper.caretLineNumber() === 1); - }); - it('page down press and hold to bottom', async function () { - // by default page down when caret is at end of the document will leave it in the same place. - // viewport based pageup/down changes that - const initialLineNumber = helper.caretLineNumber(); - helper.pageDown({ - pressAndHold: true, - }); - await helper.waitForPromise(() => helper.caretLineNumber() === initialLineNumber); - }); -}); diff --git a/tests/frontend/specs/pageupdownlineintegrity.js b/tests/frontend/specs/pageupdownlineintegrity.js index 36e9aebd2..beef6e010 100755 --- a/tests/frontend/specs/pageupdownlineintegrity.js +++ b/tests/frontend/specs/pageupdownlineintegrity.js @@ -1,55 +1,55 @@ -'use strict'; - -describe('Line number integrity is kept between page up/down', function () { - beforeEach(function (cb) { - helper.newPad({ - cb: async () => { - await helper.clearPad(); - // 200 lines - await helper.edit( - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); - cb(); - }, - }); - }); - - const lineHistory = []; - - it('Page down x times, then page up and see if lines match', async function () { - // this places the caret in the first line - await helper.edit('Line 1', 1); - - const currentLineNumber = helper.caretLineNumber(); - lineHistory.push(helper.caretLineNumber()); - - helper.pageDown(); - await helper.waitForPromise(() => currentLineNumber < helper.caretLineNumber()); - lineHistory.push(helper.caretLineNumber()); - - helper.pageDown(); - await helper.waitForPromise(() => currentLineNumber < helper.caretLineNumber()); - lineHistory.push(helper.caretLineNumber()); - - helper.pageDown(); - await helper.waitForPromise(() => currentLineNumber < helper.caretLineNumber()); - - let futureLineNumber = helper.caretLineNumber(); - helper.pageUp(); - await helper.waitForPromise(() => futureLineNumber > helper.caretLineNumber()); - if (helper.caretLineNumber() !== lineHistory[lineHistory.length - 1]) { - throw new Error('Line History not being properly maintained on page up #1'); - } - lineHistory.pop(); - - futureLineNumber = helper.caretLineNumber(); - helper.pageUp(); - await helper.waitForPromise(() => futureLineNumber > helper.caretLineNumber()); - if (helper.caretLineNumber() !== lineHistory[lineHistory.length - 1]) { - throw new Error('Line History not being properly maintained on page up #2'); - } - }); -}); +'use strict'; + +describe('Line number integrity is kept between page up/down', function () { + beforeEach(function (cb) { + helper.newPad({ + cb: async () => { + await helper.clearPad(); + // 200 lines + await helper.edit( + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); + cb(); + }, + }); + }); + + const lineHistory = []; + + it('Page down x times, then page up and see if lines match', async function () { + // this places the caret in the first line + await helper.edit('Line 1', 1); + + const currentLineNumber = helper.caretLineNumber(); + lineHistory.push(helper.caretLineNumber()); + + helper.pageDown(); + await helper.waitForPromise(() => currentLineNumber < helper.caretLineNumber()); + lineHistory.push(helper.caretLineNumber()); + + helper.pageDown(); + await helper.waitForPromise(() => currentLineNumber < helper.caretLineNumber()); + lineHistory.push(helper.caretLineNumber()); + + helper.pageDown(); + await helper.waitForPromise(() => currentLineNumber < helper.caretLineNumber()); + + let futureLineNumber = helper.caretLineNumber(); + helper.pageUp(); + await helper.waitForPromise(() => futureLineNumber > helper.caretLineNumber()); + if (helper.caretLineNumber() !== lineHistory[lineHistory.length - 1]) { + throw new Error('Line History not being properly maintained on page up #1'); + } + lineHistory.pop(); + + futureLineNumber = helper.caretLineNumber(); + helper.pageUp(); + await helper.waitForPromise(() => futureLineNumber > helper.caretLineNumber()); + if (helper.caretLineNumber() !== lineHistory[lineHistory.length - 1]) { + throw new Error('Line History not being properly maintained on page up #2'); + } + }); +}); diff --git a/tests/frontend/specs/pageupdownlongline.js b/tests/frontend/specs/pageupdownlongline.js index 345477227..958673244 100755 --- a/tests/frontend/specs/pageupdownlongline.js +++ b/tests/frontend/specs/pageupdownlongline.js @@ -1,95 +1,95 @@ -'use strict'; - -describe(`Really long text line goes to character within text line if text line is last - line in viewport if the second line is also incredibly long`, function () { - beforeEach(function (cb) { - helper.newPad({ - cb: async () => { - await helper.clearPad(); - // 200 lines - await helper.edit( - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world\n ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - 'hello world hello world hello world hello world hello world hello world hello world ' + - '\n\n\n\n\n\n\n\n\n '); - cb(); - }, - }); - }); - - it('Pg down on long line keeps char on the same line but with large X offset', async function () { - await helper.edit('xxx', 1); // caret is offset 6 - await helper.waitForPromise(() => { - if ((helper.padInner$.document.getSelection().anchorOffset === 0) && - (helper.caretLineNumber() === 1)) { - return true; - } else { - helper.pageUp(); - } - }); - helper.pageDown(); - await helper.waitForPromise(() => { - if ((helper.padInner$.document.getSelection().anchorOffset > 0) && - (helper.caretLineNumber() === 1)) { - return true; - } - }); - helper.pageUp(); - await helper.waitForPromise(() => { - if ((helper.padInner$.document.getSelection().anchorOffset > 0) && - (helper.caretLineNumber() === 1)) { - return true; - } - }); - }); -}); +'use strict'; + +describe(`Really long text line goes to character within text line if text line is last + line in viewport if the second line is also incredibly long`, function () { + beforeEach(function (cb) { + helper.newPad({ + cb: async () => { + await helper.clearPad(); + // 200 lines + await helper.edit( + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world\n ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + 'hello world hello world hello world hello world hello world hello world hello world ' + + '\n\n\n\n\n\n\n\n\n '); + cb(); + }, + }); + }); + + it('Pg down on long line keeps char on the same line but with large X offset', async function () { + await helper.edit('xxx', 1); // caret is offset 6 + await helper.waitForPromise(() => { + if ((helper.padInner$.document.getSelection().anchorOffset === 0) && + (helper.caretLineNumber() === 1)) { + return true; + } else { + helper.pageUp(); + } + }); + helper.pageDown(); + await helper.waitForPromise(() => { + if ((helper.padInner$.document.getSelection().anchorOffset > 0) && + (helper.caretLineNumber() === 1)) { + return true; + } + }); + helper.pageUp(); + await helper.waitForPromise(() => { + if ((helper.padInner$.document.getSelection().anchorOffset > 0) && + (helper.caretLineNumber() === 1)) { + return true; + } + }); + }); +}); diff --git a/tests/frontend/specs/pageupdownpressandhold.js b/tests/frontend/specs/pageupdownpressandhold.js index d84137e94..f70e8025b 100755 --- a/tests/frontend/specs/pageupdownpressandhold.js +++ b/tests/frontend/specs/pageupdownpressandhold.js @@ -1,36 +1,36 @@ -'use strict'; - -describe('Press and Hold Page Up/Down', function () { - beforeEach(function (cb) { - helper.newPad({ - cb: async () => { - await helper.clearPad(); - // 200 lines - await helper.edit( - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); - cb(); - }, - }); - }); - it('page up press and hold to top', async function () { - // by default page down when caret is at end of the document will leave it in the same place. - // viewport based pageup/down changes that - helper.pageUp({ - pressAndHold: true, - }); - await helper.waitForPromise(() => helper.caretLineNumber() === 1); - }); - it('page down press and hold to bottom', async function () { - // by default page down when caret is at end of the document will leave it in the same place. - // viewport based pageup/down changes that - const initialLineNumber = helper.caretLineNumber(); - helper.pageDown({ - pressAndHold: true, - }); - await helper.waitForPromise(() => helper.caretLineNumber() === initialLineNumber); - }); -}); +'use strict'; + +describe('Press and Hold Page Up/Down', function () { + beforeEach(function (cb) { + helper.newPad({ + cb: async () => { + await helper.clearPad(); + // 200 lines + await helper.edit( + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); + cb(); + }, + }); + }); + it('page up press and hold to top', async function () { + // by default page down when caret is at end of the document will leave it in the same place. + // viewport based pageup/down changes that + helper.pageUp({ + pressAndHold: true, + }); + await helper.waitForPromise(() => helper.caretLineNumber() === 1); + }); + it('page down press and hold to bottom', async function () { + // by default page down when caret is at end of the document will leave it in the same place. + // viewport based pageup/down changes that + const initialLineNumber = helper.caretLineNumber(); + helper.pageDown({ + pressAndHold: true, + }); + await helper.waitForPromise(() => helper.caretLineNumber() === initialLineNumber); + }); +}); diff --git a/tests/frontend/specs/pageupdownshift.js b/tests/frontend/specs/pageupdownshift.js index 53ad17a8b..8cde52949 100755 --- a/tests/frontend/specs/pageupdownshift.js +++ b/tests/frontend/specs/pageupdownshift.js @@ -1,130 +1,130 @@ -'use strict'; - -describe('Shift Page Up/Down', function () { - beforeEach(function (cb) { - helper.newPad({ - cb: async () => { - await helper.clearPad(); - // 200 lines - await helper.edit( - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); - cb(); - }, - }); - }); - - it('highlights lines on shift page down and releases them on page up', async function () { - await helper.edit('xxx', 1); // caret is offset 6 - - helper.pageUp(); - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Caret'); - }); - it('highlights lines on shift pg down and maintains first selection on pg up', async function () { - await helper.edit('xxx', 1); // caret is offset 6 - - helper.pageUp(); - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - }); - - it(`Highlights from end of document on pg up - then releases them on shift pg down`, async function () { - // TODO: JM NEEDS HELP: Why isn't this working? It works if you do the same in browser.. - - await helper.waitForPromise(() => helper.caretLineNumber() >= 201); - // make sure we're at bottom - helper.pageDown({ - pressAndHold: true, - }); - await helper.waitForPromise(() => helper.caretLineNumber() >= 201); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Caret'); - throw new Error('I NEED HELPZ PLZ'); - }); - it(`highlights from end of document on pg up twice - and retains on single pg down`, async function () { - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageDown({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - }); - - it(`highlights from 3rd line on page up twice - should keep highlight`, async function () { - await helper.edit('xxx', 3); // caret is offset 6 - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - - helper.pageUp({ - shift: true, - }); - await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); - }); - xit(`highlights range forward then hit page up, selStart should be prior to initial - selStart and selEnd should be the original selStart`, async function () { - // TODO: JM Needs help, need a way to just select this line but it needs direction - // {select} wont cut the mustard - // selStartFocus is internal to rep - }); - - xit(`highlights (a few lines) range forwards then hit page down, selStart should be initial - selStart and selEnd further than original selEnd`, async function () { - throw new Error('JM TO DO'); - }); - - xit(`highlights (a few lines) range backwards (rep.selFocusAtStart) then hit page up, selEnd - should be initial selStart, - selStart should be less than original selStart`, async function () { - throw new Error('JM TO DO'); - }); - - xit(`highlights (a few lines) range backwards (rep.selFocusAtStart) then hit page down, selStart - should be initial selEnd and selEnd further than original selEnd`, async function () { - throw new Error('JM TO DO'); - }); -}); +'use strict'; + +describe('Shift Page Up/Down', function () { + beforeEach(function (cb) { + helper.newPad({ + cb: async () => { + await helper.clearPad(); + // 200 lines + await helper.edit( + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); + cb(); + }, + }); + }); + + it('highlights lines on shift page down and releases them on page up', async function () { + await helper.edit('xxx', 1); // caret is offset 6 + + helper.pageUp(); + helper.pageDown({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + + helper.pageUp({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Caret'); + }); + it('highlights lines on shift pg down and maintains first selection on pg up', async function () { + await helper.edit('xxx', 1); // caret is offset 6 + + helper.pageUp(); + helper.pageDown({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + + helper.pageDown({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + + helper.pageUp({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + }); + + it(`Highlights from end of document on pg up + then releases them on shift pg down`, async function () { + // TODO: JM NEEDS HELP: Why isn't this working? It works if you do the same in browser.. + + await helper.waitForPromise(() => helper.caretLineNumber() >= 201); + // make sure we're at bottom + helper.pageDown({ + pressAndHold: true, + }); + await helper.waitForPromise(() => helper.caretLineNumber() >= 201); + + helper.pageUp({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + + helper.pageDown({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Caret'); + throw new Error('I NEED HELPZ PLZ'); + }); + it(`highlights from end of document on pg up twice + and retains on single pg down`, async function () { + helper.pageUp({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + + helper.pageUp({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + + helper.pageDown({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + }); + + it(`highlights from 3rd line on page up twice + should keep highlight`, async function () { + await helper.edit('xxx', 3); // caret is offset 6 + + helper.pageUp({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + + helper.pageUp({ + shift: true, + }); + await helper.waitForPromise(() => helper.padInner$.document.getSelection().type === 'Range'); + }); + xit(`highlights range forward then hit page up, selStart should be prior to initial + selStart and selEnd should be the original selStart`, async function () { + // TODO: JM Needs help, need a way to just select this line but it needs direction + // {select} wont cut the mustard + // selStartFocus is internal to rep + }); + + xit(`highlights (a few lines) range forwards then hit page down, selStart should be initial + selStart and selEnd further than original selEnd`, async function () { + throw new Error('JM TO DO'); + }); + + xit(`highlights (a few lines) range backwards (rep.selFocusAtStart) then hit page up, selEnd + should be initial selStart, + selStart should be less than original selStart`, async function () { + throw new Error('JM TO DO'); + }); + + xit(`highlights (a few lines) range backwards (rep.selFocusAtStart) then hit page down, selStart + should be initial selEnd and selEnd further than original selEnd`, async function () { + throw new Error('JM TO DO'); + }); +}); diff --git a/tests/frontend/specs/pageupdownviewport.js b/tests/frontend/specs/pageupdownviewport.js index 1e9236b36..5a47bae0f 100755 --- a/tests/frontend/specs/pageupdownviewport.js +++ b/tests/frontend/specs/pageupdownviewport.js @@ -1,41 +1,41 @@ -'use strict'; - -describe('Viewport based Page Up/Down', function () { - beforeEach(function (cb) { - helper.newPad({ - cb: async () => { - await helper.clearPad(); - // 200 lines - await helper.edit( - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); - cb(); - }, - }); - }); - it('page up when top is at 100 and caret is at bottom', async function () { - // by default page down when caret is at end of the document will leave it in the same place. - // viewport based pageup/down changes that - const initialLineNumber = helper.caretLineNumber(); - helper.pageDown(); - helper.padOuter$('#outerdocbody').parent().scrollTop(100); - helper.pageUp(); - await helper.waitForPromise(() => helper.caretLineNumber() < initialLineNumber); - }); - - it('page down when top is at 0 and caret is at bottom', async function () { - // by default page down when caret is at end of the document will leave it in the same place. - // viewport based pageup/down changes that - const initialLineNumber = helper.caretLineNumber(); - helper.padOuter$('#outerdocbody').parent().scrollTop(0); - await helper.waitForPromise(() => helper.padOuter$('#outerdocbody').parent().scrollTop() === 0); - helper.pageUp(); // I think this might not be right.. - helper.pageDown(); - - await helper.waitForPromise(() => (helper - .caretLineNumber() < initialLineNumber) && (helper.caretLineNumber() > 1)); - }); -}); +'use strict'; + +describe('Viewport based Page Up/Down', function () { + beforeEach(function (cb) { + helper.newPad({ + cb: async () => { + await helper.clearPad(); + // 200 lines + await helper.edit( + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); + cb(); + }, + }); + }); + it('page up when top is at 100 and caret is at bottom', async function () { + // by default page down when caret is at end of the document will leave it in the same place. + // viewport based pageup/down changes that + const initialLineNumber = helper.caretLineNumber(); + helper.pageDown(); + helper.padOuter$('#outerdocbody').parent().scrollTop(100); + helper.pageUp(); + await helper.waitForPromise(() => helper.caretLineNumber() < initialLineNumber); + }); + + it('page down when top is at 0 and caret is at bottom', async function () { + // by default page down when caret is at end of the document will leave it in the same place. + // viewport based pageup/down changes that + const initialLineNumber = helper.caretLineNumber(); + helper.padOuter$('#outerdocbody').parent().scrollTop(0); + await helper.waitForPromise(() => helper.padOuter$('#outerdocbody').parent().scrollTop() === 0); + helper.pageUp(); // I think this might not be right.. + helper.pageDown(); + + await helper.waitForPromise(() => (helper + .caretLineNumber() < initialLineNumber) && (helper.caretLineNumber() > 1)); + }); +});