diff --git a/packages/docs-ui/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/docs-ui/src/commands/commands/__tests__/create-command-test-bed.ts index 61d556a2d05..753d70db1f6 100644 --- a/packages/docs-ui/src/commands/commands/__tests__/create-command-test-bed.ts +++ b/packages/docs-ui/src/commands/commands/__tests__/create-command-test-bed.ts @@ -16,6 +16,8 @@ /* eslint-disable ts/no-explicit-any */ +import type { Ctor, Dependency, DependencyIdentifier, DocumentDataModel, IDocumentData, Nullable } from '@univerjs/core'; +import type { DocumentSkeleton, IRender, IRenderContext, IRenderModule } from '@univerjs/engine-render'; import { BooleanNumber, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, @@ -31,11 +33,9 @@ import { UniverInstanceType, } from '@univerjs/core'; import { DocSelectionManagerService, DocSkeletonManagerService, DocStateEmitService } from '@univerjs/docs'; + import { DocumentViewModel, IRenderManagerService } from '@univerjs/engine-render'; import { BehaviorSubject, takeUntil } from 'rxjs'; - -import type { Ctor, Dependency, DependencyIdentifier, DocumentDataModel, IDocumentData, Nullable } from '@univerjs/core'; -import type { DocumentSkeleton, IRender, IRenderContext, IRenderModule } from '@univerjs/engine-render'; import { DocIMEInputManagerService } from '../../../services/doc-ime-input-manager.service'; import { DocStateChangeManagerService } from '../../../services/doc-state-change-manager.service'; import { DocSelectionRenderService } from '../../../services/selection/doc-selection-render.service'; @@ -124,6 +124,10 @@ export function createCommandTestBed(docData?: IDocumentData, dependencies?: Dep dependencies?.forEach((d) => injector.add(d)); } + + override onReady(): void { + this._injector.get(DocStateChangeManagerService); + } } univer.registerPlugin(TestPlugin); diff --git a/packages/docs-ui/src/commands/commands/__tests__/inline-format.command.spec.ts b/packages/docs-ui/src/commands/commands/__tests__/inline-format.command.spec.ts index 4081ef278b9..48e8308b9fe 100644 --- a/packages/docs-ui/src/commands/commands/__tests__/inline-format.command.spec.ts +++ b/packages/docs-ui/src/commands/commands/__tests__/inline-format.command.spec.ts @@ -14,11 +14,10 @@ * limitations under the License. */ +import type { DocumentDataModel, ICommand, Injector, IStyleBase, Univer } from '@univerjs/core'; import { BooleanNumber, ICommandService, IUniverInstanceService, RedoCommand, UndoCommand, UniverInstanceType } from '@univerjs/core'; import { DocSelectionManagerService, RichTextEditingMutation, SetTextSelectionsOperation } from '@univerjs/docs'; import { afterEach, beforeEach, describe, expect, it } from 'vitest'; - -import type { DocumentDataModel, ICommand, Injector, IStyleBase, Univer } from '@univerjs/core'; import { SetInlineFormatBoldCommand, SetInlineFormatCommand, diff --git a/packages/facade/src/apis/__tests__/create-test-bed.ts b/packages/facade/src/apis/__tests__/create-test-bed.ts index 500128a1263..bae3cf55938 100644 --- a/packages/facade/src/apis/__tests__/create-test-bed.ts +++ b/packages/facade/src/apis/__tests__/create-test-bed.ts @@ -204,6 +204,15 @@ export function createFacadeTestBed(workbookData?: IWorkbookData, dependencies?: }); dependencies?.forEach((d) => injector.add(d)); + + this._injector.get(SheetInterceptorService); + this._injector.get(WorkbookPermissionService); + this._injector.get(WorksheetPermissionService); + this._injector.get(ConditionalFormattingService); + } + + override onReady(): void { + this._injector.get(SheetsRenderService); } } diff --git a/packages/facade/src/apis/docs/__tests__/create-test-bed.ts b/packages/facade/src/apis/docs/__tests__/create-test-bed.ts index 6eea2c57643..a897760bc62 100644 --- a/packages/facade/src/apis/docs/__tests__/create-test-bed.ts +++ b/packages/facade/src/apis/docs/__tests__/create-test-bed.ts @@ -88,6 +88,11 @@ export function createTestBed(documentConfig?: IDocumentData, dependencies?: Dep renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_DOC, [DocSkeletonManagerService] as Dependency); renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_DOC, [DocIMEInputManagerService] as Dependency); } + + override onReady(): void { + this._injector.get(DocStateChangeManagerService); + this._injector.get(DocsRenderService); + } } injector.get(LocaleService).load({ zhCN, enUS }); diff --git a/packages/facade/src/apis/sheets/__tests__/f-range.spec.ts b/packages/facade/src/apis/sheets/__tests__/f-range.spec.ts index 6cf24ff8593..cec1b0e523d 100644 --- a/packages/facade/src/apis/sheets/__tests__/f-range.spec.ts +++ b/packages/facade/src/apis/sheets/__tests__/f-range.spec.ts @@ -16,14 +16,14 @@ /* eslint-disable ts/no-non-null-asserted-optional-chain */ +import type { ICellData, Injector, IRange, IStyleData, Nullable } from '@univerjs/core'; import { DataValidationType, HorizontalAlign, ICommandService, IUniverInstanceService, VerticalAlign, WrapStrategy } from '@univerjs/core'; import { FormulaDataModel } from '@univerjs/engine-formula'; import { AddWorksheetMergeCommand, SetHorizontalTextAlignCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetStyleCommand, SetTextWrapCommand, SetVerticalTextAlignCommand } from '@univerjs/sheets'; -import { AddSheetDataValidationCommand } from '@univerjs/sheets-data-validation'; +import { AddSheetDataValidationCommand } from '@univerjs/sheets-data-validation'; import { ClearSheetsFilterCriteriaCommand, RemoveSheetFilterCommand, SetSheetFilterRangeCommand, SetSheetsFilterCriteriaCommand } from '@univerjs/sheets-filter-ui'; import { beforeEach, describe, expect, it } from 'vitest'; -import type { ICellData, Injector, IRange, IStyleData, Nullable } from '@univerjs/core'; import { createFacadeTestBed } from '../../__tests__/create-test-bed'; import { FUniver } from '../../facade'; diff --git a/packages/sheets-conditional-formatting/src/services/conditional-formatting-formula.service.ts b/packages/sheets-conditional-formatting/src/services/conditional-formatting-formula.service.ts index bb7cffc81ed..3800b394823 100644 --- a/packages/sheets-conditional-formatting/src/services/conditional-formatting-formula.service.ts +++ b/packages/sheets-conditional-formatting/src/services/conditional-formatting-formula.service.ts @@ -15,21 +15,21 @@ */ import type { ICellData, Nullable, ObjectMatrix } from '@univerjs/core'; -import { BooleanNumber, CellValueType, Disposable, ICommandService, Inject, Injector, RefAlias, toDisposable, Tools } from '@univerjs/core'; import type { IRemoveOtherFormulaMutationParams, ISetFormulaCalculationResultMutation, ISetOtherFormulaMutationParams } from '@univerjs/engine-formula'; +import type { IConditionalFormattingFormulaMarkDirtyParams } from '../commands/mutations/formula-mark-dirty.mutation'; +import { BooleanNumber, CellValueType, Disposable, ICommandService, Inject, Injector, RefAlias, toDisposable, Tools } from '@univerjs/core'; + import { IActiveDirtyManagerService, RemoveOtherFormulaMutation, SetFormulaCalculationResultMutation, SetOtherFormulaMutation, } from '@univerjs/engine-formula'; - import { Subject } from 'rxjs'; import { bufferTime, filter, map } from 'rxjs/operators'; -import type { IConditionalFormattingFormulaMarkDirtyParams } from '../commands/mutations/formula-mark-dirty.mutation'; import { ConditionalFormattingFormulaMarkDirty } from '../commands/mutations/formula-mark-dirty.mutation'; -import { ConditionalFormattingViewModel } from '../models/conditional-formatting-view-model'; import { ConditionalFormattingRuleModel } from '../models/conditional-formatting-rule-model'; +import { ConditionalFormattingViewModel } from '../models/conditional-formatting-view-model'; import { ConditionalFormattingService } from './conditional-formatting.service'; // eslint-disable-next-line ts/consistent-type-definitions diff --git a/packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.ts b/packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.ts index 47c3be71a7f..ed786513519 100644 --- a/packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.ts +++ b/packages/sheets-formula-ui/src/commands/operations/__tests__/create-command-test-bed.ts @@ -84,6 +84,10 @@ export function createCommandTestBed(workbookData?: IWorkbookData, dependencies? injector.add([WorksheetProtectionRuleModel]); dependencies?.forEach((d) => injector.add(d)); + + this._injector.get(SheetInterceptorService); + this._injector.get(WorkbookPermissionService); + this._injector.get(WorksheetPermissionService); } } diff --git a/packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.ts b/packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.ts index ae6b9bae2c2..2ada7c73181 100644 --- a/packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.ts +++ b/packages/sheets-formula-ui/src/controllers/__tests__/create-command-test-bed.ts @@ -99,6 +99,10 @@ export function createCommandTestBed(workbookData?: IWorkbookData, dependencies? injector.add([IRefSelectionsService, { useClass: SheetsSelectionsService }]); dependencies?.forEach((d) => injector.add(d)); + + this._injector.get(SheetInterceptorService); + this._injector.get(WorkbookPermissionService); + this._injector.get(WorksheetPermissionService); } override onReady(): void { diff --git a/packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.ts b/packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.ts index d8405f6d189..16bf6dfc8c8 100644 --- a/packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.ts +++ b/packages/sheets-formula-ui/src/controllers/__tests__/formula-auto-fill.controller.spec.ts @@ -81,18 +81,23 @@ describe('Test auto fill with formula', () => { [RangeProtectionRenderModel], [SheetsRenderService, { useClass: mockSheetsRenderService }], ]); + univer = testBed.univer; get = testBed.get; + commandService = get(ICommandService); themeService = get(ThemeService); themeService.setTheme(theme); autoFillController = get(AutoFillController); + commandService.registerCommand(SetRangeValuesMutation); commandService.registerCommand(SetSelectionsOperation); commandService.registerCommand(AddWorksheetMergeMutation); commandService.registerCommand(RemoveWorksheetMergeMutation); commandService.registerCommand(AutoFillCommand); + get(FormulaAutoFillController); + getValues = ( startRow: number, startColumn: number, diff --git a/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts b/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts index 9549e681139..e84fd4658df 100644 --- a/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts +++ b/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import type { ICellData, Injector, IObjectMatrixPrimitiveType, IWorkbookData, Nullable, Univer } from '@univerjs/core'; +import type { ICellData, Injector, IWorkbookData, Nullable, Univer, Workbook } from '@univerjs/core'; import type { IDeleteRangeMoveLeftCommandParams, IDeleteRangeMoveUpCommandParams, IInsertColCommandParams, IInsertRowCommandParams, IMoveColsCommandParams, IMoveRangeCommandParams, IMoveRowsCommandParams, InsertRangeMoveDownCommandParams, InsertRangeMoveRightCommandParams, IRemoveRowColCommandParams, IRemoveSheetCommandParams, ISetRangeValuesCommandParams, ISetWorksheetNameCommandParams } from '@univerjs/sheets'; import { CellValueType, Direction, ICommandService, IUniverInstanceService, LocaleType, RANGE_TYPE, RedoCommand, UndoCommand } from '@univerjs/core'; import { SetArrayFormulaDataMutation, SetFormulaDataMutation } from '@univerjs/engine-formula'; @@ -280,12 +280,12 @@ describe('Test insert function operation', () => { endRow: number, endColumn: number ) => Array>> | undefined; - let getCellData: () => IObjectMatrixPrimitiveType> | undefined; beforeEach(() => { const testBed = createCommandTestBed(TEST_WORKBOOK_DATA_DEMO(), [ [UpdateFormulaController], ]); + univer = testBed.univer; get = testBed.get; @@ -334,14 +334,12 @@ describe('Test insert function operation', () => { endColumn: number ): Array>> | undefined => get(IUniverInstanceService) - .getUniverSheetInstance('test') + .getUnit('test') ?.getSheetBySheetId('sheet1') ?.getRange(startRow, startColumn, endRow, endColumn) .getValues(); - getCellData = () => { - return get(IUniverInstanceService).getUniverSheetInstance('test')?.getSheetBySheetId('sheet1')?.getCellMatrix().clone(); - }; + get(UpdateFormulaController); }); afterEach(() => { diff --git a/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts b/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts index 356de1129e0..30f6a2928a9 100644 --- a/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts +++ b/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts @@ -80,6 +80,10 @@ export function createMenuTestBed() { injector.add([RangeProtectionCache]); injector.add([RangeProtectionRuleModel]); injector.add([RangeProtectionService]); + + this._injector.get(SheetInterceptorService); + this._injector.get(WorkbookPermissionService); + this._injector.get(WorksheetPermissionService); } }