From 9123e3d445493e97e48e4b56f00a9c3cea789beb Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 24 Oct 2025 21:20:58 +0200 Subject: [PATCH] fix(docs-infra): fix broken adev tests (#64761) Fixes some adev tests that are broken on main. PR Close #64761 --- .../playground/playground.component.spec.ts | 23 +++++++++---------- .../playground/playground.component.ts | 4 ++-- .../api-item-label.component.spec.ts | 3 --- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/adev/src/app/features/playground/playground.component.spec.ts b/adev/src/app/features/playground/playground.component.spec.ts index 7af2d3ccdbe..5cdd88f1761 100644 --- a/adev/src/app/features/playground/playground.component.spec.ts +++ b/adev/src/app/features/playground/playground.component.spec.ts @@ -14,6 +14,7 @@ import {NodeRuntimeSandbox} from '../../editor/node-runtime-sandbox.service'; import TutorialPlayground from './playground.component'; import {provideRouter} from '@angular/router'; +import {mockAsyncProvider} from '../../core/services/inject-async'; describe('TutorialPlayground', () => { let component: TutorialPlayground; @@ -26,6 +27,14 @@ describe('TutorialPlayground', () => { }; beforeEach(() => { + class FakeEmbeddedTutorialManager { + fetchAndSetTutorialFiles() {} + } + + class FakeNodeRuntimeSandbox { + init() {} + } + TestBed.configureTestingModule({ imports: [TutorialPlayground], providers: [ @@ -34,18 +43,8 @@ describe('TutorialPlayground', () => { provide: WINDOW, useValue: fakeWindow, }, - { - provide: EmbeddedTutorialManager, - useValue: { - fetchAndSetTutorialFiles: () => {}, - }, - }, - { - provide: NodeRuntimeSandbox, - useVaue: { - init: () => {}, - }, - }, + mockAsyncProvider(NodeRuntimeSandbox, FakeNodeRuntimeSandbox), + mockAsyncProvider(EmbeddedTutorialManager, FakeEmbeddedTutorialManager), ], }); diff --git a/adev/src/app/features/playground/playground.component.ts b/adev/src/app/features/playground/playground.component.ts index fc8c3064646..f59b7448033 100644 --- a/adev/src/app/features/playground/playground.component.ts +++ b/adev/src/app/features/playground/playground.component.ts @@ -83,7 +83,7 @@ export default class PlaygroundComponent { ) .subscribe(() => { this.changeDetectorRef.markForCheck(); - this.nodeRuntimeSandbox!.init(); + this.nodeRuntimeSandbox?.init(); }); } @@ -99,7 +99,7 @@ export default class PlaygroundComponent { }); this.selectedTemplate = template; await this.loadTemplate(template.path); - await this.nodeRuntimeSandbox!.reset(); + await this.nodeRuntimeSandbox?.reset(); } private async loadTemplate(tutorialPath: string) { diff --git a/adev/src/app/features/references/api-item-label/api-item-label.component.spec.ts b/adev/src/app/features/references/api-item-label/api-item-label.component.spec.ts index 154789f0b70..0c794eb6ecd 100644 --- a/adev/src/app/features/references/api-item-label/api-item-label.component.spec.ts +++ b/adev/src/app/features/references/api-item-label/api-item-label.component.spec.ts @@ -12,7 +12,6 @@ import ApiItemLabel from './api-item-label.component'; import {ApiItemType} from '../interfaces/api-item-type'; describe('ApiItemLabel', () => { - let component: ApiItemLabel; let fixture: ComponentFixture; beforeEach(() => { @@ -20,12 +19,10 @@ describe('ApiItemLabel', () => { imports: [ApiItemLabel], }); fixture = TestBed.createComponent(ApiItemLabel); - component = fixture.componentInstance; }); it('should by default display short label for Class', () => { fixture.componentRef.setInput('type', ApiItemType.CLASS); - fixture.componentRef.setInput('mode', 'short'); fixture.detectChanges(); const label = fixture.nativeElement.innerText;