Re-enable notebook editor unit tests (#13328)

* wip

* Re-enable notebook editor tests

* PR Feedback
This commit is contained in:
Chris LaFreniere
2020-11-10 17:04:30 -08:00
committed by GitHub
parent b83da2dfa8
commit 8c6a966bb9
3 changed files with 15 additions and 8 deletions

View File

@@ -368,7 +368,7 @@ export class NotebookEditor extends EditorPane implements IFindNotebookControlle
currentMatch: false,
loop: true
};
this._notebookModel.cells.forEach(cell => {
this._notebookModel.cells?.forEach(cell => {
this._register(cell.onCellModeChanged((state) => {
this._onFindStateChange(changeEvent).catch(onUnexpectedError);
}));

View File

@@ -56,15 +56,15 @@ import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/u
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { IProductService } from 'vs/platform/product/common/productService';
import { IHostColorSchemeService } from 'vs/workbench/services/themes/common/hostColorSchemeService';
import { ColorScheme } from 'vs/platform/theme/common/theme';
import { CellModel } from 'sql/workbench/services/notebook/browser/models/cell';
class NotebookModelStub extends stubs.NotebookModelStub {
public contentChangedEmitter = new Emitter<NotebookContentChange>();
private _kernelChangedEmitter = new Emitter<nb.IKernelChangedArgs>();
private _onActiveCellChanged = new Emitter<ICellModel>();
get cells(): ICellModel[] {
return this.cells;
}
public get contentChanged(): Event<NotebookContentChange> {
return this.contentChangedEmitter.event;
}
@@ -84,8 +84,12 @@ class NotebookModelStub extends stubs.NotebookModelStub {
}
}
suite.skip('Test class NotebookEditor:', () => {
suite('Test class NotebookEditor:', () => {
let instantiationService = <TestInstantiationService>workbenchInstantiationService();
instantiationService.stub(IHostColorSchemeService, {
colorScheme: ColorScheme.DARK,
onDidChangeColorScheme: new Emitter<void>().event
});
let workbenchThemeService = instantiationService.createInstance(WorkbenchThemeService);
let notebookEditor: NotebookEditor;
let testTitle: string;
@@ -169,7 +173,7 @@ suite.skip('Test class NotebookEditor:', () => {
});
}
test.skip('Verifies that getCellEditor() returns a valid text editor object for valid guid input', async () => {
test('Verifies that getCellEditor() returns a valid text editor object for valid guid input', async () => {
await setupNotebookEditor(notebookEditor, untitledNotebookInput);
const result = notebookEditor.getCellEditor(cellTextEditorGuid);
assert.strictEqual(result, queryTextEditor, 'notebookEditor.getCellEditor() should return an expected QueryTextEditor when a guid corresponding to that editor is passed in.');
@@ -451,6 +455,7 @@ suite.skip('Test class NotebookEditor:', () => {
});
untitledNotebookInput.notebookFindModel.notebookModel = undefined; // clear preexisting notebookModel
const notebookModel = <NotebookModelStub>await notebookEditor.getNotebookModel();
notebookModel['_cells'] = [new CellModel({ cell_type: 'code', source: '' }, { isTrusted: true, notebook: notebookModel })];
notebookEditor['registerModelChanges']();
notebookModel.cells[0]['_onCellModeChanged'].fire(true); //fire cellModeChanged event on the first sell of our test notebookModel
notebookModel.contentChangedEmitter.fire({ changeType: NotebookChangeType.Saved });

View File

@@ -21,9 +21,9 @@ export class NotebookEditorStub extends stubs.NotebookEditorStub {
model: INotebookModel | undefined;
cells?: ICellModel[] = [];
public readonly id = this.notebookParams?.notebookUri?.toString();
public readonly id: string;
public readonly modelReady: Promise<INotebookModel> = Promise.resolve(this.model);
public readonly modelReady: Promise<INotebookModel>;
// Normally one needs to provide either the editor or the instantiationService as the constructor parameter
constructor({ cellGuid, instantiationService, editor, model, notebookParams }: { cellGuid?: string; instantiationService?: IInstantiationService; editor?: QueryTextEditor; model?: INotebookModel, notebookParams?: INotebookParams } = {}) {
@@ -31,6 +31,8 @@ export class NotebookEditorStub extends stubs.NotebookEditorStub {
this.model = model;
this.notebookParams = notebookParams;
this.cellEditors = [new CellEditorProviderStub({ cellGuid: cellGuid, instantiationService: instantiationService, editor: editor })];
this.id = this.notebookParams?.notebookUri?.toString();
this.modelReady = Promise.resolve(this.model);
}
}