mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 17:36:14 -04:00
restructure: move bin/ and tests/ to src/
Also add symlinks from the old `bin/` and `tests/` locations to avoid breaking scripts and other tools. Motivations: * Scripts and tests no longer have to do dubious things like: require('ep_etherpad-lite/node_modules/foo') to access packages installed as dependencies in `src/package.json`. * Plugins can access the backend test helper library in a non-hacky way: require('ep_etherpad-lite/tests/backend/common') * We can delete the top-level `package.json` without breaking our ability to lint the files in `bin/` and `tests/`. Deleting the top-level `package.json` has downsides: It will cause `npm` to print warnings whenever plugins are installed, npm will no longer be able to enforce a plugin's peer dependency on ep_etherpad-lite, and npm will keep deleting the `node_modules/ep_etherpad-lite` symlink that points to `../src`. But there are significant upsides to deleting the top-level `package.json`: It will drastically speed up plugin installation because `npm` doesn't have to recursively walk the dependencies in `src/package.json`. Also, deleting the top-level `package.json` avoids npm's horrible dependency hoisting behavior (where it moves stuff from `src/node_modules/` to the top-level `node_modules/` directory). Dependency hoisting causes numerous mysterious problems such as silent failures in `npm outdated` and `npm update`. Dependency hoisting also breaks plugins that do: require('ep_etherpad-lite/node_modules/foo')
This commit is contained in:
parent
efde0b787a
commit
2ea8ea1275
146 changed files with 191 additions and 1161 deletions
100
src/tests/frontend/specs/timeslider_follow.js
Normal file
100
src/tests/frontend/specs/timeslider_follow.js
Normal file
|
@ -0,0 +1,100 @@
|
|||
'use strict';
|
||||
|
||||
describe('timeslider follow', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
helper.newPad(cb);
|
||||
});
|
||||
|
||||
// TODO needs test if content is also followed, when user a makes edits
|
||||
// while user b is in the timeslider
|
||||
it("content as it's added to timeslider", async function () {
|
||||
// send 6 revisions
|
||||
const revs = 6;
|
||||
const message = 'a\n\n\n\n\n\n\n\n\n\n';
|
||||
const newLines = message.split('\n').length;
|
||||
for (let i = 0; i < revs; i++) {
|
||||
await helper.edit(message, newLines * i + 1);
|
||||
}
|
||||
|
||||
await helper.gotoTimeslider(0);
|
||||
await helper.waitForPromise(() => helper.contentWindow().location.hash === '#0');
|
||||
|
||||
const originalTop = helper.contentWindow().$('#innerdocbody').offset();
|
||||
|
||||
// set to follow contents as it arrives
|
||||
helper.contentWindow().$('#options-followContents').prop('checked', true);
|
||||
helper.contentWindow().$('#playpause_button_icon').click();
|
||||
|
||||
let newTop;
|
||||
await helper.waitForPromise(() => {
|
||||
newTop = helper.contentWindow().$('#innerdocbody').offset();
|
||||
return newTop.top < originalTop.top;
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests for bug described in #4389
|
||||
* The goal is to scroll to the first line that contains a change right before
|
||||
* the change is applied.
|
||||
*/
|
||||
it('only to lines that exist in the pad view, regression test for #4389', async function () {
|
||||
await helper.clearPad();
|
||||
await helper.edit('Test line\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' +
|
||||
'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n');
|
||||
await helper.edit('Another test line', 40);
|
||||
|
||||
|
||||
await helper.gotoTimeslider();
|
||||
|
||||
// set to follow contents as it arrives
|
||||
helper.contentWindow().$('#options-followContents').prop('checked', true);
|
||||
|
||||
const oldYPosition = helper.contentWindow().$('#editorcontainerbox')[0].scrollTop;
|
||||
expect(oldYPosition).to.be(0);
|
||||
|
||||
/**
|
||||
* pad content rev 0 [default Pad text]
|
||||
* pad content rev 1 ['']
|
||||
* pad content rev 2 ['Test line','','', ..., '']
|
||||
* pad content rev 3 ['Test line','',..., 'Another test line', ..., '']
|
||||
*/
|
||||
|
||||
// line 40 changed
|
||||
helper.contentWindow().$('#leftstep').click();
|
||||
await helper.waitForPromise(() => hasFollowedToLine(40));
|
||||
|
||||
// line 1 is the first line that changed
|
||||
helper.contentWindow().$('#leftstep').click();
|
||||
await helper.waitForPromise(() => hasFollowedToLine(1));
|
||||
|
||||
// line 1 changed
|
||||
helper.contentWindow().$('#leftstep').click();
|
||||
await helper.waitForPromise(() => hasFollowedToLine(1));
|
||||
|
||||
// line 1 changed
|
||||
helper.contentWindow().$('#rightstep').click();
|
||||
await helper.waitForPromise(() => hasFollowedToLine(1));
|
||||
|
||||
// line 1 is the first line that changed
|
||||
helper.contentWindow().$('#rightstep').click();
|
||||
await helper.waitForPromise(() => hasFollowedToLine(1));
|
||||
|
||||
// line 40 changed
|
||||
helper.contentWindow().$('#rightstep').click();
|
||||
helper.waitForPromise(() => hasFollowedToLine(40));
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {number} lineNum
|
||||
* @returns {boolean} scrolled to the lineOffset?
|
||||
*/
|
||||
const hasFollowedToLine = (lineNum) => {
|
||||
const scrollPosition = helper.contentWindow().$('#editorcontainerbox')[0].scrollTop;
|
||||
const lineOffset =
|
||||
helper.contentWindow().$('#innerdocbody').find(`div:nth-child(${lineNum})`)[0].offsetTop;
|
||||
return Math.abs(scrollPosition - lineOffset) < 1;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue