##// END OF EJS Templates
fixing tests
fixing tests

File last commit:

r16989:2ac6956b
r19288:5e74ae91
Show More
dualmode.js
116 lines | 4.0 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Add dual mode JS tests
r15914 // Test the notebook dual mode feature.
// Test
casper.notebook_test(function () {
Jonathan Frederic
Added ctrl+(j&k), a, and b tests
r15928 var a = 'print("a")';
var index = this.append_cell(a);
Jonathan Frederic
Add dual mode JS tests
r15914 this.execute_cell_then(index);
Jonathan Frederic
Added ctrl+(j&k), a, and b tests
r15928
var b = 'print("b")';
index = this.append_cell(b);
Jonathan Frederic
Add dual mode JS tests
r15914 this.execute_cell_then(index);
Jonathan Frederic
Added ctrl+(j&k), a, and b tests
r15928
var c = 'print("c")';
index = this.append_cell(c);
Jonathan Frederic
Add dual mode JS tests
r15914 this.execute_cell_then(index);
this.then(function () {
Jonathan Frederic
Add slimerjs flag to test engine.
r16841 if (this.slimerjs) {
// When running in xvfb, the Slimer window doesn't always have focus
jon
Address comments
r16861 // immediately. By clicking on a new element on the page we can force
Jonathan Frederic
Add slimerjs flag to test engine.
r16841 // it to gain focus.
this.click_cell_editor(1);
this.click_cell_editor(0);
}
Jonathan Frederic
Some cleanup
r16838
this.validate_notebook_state('initial state', 'edit', 0);
Jonathan Frederic
s/key_press/trigger_keydown
r15915 this.trigger_keydown('esc');
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('esc', 'command', 0);
Jonathan Frederic
s/key_press/trigger_keydown
r15915 this.trigger_keydown('down');
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('down', 'command', 1);
Jonathan Frederic
s/key_press/trigger_keydown
r15915 this.trigger_keydown('enter');
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('enter', 'edit', 1);
Jonathan Frederic
s/key_press/trigger_keydown
r15915 this.trigger_keydown('j');
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('j in edit mode', 'edit', 1);
Jonathan Frederic
s/key_press/trigger_keydown
r15915 this.trigger_keydown('esc');
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('esc', 'command', 1);
Jonathan Frederic
s/key_press/trigger_keydown
r15915 this.trigger_keydown('j');
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('j in command mode', 'command', 2);
Jonathan Frederic
Added up/down and markdown tests
r15926 this.click_cell_editor(0);
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('click cell 0', 'edit', 0);
Jonathan Frederic
Added up/down and markdown tests
r15926 this.click_cell_editor(3);
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('click cell 3', 'edit', 3);
Jonathan Frederic
s/key_press/trigger_keydown
r15915 this.trigger_keydown('esc');
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('esc', 'command', 3);
Jonathan Frederic
Add dual mode JS tests
r15914
// Open keyboard help
this.evaluate(function(){
$('#keyboard_shortcuts a').click();
}, {});
Jonathan Frederic
Wait for keyboard help fadein and fadeout.
r16988 });
Jonathan Frederic
Use waits instead of sleeps.
r16989
Jonathan Frederic
Wait for keyboard help fadein and fadeout.
r16988 // Wait for the dialog to fade in completely.
Jonathan Frederic
Use waits instead of sleeps.
r16989 this.waitForSelector('div.modal', function() {
this.evaluate(function(){
IPython.modal_shown = false;
$('div.modal').on('shown.bs.modal', function (){
IPython.modal_shown = true;
});
$('div.modal').on('hidden.bs.modal', function (){
IPython.modal_shown = false;
});
});
});
Jonathan Frederic
Add dual mode JS tests
r15914
Jonathan Frederic
Use waits instead of sleeps.
r16989 this.waitFor(function () {
return this.evaluate(function(){
return IPython.modal_shown;
});
},
function() {
Jonathan Frederic
s/key_press/trigger_keydown
r15915 this.trigger_keydown('k');
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('k in command mode while keyboard help is up', 'command', 3);
Jonathan Frederic
Add dual mode JS tests
r15914
// Close keyboard help
this.evaluate(function(){
Jonathan Frederic
Wait for keyboard help fadein and fadeout.
r16988 $('div.modal-footer button.btn-default').click();
Jonathan Frederic
Add dual mode JS tests
r15914 }, {});
Jonathan Frederic
Wait for keyboard help fadein and fadeout.
r16988 });
Jonathan Frederic
Use waits instead of sleeps.
r16989
Jonathan Frederic
Wait for keyboard help fadein and fadeout.
r16988 // Wait for the dialog to fade out completely.
Jonathan Frederic
Use waits instead of sleeps.
r16989 this.waitFor(function () {
return this.evaluate(function(){
return !IPython.modal_shown;
});
},
function() {
Jonathan Frederic
Add dual mode JS tests
r15914
Jonathan Frederic
s/key_press/trigger_keydown
r15915 this.trigger_keydown('k');
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('k in command mode', 'command', 2);
Jonathan Frederic
Added up/down and markdown tests
r15926 this.click_cell_editor(0);
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('click cell 0', 'edit', 0);
Jonathan Frederic
Add dual mode JS tests
r15914 this.focus_notebook();
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('focus #notebook', 'command', 0);
Jonathan Frederic
Added up/down and markdown tests
r15926 this.click_cell_editor(0);
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('click cell 0', 'edit', 0);
Jonathan Frederic
Add dual mode JS tests
r15914 this.focus_notebook();
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('focus #notebook', 'command', 0);
Jonathan Frederic
Added up/down and markdown tests
r15926 this.click_cell_editor(3);
Jonathan Frederic
HUGE speed improvements to dual mode tests
r15934 this.validate_notebook_state('click cell 3', 'edit', 3);
Jonathan Frederic
Made *+enter tests more complicated.
r15922
Jonathan Frederic
Added ctrl+(j&k), a, and b tests
r15928 // Cell deletion
Jonathan Frederic
Cleaned up test names and locations.
r15936 this.trigger_keydown('esc', 'd', 'd');
this.test.assertEquals(this.get_cells_length(), 3, 'dd actually deletes a cell');
this.validate_notebook_state('dd', 'command', 2);
Jonathan Frederic
Add dd tests
r15924
Jonathan Frederic
Added ctrl+(j&k), a, and b tests
r15928 // Make sure that if the time between d presses is too long, nothing gets removed.
Jonathan Frederic
Add dd tests
r15924 this.trigger_keydown('d');
Jonathan Frederic
Add dual mode JS tests
r15914 });
Jonathan Frederic
Add dd tests
r15924 this.wait(1000);
this.then(function () {
this.trigger_keydown('d');
Jonathan Frederic
Cleaned up test names and locations.
r15936 this.test.assertEquals(this.get_cells_length(), 3, "d, 1 second wait, d doesn't delete a cell");
this.validate_notebook_state('d, 1 second wait, d', 'command', 2);
Jonathan Frederic
Add dd tests
r15924 });
Jonathan Frederic
Add dual mode JS tests
r15914 });