mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
915849b319
* lint: low hanging specs/alphabet.js * lint: low hanging specs/authorship_of_editions.js * lint: low hanging specs/bold.js * lint: low hanging specs/caret.js * lint: low hanging specs/change_user_color.js * lint: low hanging specs/change_user_name.js * lint: low hanging specs/chat.js * lint: low hanging specs/chat_load_messages.js * lint: low hanging specs/clear_authorship_colors.js * lint: low hanging specs/delete.js * lint: low hanging specs/drag_and_drop.js * lint: low hanging specs/embed_value.js * lint: low hanging specs/enter.js * lint: low hanging specs/font_type.js * lint: low hanging specs/helper.js * lint: low hanging specs/importexport.js * lint: low hanging specs/importindents.js * lint: low hanging specs/indentation.js * lint: low hanging specs/italic.js * lint: low hanging specs/language.js * lint: low hanging specs/multiple_authors_clear_authorship_colors.js * lint: low hanging specs/ordered_list.js * lint: low hanging specs/pad_modal.js * lint: low hanging specs/redo.js * lint: low hanging specs/responsiveness.js * lint: low hanging specs/select_formatting_buttons.js * lint: low hanging specs/strikethrough.js * lint: low hanging specs/timeslider.js * lint: low hanging specs/timeslider_labels.js * lint: low hanging specs/timeslider_numeric_padID.js * lint: low hanging specs/timeslider_revisions.js * lint: low hanging specs/undo.js * lint: low hanging specs/unordered_list.js * lint: low hanging specs/xxauto_reconnect.js * lint: attempt to do remote_runner.js * lint: helper linting * lint: rate limit linting * use constructor for Event to make eslint happier * for squash: lint fix refinements * for squash: lint fix refinements Co-authored-by: Richard Hansen <rhansen@rhansen.org>
187 lines
6.2 KiB
JavaScript
187 lines
6.2 KiB
JavaScript
'use strict';
|
|
|
|
describe('assign ordered list', function () {
|
|
// create a new pad before each test run
|
|
beforeEach(function (cb) {
|
|
helper.newPad(cb);
|
|
this.timeout(60000);
|
|
});
|
|
|
|
it('inserts ordered list text', function (done) {
|
|
const inner$ = helper.padInner$;
|
|
const chrome$ = helper.padChrome$;
|
|
|
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
|
$insertorderedlistButton.click();
|
|
|
|
helper.waitFor(() => inner$('div').first().find('ol li').length === 1).done(done);
|
|
});
|
|
|
|
context('when user presses Ctrl+Shift+N', function () {
|
|
context('and pad shortcut is enabled', function () {
|
|
beforeEach(function () {
|
|
makeSureShortcutIsEnabled('cmdShiftN');
|
|
triggerCtrlShiftShortcut('N');
|
|
});
|
|
|
|
it('inserts unordered list', function (done) {
|
|
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done);
|
|
});
|
|
});
|
|
|
|
context('and pad shortcut is disabled', function () {
|
|
beforeEach(function () {
|
|
makeSureShortcutIsDisabled('cmdShiftN');
|
|
triggerCtrlShiftShortcut('N');
|
|
});
|
|
|
|
it('does not insert unordered list', function (done) {
|
|
helper.waitFor(
|
|
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
|
|
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
|
}).fail(() => {
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
context('when user presses Ctrl+Shift+1', function () {
|
|
context('and pad shortcut is enabled', function () {
|
|
beforeEach(function () {
|
|
makeSureShortcutIsEnabled('cmdShift1');
|
|
triggerCtrlShiftShortcut('1');
|
|
});
|
|
|
|
it('inserts unordered list', function (done) {
|
|
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done);
|
|
});
|
|
});
|
|
|
|
context('and pad shortcut is disabled', function () {
|
|
beforeEach(function () {
|
|
makeSureShortcutIsDisabled('cmdShift1');
|
|
triggerCtrlShiftShortcut('1');
|
|
});
|
|
|
|
it('does not insert unordered list', function (done) {
|
|
helper.waitFor(
|
|
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
|
|
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
|
|
}).fail(() => {
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
xit('issue #1125 keeps the numbered list on enter for the new line', function (done) {
|
|
// EMULATES PASTING INTO A PAD
|
|
const inner$ = helper.padInner$;
|
|
const chrome$ = helper.padChrome$;
|
|
|
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
|
$insertorderedlistButton.click();
|
|
|
|
// type a bit, make a line break and type again
|
|
const $firstTextElement = inner$('div span').first();
|
|
$firstTextElement.sendkeys('line 1');
|
|
$firstTextElement.sendkeys('{enter}');
|
|
$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();
|
|
});
|
|
});
|
|
|
|
const triggerCtrlShiftShortcut = (shortcutChar) => {
|
|
const inner$ = helper.padInner$;
|
|
const e = new inner$.Event(helper.evtType);
|
|
e.ctrlKey = true;
|
|
e.shiftKey = true;
|
|
e.which = shortcutChar.toString().charCodeAt(0);
|
|
inner$('#innerdocbody').trigger(e);
|
|
};
|
|
|
|
const makeSureShortcutIsDisabled = (shortcut) => {
|
|
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false;
|
|
};
|
|
const makeSureShortcutIsEnabled = (shortcut) => {
|
|
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
|
|
};
|
|
});
|
|
|
|
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);
|
|
this.timeout(60000);
|
|
});
|
|
|
|
it('indent and de-indent list item with keypress', function (done) {
|
|
const inner$ = helper.padInner$;
|
|
const chrome$ = helper.padChrome$;
|
|
|
|
// get the first text element out of the inner iframe
|
|
const $firstTextElement = inner$('div').first();
|
|
|
|
// select this text element
|
|
$firstTextElement.sendkeys('{selectall}');
|
|
|
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
|
$insertorderedlistButton.click();
|
|
|
|
const e = new inner$.Event(helper.evtType);
|
|
e.keyCode = 9; // tab
|
|
inner$('#innerdocbody').trigger(e);
|
|
|
|
expect(inner$('div').first().find('.list-number2').length === 1).to.be(true);
|
|
e.shiftKey = true; // shift
|
|
e.keyCode = 9; // tab
|
|
inner$('#innerdocbody').trigger(e);
|
|
|
|
helper.waitFor(() => inner$('div').first().find('.list-number1').length === 1).done(done);
|
|
});
|
|
});
|
|
|
|
|
|
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);
|
|
this.timeout(60000);
|
|
});
|
|
|
|
it('indent and de-indent list item with indent button', function (done) {
|
|
const inner$ = helper.padInner$;
|
|
const chrome$ = helper.padChrome$;
|
|
|
|
// get the first text element out of the inner iframe
|
|
const $firstTextElement = inner$('div').first();
|
|
|
|
// select this text element
|
|
$firstTextElement.sendkeys('{selectall}');
|
|
|
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
|
$insertorderedlistButton.click();
|
|
|
|
const $indentButton = chrome$('.buttonicon-indent');
|
|
$indentButton.click(); // make it indented twice
|
|
|
|
expect(inner$('div').first().find('.list-number2').length === 1).to.be(true);
|
|
|
|
const $outdentButton = chrome$('.buttonicon-outdent');
|
|
$outdentButton.click(); // make it deindented to 1
|
|
|
|
helper.waitFor(() => inner$('div').first().find('.list-number1').length === 1).done(done);
|
|
});
|
|
});
|