2020-11-23 18:21:51 +00:00
|
|
|
describe('assign ordered list', function () {
|
|
|
|
// create a new pad before each test run
|
|
|
|
beforeEach(function (cb) {
|
2012-10-09 01:27:22 +00:00
|
|
|
helper.newPad(cb);
|
2012-11-01 23:19:59 +00:00
|
|
|
this.timeout(60000);
|
2012-10-09 01:27:22 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('inserts ordered list text', function (done) {
|
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
2012-10-09 01:27:22 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
2012-10-09 01:27:22 +00:00
|
|
|
$insertorderedlistButton.click();
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => inner$('div').first().find('ol li').length === 1).done(done);
|
2012-10-09 01:27:22 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
context('when user presses Ctrl+Shift+N', function () {
|
|
|
|
context('and pad shortcut is enabled', function () {
|
|
|
|
beforeEach(function () {
|
2017-05-11 17:56:09 +00:00
|
|
|
makeSureShortcutIsEnabled('cmdShiftN');
|
|
|
|
triggerCtrlShiftShortcut('N');
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('inserts unordered list', function (done) {
|
|
|
|
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done);
|
2017-05-11 17:56:09 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
context('and pad shortcut is disabled', function () {
|
|
|
|
beforeEach(function () {
|
2017-05-11 17:56:09 +00:00
|
|
|
makeSureShortcutIsDisabled('cmdShiftN');
|
|
|
|
triggerCtrlShiftShortcut('N');
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
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(() => {
|
2017-05-11 17:56:09 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
context('when user presses Ctrl+Shift+1', function () {
|
|
|
|
context('and pad shortcut is enabled', function () {
|
|
|
|
beforeEach(function () {
|
2017-05-11 17:56:09 +00:00
|
|
|
makeSureShortcutIsEnabled('cmdShift1');
|
|
|
|
triggerCtrlShiftShortcut('1');
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('inserts unordered list', function (done) {
|
|
|
|
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done);
|
2017-05-11 17:56:09 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
context('and pad shortcut is disabled', function () {
|
|
|
|
beforeEach(function () {
|
2017-05-11 17:56:09 +00:00
|
|
|
makeSureShortcutIsDisabled('cmdShift1');
|
|
|
|
triggerCtrlShiftShortcut('1');
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
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(() => {
|
2017-05-11 17:56:09 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
xit('issue #1125 keeps the numbered list on enter for the new line - EMULATES PASTING INTO A PAD', function (done) {
|
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
2012-10-09 01:27:22 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
2012-10-09 01:27:22 +00:00
|
|
|
$insertorderedlistButton.click();
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
// type a bit, make a line break and type again
|
|
|
|
const $firstTextElement = inner$('div span').first();
|
2017-05-11 17:56:09 +00:00
|
|
|
$firstTextElement.sendkeys('line 1');
|
|
|
|
$firstTextElement.sendkeys('{enter}');
|
|
|
|
$firstTextElement.sendkeys('line 2');
|
2012-10-09 01:27:22 +00:00
|
|
|
$firstTextElement.sendkeys('{enter}');
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
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;
|
2012-10-09 01:27:22 +00:00
|
|
|
expect(hasOLElement).to.be(true);
|
2020-11-23 18:21:51 +00:00
|
|
|
expect($newSecondLine.text()).to.be('line 2');
|
|
|
|
const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2;
|
2012-10-09 01:27:22 +00:00
|
|
|
expect(hasLineNumber).to.be(true); // This doesn't work because pasting in content doesn't work
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2017-05-11 17:56:09 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
var triggerCtrlShiftShortcut = function (shortcutChar) {
|
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const e = inner$.Event(helper.evtType);
|
2017-05-11 17:56:09 +00:00
|
|
|
e.ctrlKey = true;
|
|
|
|
e.shiftKey = true;
|
|
|
|
e.which = shortcutChar.toString().charCodeAt(0);
|
2020-11-23 18:21:51 +00:00
|
|
|
inner$('#innerdocbody').trigger(e);
|
|
|
|
};
|
2017-05-11 17:56:09 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
var makeSureShortcutIsDisabled = function (shortcut) {
|
2017-05-11 17:56:09 +00:00
|
|
|
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false;
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
|
|
|
var makeSureShortcutIsEnabled = function (shortcut) {
|
2017-05-11 17:56:09 +00:00
|
|
|
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2012-10-09 01:27:22 +00:00
|
|
|
});
|
2020-06-05 21:18:58 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
describe('Pressing Tab in an OL increases and decreases indentation', function () {
|
|
|
|
// create a new pad before each test run
|
|
|
|
beforeEach(function (cb) {
|
2020-06-05 21:18:58 +00:00
|
|
|
helper.newPad(cb);
|
|
|
|
this.timeout(60000);
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('indent and de-indent list item with keypress', function (done) {
|
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
2020-06-05 21:18:58 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
// get the first text element out of the inner iframe
|
|
|
|
const $firstTextElement = inner$('div').first();
|
2020-06-05 21:18:58 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
// select this text element
|
2020-06-05 21:18:58 +00:00
|
|
|
$firstTextElement.sendkeys('{selectall}');
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
2020-06-05 21:18:58 +00:00
|
|
|
$insertorderedlistButton.click();
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
const e = inner$.Event(helper.evtType);
|
2020-06-05 21:18:58 +00:00
|
|
|
e.keyCode = 9; // tab
|
2020-11-23 18:21:51 +00:00
|
|
|
inner$('#innerdocbody').trigger(e);
|
2020-06-05 21:18:58 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
expect(inner$('div').first().find('.list-number2').length === 1).to.be(true);
|
2020-06-05 21:18:58 +00:00
|
|
|
e.shiftKey = true; // shift
|
|
|
|
e.keyCode = 9; // tab
|
2020-11-23 18:21:51 +00:00
|
|
|
inner$('#innerdocbody').trigger(e);
|
2020-06-05 21:18:58 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => inner$('div').first().find('.list-number1').length === 1).done(done);
|
2020-06-05 21:18:58 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
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) {
|
2020-06-05 21:18:58 +00:00
|
|
|
helper.newPad(cb);
|
|
|
|
this.timeout(60000);
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('indent and de-indent list item with indent button', function (done) {
|
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
2020-06-05 21:18:58 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
// get the first text element out of the inner iframe
|
|
|
|
const $firstTextElement = inner$('div').first();
|
2020-06-05 21:18:58 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
// select this text element
|
2020-06-05 21:18:58 +00:00
|
|
|
$firstTextElement.sendkeys('{selectall}');
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
|
2020-06-05 21:18:58 +00:00
|
|
|
$insertorderedlistButton.click();
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
const $indentButton = chrome$('.buttonicon-indent');
|
2020-06-05 21:18:58 +00:00
|
|
|
$indentButton.click(); // make it indented twice
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
expect(inner$('div').first().find('.list-number2').length === 1).to.be(true);
|
2020-06-05 21:18:58 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
const $outdentButton = chrome$('.buttonicon-outdent');
|
2020-06-05 21:18:58 +00:00
|
|
|
$outdentButton.click(); // make it deindented to 1
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => inner$('div').first().find('.list-number1').length === 1).done(done);
|
2020-06-05 21:18:58 +00:00
|
|
|
});
|
|
|
|
});
|