Add Copy/Paste cell attachments test

This commit is contained in:
Julien Rebetez 2016-02-25 10:15:50 +01:00
parent cc58b282fd
commit 51cab51f1c
2 changed files with 34 additions and 2 deletions

View File

@ -1727,7 +1727,6 @@ define(function (require) {
if (cell.attachments !== undefined) {
// Do a deep copy of attachments to avoid subsequent modification
// to the cell to modify the clipboard
console.log(cell.attachments);
this.clipboard_attachments = $.extend(true, {}, cell.attachments);
this.enable_attachments_paste();
}
@ -1744,7 +1743,8 @@ define(function (require) {
if (cell.attachments === undefined) {
cell.attachments = {};
}
$.extend(cell.attachments, this.clipboard_attachments);
// Do a deep copy so we can paste multiple times
$.extend(true, cell.attachments, this.clipboard_attachments);
cell.unrender();
cell.render();
}

View File

@ -69,5 +69,37 @@ casper.notebook_test(function () {
//this.then(function() {
//this.capture('test.png');
//});
// Use the Edit->Copy/Paste Cell Attachments menu items
selector = '#copy_cell_attachments > a';
this.waitForSelector(selector);
this.thenClick(selector);
// append a new cell
this.append_cell('', 'markdown');
this.thenEvaluate(function() {
IPython.notebook.select_next();
});
// and paste the attachments into it
selector = '#paste_cell_attachments > a';
this.waitForSelector(selector);
this.thenClick(selector);
// Small delay so the paste has the time to complete
this.wait(500);
// check that the new cell has attachments
this.then(function() {
var cell = this.evaluate(function() {
return IPython.notebook.get_selected_cell();
});
var orig_cell = this.evaluate(function() {
return IPython.notebook.get_cell(0);
});
var clip = this.evaluate(function() { return IPython.notebook.clipboard_attachments; });
// Check that the two cells have the same attachments
this.test.assertEquals(cell.attachments, orig_cell.attachments,
"both cells have the attachments");
});
});