#4586: Clear Results feature in Notebooks (#4705)

* #4586: Clear all outputs feature

* text change

* Adding extensible method with integration tests

* Misc change

* Misc change

* Adding more logging

* Change to test

* Adding outputs confition in integration tests
This commit is contained in:
Raj
2019-03-28 15:20:28 -07:00
committed by GitHub
parent 7eb17f6abc
commit 1415aa1c03
11 changed files with 108 additions and 3 deletions

View File

@@ -43,6 +43,40 @@ if (context.RunTest) {
// console.log('Python3 NB done');
// });
// test('Clear all outputs - Python3 notebook ', async function () {
// let notebook = await openNotebook(pySparkNotebookContent, pythonKernelMetadata);
// //Check if at least one cell with output
// let cellWithOutputs = notebook.document.cells.find(cell => cell.contents && cell.contents.outputs && cell.contents.outputs.length > 0);
// console.log("Before clearing cell outputs");
// if (cellWithOutputs) {
// let clearedOutputs = await notebook.clearAllOutputs();
// let cells = notebook.document.cells;
// cells.forEach(cell => {
// assert(cell.contents && cell.contents.outputs && cell.contents.outputs.length === 0, `Expected Output: 0, Acutal: '${cell.contents.outputs.length}'`);
// });
// assert(clearedOutputs, 'Outputs of all the code cells from Python notebook should be cleared');
// console.log("After clearing cell outputs");
// }
// assert(cellWithOutputs === undefined, 'Could not find notebook cells with outputs');
// });
test('Clear all outputs - SQL notebook ', async function () {
let notebook = await openNotebook(sqlNotebookContent, sqlKernelMetadata);
let cellWithOutputs = notebook.document.cells.find(cell => cell.contents && cell.contents.outputs && cell.contents.outputs.length > 0);
console.log("Before clearing cell outputs");
if (cellWithOutputs) {
let clearedOutputs = await notebook.clearAllOutputs();
let cells = notebook.document.cells;
cells.forEach(cell => {
assert(cell.contents && cell.contents.outputs && cell.contents.outputs.length === 0, `Expected Output: 0, Acutal: '${cell.contents.outputs.length}'`);
});
assert(clearedOutputs, 'Outputs of all the code cells from SQL notebook should be cleared');
console.log("After clearing cell outputs");
}
assert(cellWithOutputs === undefined, 'Could not find notebook cells with outputs');
});
// test('PySpark3 notebook test', async function () {
// this.timeout(12000);
// let notebook = await openNotebook(pySparkNotebookContent, pySpark3KernelMetadata);