mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Re-enable notebook editor unit tests (#13328)
* wip * Re-enable notebook editor tests * PR Feedback
This commit is contained in:
@@ -368,7 +368,7 @@ export class NotebookEditor extends EditorPane implements IFindNotebookControlle
|
|||||||
currentMatch: false,
|
currentMatch: false,
|
||||||
loop: true
|
loop: true
|
||||||
};
|
};
|
||||||
this._notebookModel.cells.forEach(cell => {
|
this._notebookModel.cells?.forEach(cell => {
|
||||||
this._register(cell.onCellModeChanged((state) => {
|
this._register(cell.onCellModeChanged((state) => {
|
||||||
this._onFindStateChange(changeEvent).catch(onUnexpectedError);
|
this._onFindStateChange(changeEvent).catch(onUnexpectedError);
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/u
|
|||||||
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||||
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
|
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||||
import { IProductService } from 'vs/platform/product/common/productService';
|
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 {
|
class NotebookModelStub extends stubs.NotebookModelStub {
|
||||||
public contentChangedEmitter = new Emitter<NotebookContentChange>();
|
public contentChangedEmitter = new Emitter<NotebookContentChange>();
|
||||||
private _kernelChangedEmitter = new Emitter<nb.IKernelChangedArgs>();
|
private _kernelChangedEmitter = new Emitter<nb.IKernelChangedArgs>();
|
||||||
private _onActiveCellChanged = new Emitter<ICellModel>();
|
private _onActiveCellChanged = new Emitter<ICellModel>();
|
||||||
|
|
||||||
get cells(): ICellModel[] {
|
|
||||||
return this.cells;
|
|
||||||
}
|
|
||||||
public get contentChanged(): Event<NotebookContentChange> {
|
public get contentChanged(): Event<NotebookContentChange> {
|
||||||
return this.contentChangedEmitter.event;
|
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();
|
let instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||||
|
instantiationService.stub(IHostColorSchemeService, {
|
||||||
|
colorScheme: ColorScheme.DARK,
|
||||||
|
onDidChangeColorScheme: new Emitter<void>().event
|
||||||
|
});
|
||||||
let workbenchThemeService = instantiationService.createInstance(WorkbenchThemeService);
|
let workbenchThemeService = instantiationService.createInstance(WorkbenchThemeService);
|
||||||
let notebookEditor: NotebookEditor;
|
let notebookEditor: NotebookEditor;
|
||||||
let testTitle: string;
|
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);
|
await setupNotebookEditor(notebookEditor, untitledNotebookInput);
|
||||||
const result = notebookEditor.getCellEditor(cellTextEditorGuid);
|
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.');
|
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
|
untitledNotebookInput.notebookFindModel.notebookModel = undefined; // clear preexisting notebookModel
|
||||||
const notebookModel = <NotebookModelStub>await notebookEditor.getNotebookModel();
|
const notebookModel = <NotebookModelStub>await notebookEditor.getNotebookModel();
|
||||||
|
notebookModel['_cells'] = [new CellModel({ cell_type: 'code', source: '' }, { isTrusted: true, notebook: notebookModel })];
|
||||||
notebookEditor['registerModelChanges']();
|
notebookEditor['registerModelChanges']();
|
||||||
notebookModel.cells[0]['_onCellModeChanged'].fire(true); //fire cellModeChanged event on the first sell of our test notebookModel
|
notebookModel.cells[0]['_onCellModeChanged'].fire(true); //fire cellModeChanged event on the first sell of our test notebookModel
|
||||||
notebookModel.contentChangedEmitter.fire({ changeType: NotebookChangeType.Saved });
|
notebookModel.contentChangedEmitter.fire({ changeType: NotebookChangeType.Saved });
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ export class NotebookEditorStub extends stubs.NotebookEditorStub {
|
|||||||
model: INotebookModel | undefined;
|
model: INotebookModel | undefined;
|
||||||
cells?: ICellModel[] = [];
|
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
|
// 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 } = {}) {
|
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.model = model;
|
||||||
this.notebookParams = notebookParams;
|
this.notebookParams = notebookParams;
|
||||||
this.cellEditors = [new CellEditorProviderStub({ cellGuid: cellGuid, instantiationService: instantiationService, editor: editor })];
|
this.cellEditors = [new CellEditorProviderStub({ cellGuid: cellGuid, instantiationService: instantiationService, editor: editor })];
|
||||||
|
this.id = this.notebookParams?.notebookUri?.toString();
|
||||||
|
this.modelReady = Promise.resolve(this.model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user