From b0e7dc16e30147a3dacadf46f437f5015ad1eb4f Mon Sep 17 00:00:00 2001 From: Nicolas Molina Date: Wed, 20 Nov 2024 15:36:41 -0400 Subject: [PATCH] chore(edit-content): fix error #30215 --- core-web/libs/edit-content/jest.config.ts | 3 +-- .../dot-file-field-ui-message.component.html | 4 ++-- .../dot-file-field-ui-message.component.spec.ts | 4 +++- .../dot-edit-content-file-field.component.ts | 4 ++-- core-web/libs/edit-content/src/test-setup.ts | 10 ++++++++++ 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core-web/libs/edit-content/jest.config.ts b/core-web/libs/edit-content/jest.config.ts index f03e2169f66c..2728432e8776 100644 --- a/core-web/libs/edit-content/jest.config.ts +++ b/core-web/libs/edit-content/jest.config.ts @@ -18,6 +18,5 @@ export default { 'jest-preset-angular/build/serializers/no-ng-attributes', 'jest-preset-angular/build/serializers/ng-snapshot', 'jest-preset-angular/build/serializers/html-comment' - ], - testEnvironment: '@happy-dom/jest-environment' + ] }; diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.html b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.html index f77e24d304bf..2fe32d45f443 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.html +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.html @@ -4,8 +4,8 @@
- + data-testId="ui-message-span">
diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.spec.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.spec.ts index 533e67bc932f..aeece3be2c67 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.spec.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.spec.ts @@ -1,5 +1,7 @@ import { Spectator, byTestId, createComponentFactory } from '@ngneat/spectator/jest'; +import { CommonModule } from '@angular/common'; + import { DotMessageService } from '@dotcms/data-access'; import { DotMessagePipe } from '@dotcms/ui'; import { MockDotMessageService } from '@dotcms/utils-testing'; @@ -14,7 +16,7 @@ describe('DotFileFieldUiMessageComponent', () => { const createComponent = createComponentFactory({ component: DotFileFieldUiMessageComponent, detectChanges: false, - imports: [DotMessagePipe], + imports: [DotMessagePipe, CommonModule], providers: [ { provide: DotMessageService, diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.component.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.component.ts index da44a672d8ff..fb08b1907ff0 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.component.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.component.ts @@ -21,7 +21,7 @@ import { filter, map } from 'rxjs/operators'; import { DotAiService, DotMessageService } from '@dotcms/data-access'; import { DotCMSContentTypeField, DotGeneratedAIImage } from '@dotcms/dotcms-models'; -import { INPUT_TYPES, UploadedFile } from '@dotcms/edit-content/models/dot-edit-content-file.model'; +import { INPUT_TYPE, UploadedFile } from '@dotcms/edit-content/models/dot-edit-content-file.model'; import { DotDropZoneComponent, DotMessagePipe, @@ -162,7 +162,7 @@ export class DotEditContentFileFieldComponent implements ControlValueAccessor, O this.store.initLoad({ fieldVariable: field.variable, - inputType: field.fieldType as INPUT_TYPES + inputType: field.fieldType as INPUT_TYPE }); } diff --git a/core-web/libs/edit-content/src/test-setup.ts b/core-web/libs/edit-content/src/test-setup.ts index 1100b3e8a6ed..32c17d6888ff 100644 --- a/core-web/libs/edit-content/src/test-setup.ts +++ b/core-web/libs/edit-content/src/test-setup.ts @@ -1 +1,11 @@ import 'jest-preset-angular/setup-jest'; + +// Workaround for the following issue: +// https://github.com/jsdom/jsdom/issues/2177#issuecomment-1724971596 +const originalConsoleError = console.error; +const jsDomCssError = 'Error: Could not parse CSS stylesheet'; +console.error = (...params) => { + if (!params.find((p) => p.toString().includes(jsDomCssError))) { + originalConsoleError(...params); + } +}; \ No newline at end of file