2015-12-31 03:53:46 +08:00
|
|
|
import N1Launcher from './helpers/n1-launcher';
|
|
|
|
import ContenteditableTestHarness from './helpers/contenteditable-test-harness.es6';
|
2015-12-02 10:49:40 +08:00
|
|
|
|
2015-12-31 04:24:50 +08:00
|
|
|
describe('Contenteditable Integration Spec', function() {
|
2015-12-02 10:49:40 +08:00
|
|
|
beforeAll((done)=>{
|
2015-12-31 03:53:46 +08:00
|
|
|
this.app = new N1Launcher(['--dev']);
|
2015-12-02 10:49:40 +08:00
|
|
|
this.app.popoutComposerWindowReady().finally(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach((done) => {
|
2015-12-31 03:53:46 +08:00
|
|
|
this.ce = new ContenteditableTestHarness(this.app.client);
|
2015-12-02 10:49:40 +08:00
|
|
|
this.ce.init().finally(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll((done)=> {
|
|
|
|
if (this.app && this.app.isRunning()) {
|
|
|
|
this.app.stop().then(done);
|
|
|
|
} else {
|
2015-12-31 03:53:46 +08:00
|
|
|
done();
|
2015-12-02 10:49:40 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-03 04:43:11 +08:00
|
|
|
describe('Manipulating Lists', () => {
|
2015-12-31 03:53:46 +08:00
|
|
|
it('Creates ordered lists', (done)=> {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.ce.test({
|
2015-12-31 03:53:46 +08:00
|
|
|
keys: ['1', '.', 'Space'],
|
|
|
|
expectedHTML: '<ol><li></li></ol>',
|
2015-12-03 04:43:11 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
2015-12-31 03:53:46 +08:00
|
|
|
return {
|
|
|
|
node: dom.querySelectorAll('li')[0],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
2015-12-02 10:49:40 +08:00
|
|
|
|
2015-12-03 04:43:11 +08:00
|
|
|
it('Undoes ordered list creation with backspace', (done) => {
|
|
|
|
this.ce.test({
|
2015-12-31 03:53:46 +08:00
|
|
|
keys: ['1', '.', 'Space', 'Back space'],
|
|
|
|
expectedHTML: '1. <br>',
|
2015-12-03 04:43:11 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
2015-12-31 03:53:46 +08:00
|
|
|
return {
|
|
|
|
node: dom.childNodes[0], offset: 3,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
2015-12-02 10:49:40 +08:00
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('Creates unordered lists with star', (done) => {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: ['*', 'Space'],
|
2015-12-31 03:53:46 +08:00
|
|
|
expectedHTML: '<ul><li></li></ul>',
|
2015-12-03 04:43:11 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
2015-12-31 03:53:46 +08:00
|
|
|
return {
|
|
|
|
node: dom.querySelectorAll('li')[0],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('Undoes unordered list creation with backspace', (done) => {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: ['*', 'Space', 'Back space'],
|
2015-12-31 03:53:46 +08:00
|
|
|
expectedHTML: '* <br>',
|
2015-12-03 04:43:11 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
2015-12-31 03:53:46 +08:00
|
|
|
return {
|
|
|
|
node: dom.childNodes[0], offset: 2,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('Creates unordered lists with dash', (done) => {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: ['-', 'Space'],
|
2015-12-31 03:53:46 +08:00
|
|
|
expectedHTML: '<ul><li></li></ul>',
|
2015-12-03 04:43:11 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
2015-12-31 03:53:46 +08:00
|
|
|
return {
|
|
|
|
node: dom.querySelectorAll('li')[0],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
|
|
|
|
2016-01-23 02:33:39 +08:00
|
|
|
it("Doesn't create unordered lists with dash when it's not at the start of the composer", (done) => {
|
|
|
|
this.ce.test({
|
|
|
|
keys: ['asdf', 'Space', 'Back space', '-', 'Space'],
|
|
|
|
expectedHTML: `<spelling class="misspelled">asdf</spelling>- `,
|
|
|
|
expectedSelectionResolver: (dom) => {
|
|
|
|
return {
|
|
|
|
node: dom.childNodes[1],
|
|
|
|
offset: 2,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('Undoes unordered list creation with backspace', (done) => {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: ['-', 'Space', 'Back space'],
|
2015-12-31 03:53:46 +08:00
|
|
|
expectedHTML: '- <br>',
|
2015-12-03 04:43:11 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
2015-12-31 03:53:46 +08:00
|
|
|
return {
|
|
|
|
node: dom.childNodes[0], offset: 2,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
2015-12-22 11:58:01 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('When creating two items in a list', () => {
|
|
|
|
beforeEach(() => {
|
2015-12-31 03:53:46 +08:00
|
|
|
this.twoItemUl = ['-', 'Space', 'a', 'Return', 'b'];
|
|
|
|
this.twoItemOl = ['1', '.', 'Space', 'a', 'Return', 'b'];
|
2015-12-22 11:58:01 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('creates two ordered items with enter at end', (done) => {
|
2015-12-22 11:58:01 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: this.twoItemUl,
|
2015-12-31 03:53:46 +08:00
|
|
|
expectedHTML: '<ul><li>a</li><li>b</li></ul>',
|
2015-12-22 11:58:01 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
|
|
|
return {
|
2015-12-31 03:53:46 +08:00
|
|
|
node: dom.querySelectorAll('li')[1].childNodes[0],
|
|
|
|
offset: 1,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-22 11:58:01 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('creates two bullet items with enter at end', (done) => {
|
2015-12-22 11:58:01 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: this.twoItemOl,
|
2015-12-31 03:53:46 +08:00
|
|
|
expectedHTML: '<ol><li>a</li><li>b</li></ol>',
|
2015-12-22 11:58:01 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
|
|
|
return {
|
2015-12-31 03:53:46 +08:00
|
|
|
node: dom.querySelectorAll('li')[1].childNodes[0],
|
|
|
|
offset: 1,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-22 11:58:01 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('outdents the first item when backspacing from the start', (done) => {
|
2015-12-22 11:58:01 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: this.twoItemOl.concat(['Up arrow', 'Left arrow', 'Back space']),
|
|
|
|
expectedHTML: '<span style="line-height: 1.4;">a</span><br><ol><li>b</li></ol>',
|
|
|
|
expectedSelectionResolver: (dom) => {
|
|
|
|
// NOTE: This is being serialized and run in the app process by
|
|
|
|
// Selenium
|
|
|
|
const {DOMUtils} = require('nylas-exports');
|
|
|
|
return {
|
|
|
|
node: DOMUtils.findFirstTextNode(dom),
|
2015-12-31 03:53:46 +08:00
|
|
|
offset: 0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-22 11:58:01 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('outdents the last item when backspacing from the start', (done) => {
|
2015-12-22 11:58:01 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: this.twoItemOl.concat(['Left arrow', 'Back space']),
|
|
|
|
expectedHTML: '<ol><li>a</li></ol><span style="line-height: 1.4;">b</span><br>',
|
|
|
|
expectedSelectionResolver: (dom) => {
|
|
|
|
return {
|
|
|
|
node: dom.querySelector('span').childNodes[0],
|
2015-12-31 03:53:46 +08:00
|
|
|
offset: 0,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-22 11:58:01 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// xit "backspace from the start of the 1st item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['left', 'up', 'backspace']
|
|
|
|
//
|
|
|
|
// xit "backspace from the start of the 2nd item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['left', 'backspace']
|
|
|
|
//
|
|
|
|
// xit "shift-tab from the start of the 1st item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['left', 'up', 'shift-tab']
|
|
|
|
//
|
|
|
|
// xit "shift-tab from the start of the 2nd item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['left', 'shift-tab']
|
|
|
|
//
|
|
|
|
// xit "shift-tab from the end of the 1st item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['up', 'shift-tab']
|
|
|
|
//
|
|
|
|
// xit "shift-tab from the end of the 2nd item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['shift-tab']
|
|
|
|
//
|
|
|
|
// xit "backspace from the end of the 1st item doesn't outdent", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['up', 'backspace']
|
|
|
|
//
|
|
|
|
// xit "backspace from the end of the 2nd item doesn't outdent", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['backspace']
|
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
describe('when creating a list within a list', ()=> {
|
|
|
|
beforeEach(() => {
|
|
|
|
this.list = ['-', 'Space'];
|
|
|
|
});
|
|
|
|
|
|
|
|
it('indents list once', (done)=> {
|
|
|
|
this.ce.test({
|
|
|
|
keys: this.list.concat(this.list).concat(['a']),
|
|
|
|
expectedHTML: '<ul><ul><li>a</li></ul></ul>',
|
|
|
|
expectedSelectionResolver: (dom) => {
|
|
|
|
return {
|
|
|
|
node: dom.querySelectorAll('li')[0].childNodes[0],
|
2016-01-23 02:33:39 +08:00
|
|
|
offset: 1
|
2015-12-31 03:53:46 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('indents list twice', (done)=> {
|
|
|
|
this.ce.test({
|
|
|
|
keys: this.list.concat(this.list).concat(this.list).concat(['a']),
|
|
|
|
expectedHTML: '<ul><ul><ul><li>a</li></ul></ul></ul>',
|
|
|
|
expectedSelectionResolver: (dom) => {
|
|
|
|
return {
|
|
|
|
node: dom.querySelectorAll('li')[0].childNodes[0],
|
2016-01-23 02:33:39 +08:00
|
|
|
offset: 1
|
2015-12-31 03:53:46 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-12-22 11:58:01 +08:00
|
|
|
describe('When auto-concatenating lists', () => {
|
|
|
|
beforeEach(() => {
|
2015-12-31 03:53:46 +08:00
|
|
|
this.threeItemUl = ['-', 'Space', 'a', 'Return', 'b', 'Return', 'c'];
|
|
|
|
this.threeItemOl = ['1', '.', 'Space', 'a', 'Return', 'b', 'Return', 'c'];
|
|
|
|
this.deleteMiddle = ['Up arrow', 'Back space', 'Back space', 'Back space'];
|
2015-12-22 11:58:01 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('concatenates adjacent unordered lists', (done) => {
|
2015-12-22 11:58:01 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: this.threeItemUl.concat(this.deleteMiddle),
|
2015-12-31 03:53:46 +08:00
|
|
|
expectedHTML: '<ul><li>a</li><li>c</li></ul>',
|
2015-12-22 11:58:01 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
|
|
|
return {
|
2015-12-31 03:53:46 +08:00
|
|
|
node: dom.querySelectorAll('li')[0].childNodes[0],
|
|
|
|
offset: 1,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-22 11:58:01 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('concatenates adjacent ordered lists', (done) => {
|
2015-12-22 11:58:01 +08:00
|
|
|
this.ce.test({
|
|
|
|
keys: this.threeItemOl.concat(this.deleteMiddle),
|
2015-12-31 03:53:46 +08:00
|
|
|
expectedHTML: '<ol><li>a</li><li>c</li></ol>',
|
2015-12-22 11:58:01 +08:00
|
|
|
expectedSelectionResolver: (dom) => {
|
|
|
|
return {
|
2015-12-31 03:53:46 +08:00
|
|
|
node: dom.querySelectorAll('li')[0].childNodes[0],
|
|
|
|
offset: 1,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}).then(done).catch(done.fail);
|
2015-12-22 11:58:01 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-12-03 05:40:12 +08:00
|
|
|
// describe "when creating two items in a list", ->
|
|
|
|
// beforeEach ->
|
|
|
|
// @twoItemKeys = ['-', 'Space', 'a', 'Return', 'b']
|
|
|
|
//
|
|
|
|
// it "creates two items with enter at end", -> waitsForPromise =>
|
|
|
|
// @ce.keys(@twoItemKeys).then =>
|
|
|
|
// @ce.expectHTML "<ul><li>a</li><li>b</li></ul>"
|
|
|
|
// @ce.expectSelection (dom) ->
|
|
|
|
// node: dom.querySelectorAll('li')[1].childNodes[0]
|
|
|
|
// offset: 1
|
|
|
|
//
|
|
|
|
// xit "backspace from the start of the 1st item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['left', 'up', 'backspace']
|
|
|
|
//
|
|
|
|
// xit "backspace from the start of the 2nd item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['left', 'backspace']
|
|
|
|
//
|
|
|
|
// xit "shift-tab from the start of the 1st item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['left', 'up', 'shift-tab']
|
|
|
|
//
|
|
|
|
// xit "shift-tab from the start of the 2nd item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['left', 'shift-tab']
|
|
|
|
//
|
|
|
|
// xit "shift-tab from the end of the 1st item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['up', 'shift-tab']
|
|
|
|
//
|
|
|
|
// xit "shift-tab from the end of the 2nd item outdents", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['shift-tab']
|
|
|
|
//
|
|
|
|
// xit "backspace from the end of the 1st item doesn't outdent", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['up', 'backspace']
|
|
|
|
//
|
|
|
|
// xit "backspace from the end of the 2nd item doesn't outdent", ->
|
|
|
|
// @ce.keys @twoItemKeys.concat ['backspace']
|
|
|
|
//
|
|
|
|
// xdescribe "multi-depth bullets", ->
|
|
|
|
// it "creates multi level bullet when tabbed in", ->
|
|
|
|
// @ce.keys ['-', ' ', 'a', 'tab']
|
|
|
|
//
|
|
|
|
// it "creates multi level bullet when tabbed in", ->
|
|
|
|
// @ce.keys ['-', ' ', 'tab', 'a']
|
|
|
|
//
|
|
|
|
// it "returns to single level bullet on backspace", ->
|
|
|
|
// @ce.keys ['-', ' ', 'a', 'tab', 'left', 'backspace']
|
|
|
|
//
|
|
|
|
// it "returns to single level bullet on shift-tab", ->
|
|
|
|
// @ce.keys ['-', ' ', 'a', 'tab', 'shift-tab']
|
2015-12-02 10:49:40 +08:00
|
|
|
|
|
|
|
|
2015-12-03 04:43:11 +08:00
|
|
|
describe('Ensuring popout composer window works', () => {
|
2015-12-31 03:53:46 +08:00
|
|
|
it('has main window visible', (done)=> {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.app.client.isWindowVisible()
|
2015-12-31 03:53:46 +08:00
|
|
|
.then((result)=> expect(result).toBe(true) )
|
|
|
|
.then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('has main window focused', (done)=> {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.app.client.isWindowFocused()
|
2015-12-31 03:53:46 +08:00
|
|
|
.then((result)=> expect(result).toBe(true) )
|
|
|
|
.then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('is not minimized', (done)=> {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.app.client.isWindowMinimized()
|
2015-12-31 03:53:46 +08:00
|
|
|
.then((result)=> expect(result).toBe(false) )
|
|
|
|
.then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('does not have the dev tools open', (done)=> {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.app.client.isWindowDevToolsOpened()
|
2015-12-31 03:53:46 +08:00
|
|
|
.then((result)=> expect(result).toBe(false) )
|
|
|
|
.then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('has width', (done)=> {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.app.client.getWindowWidth()
|
2015-12-31 03:53:46 +08:00
|
|
|
.then((result)=> expect(result).toBeGreaterThan(0) )
|
|
|
|
.then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
|
|
|
|
2015-12-31 03:53:46 +08:00
|
|
|
it('has height', (done)=> {
|
2015-12-03 04:43:11 +08:00
|
|
|
this.app.client.getWindowHeight()
|
2015-12-31 03:53:46 +08:00
|
|
|
.then((result)=> expect(result).toBeGreaterThan(0) )
|
|
|
|
.then(done).catch(done.fail);
|
2015-12-03 04:43:11 +08:00
|
|
|
});
|
2015-12-02 10:49:40 +08:00
|
|
|
});
|
|
|
|
});
|