Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Upgrade sendkeys, fix some bugs #5157

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/static/js/ace2_inner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3466,7 +3466,7 @@ function Ace2Inner(editorInfo, cssManagers) {
// use that for displaying the side div line number inline with the first line
// of content -- This is used in ep_headings, ep_font_size etc. where the line
// height is increased.
const elementStyle = window.getComputedStyle(docLine.firstChild);
const elementStyle = window.getComputedStyle(docLine.firstElementChild);
const lineHeight = parseInt(elementStyle.getPropertyValue('line-height'));
const marginBottom = parseInt(elementStyle.getPropertyValue('margin-bottom'));
lineHeights.push(lineHeight + marginBottom);
Expand Down
13 changes: 9 additions & 4 deletions src/tests/frontend/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ const helper = {};
await p;
};

if (!win.$) await load('../../static/js/vendors/jquery.js');
// sendkeys.js depends on jQuery, so it cannot be loaded until jQuery has finished loading. (In
// other words, do not load both jQuery and sendkeys inside a Promise.all() call.)
if (!win.bililiteRange && includeSendkeys) await load('../tests/frontend/lib/sendkeys.js');
await Promise.all([
!win.$ && load('../../static/js/vendors/jquery.js'),
!win.bililiteRange && includeSendkeys && load('../tests/frontend/lib/bililiteRange.js'),
]);
// jquery.sendkeys.js depends on jQuery, so it cannot be loaded until jQuery has finished
// loading. (In other words, do not load sendkeys in the above Promise.all() call.)
if (!win.$.fn.sendkeys && includeSendkeys) {
await load('../tests/frontend/lib/jquery.sendkeys.js');
}

win.$.window = win;
win.$.document = doc;
Expand Down
3 changes: 2 additions & 1 deletion src/tests/frontend/helper/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ helper.edit = async (message, line) => {
*
* @returns {Array.<HTMLElement>} array of divs
*/
helper.linesDiv = () => helper.padInner$('.ace-line').map(function () { return $(this); }).get();
helper.linesDiv =
() => helper.padInner$('.ace-line').map(function () { return helper.padInner$(this); }).get();

/**
* The pad text as an array of lines
Expand Down
3 changes: 2 additions & 1 deletion src/tests/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

<script src="../../static/js/require-kernel.js"></script>
<script src="../../static/js/vendors/jquery.js"></script>
<script src="lib/sendkeys.js"></script>
<script src="lib/bililiteRange.js"></script>
<script src="lib/jquery.sendkeys.js"></script>
<script src="../../static/js/vendors/browser.js"></script>
<script src="../../static/plugins/js-cookie/dist/js.cookie.js"></script>
<script src="lib/underscore.js"></script>
Expand Down
Loading
Loading