diff --git a/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.spec.ts b/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.spec.ts index 5a5c28991ce..e7c6cb202f2 100644 --- a/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.spec.ts +++ b/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.spec.ts @@ -5,11 +5,13 @@ import { Spectator, SpyObject } from '@ngneat/spectator/jest'; +import { patchState } from '@ngrx/signals'; import { of } from 'rxjs'; import { Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; +import { MessageService } from 'primeng/api'; import { TabPanel, TabView } from 'primeng/tabview'; import { @@ -21,6 +23,7 @@ import { DotWorkflowsActionsService, DotWorkflowService } from '@dotcms/data-access'; +import { ComponentStatus } from '@dotcms/dotcms-models'; import { DotWorkflowActionsComponent } from '@dotcms/ui'; import { DotFormatDateServiceMock } from '@dotcms/utils-testing'; @@ -40,7 +43,7 @@ import { MockResizeObserver } from '../../utils/mocks'; describe('DotFormComponent', () => { let spectator: Spectator; let component: DotEditContentFormComponent; - let store: SpyObject>; + let store: InstanceType; let dotContentTypeService: SpyObject; let workflowActionsService: SpyObject; let workflowActionsFireService: SpyObject; @@ -62,6 +65,7 @@ describe('DotFormComponent', () => { mockProvider(DotMessageService), mockProvider(Router), mockProvider(DotWorkflowService), + mockProvider(MessageService), { provide: ActivatedRoute, useValue: { @@ -125,6 +129,21 @@ describe('DotFormComponent', () => { expect(component.form.get('modUserName')).toBeFalsy(); expect(component.form.get('publishDate')).toBeFalsy(); }); + + it('should disable the form when loading and enable it when not loading', () => { + spectator.detectChanges(); + + // // Initially, the form should be enabled + expect(component.form.enabled).toBe(true); + + patchState(store, { + state: ComponentStatus.SAVING + }); + + spectator.flushEffects(); + + expect(component.form.enabled).toBe(false); + }); }); describe('New Content', () => { diff --git a/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.ts b/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.ts index 2fa4ed9c73c..a2bd529911e 100644 --- a/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.ts +++ b/core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.ts @@ -7,7 +7,6 @@ import { DestroyRef, effect, inject, - Injector, OnInit, output } from '@angular/core'; @@ -148,8 +147,6 @@ export class DotEditContentFormComponent implements OnInit { } } - injector = inject(Injector); - constructor() { effect(() => { const isLoading = this.$store.isLoading(); diff --git a/core-web/libs/edit-content/src/lib/feature/edit-content/store/edit-content.store.spec.ts b/core-web/libs/edit-content/src/lib/feature/edit-content/store/edit-content.store.spec.ts index dbdeb648a61..4c797f4fb8c 100644 --- a/core-web/libs/edit-content/src/lib/feature/edit-content/store/edit-content.store.spec.ts +++ b/core-web/libs/edit-content/src/lib/feature/edit-content/store/edit-content.store.spec.ts @@ -37,8 +37,7 @@ import { CONTENT_TYPE_MOCK } from '../../../utils/mocks'; const messageServiceMock = new MockDotMessageService({ 'edit.content.success.workflow.message': 'Your changes have being applied.', - success: 'Success', - error: 'Error' + success: 'Success' }); describe('DotEditContentStore', () => {