Skip to content

Commit 1881587

Browse files
authored
32952 fakerjs (#33056)
### Proposed Changes This pull request refactors the usage and location of the `FieldUtil` utility and related test helpers across the codebase. The main goal is to move `FieldUtil` from the testing utilities into the main utilities library, ensuring consistent usage in both production and test code. Additionally, some test helpers are updated to use more specific field creators, and minor code cleanups are performed. Key changes include: **Refactoring and relocation of FieldUtil:** * Moved `FieldUtil` from `@dotcms/utils-testing` to `@dotcms/utils`, updating all imports across the codebase to use the new location. This affects multiple components, services, and test files related to content type fields. [[1]](diffhunk://#diff-68265dbaa48f0d088fb144f7cd1d3bdf5de62807350ff08098becc2086c909bdL1-R5) [[2]](diffhunk://#diff-eed6eb3b744d97d82e3e08ddbe4d1caa3d2638239b5637b2b89eef8cc5e5349aR7) [[3]](diffhunk://#diff-9ab5f7453058fb177f148e614b6ad8e8864543f824713a0d24ab570c12d737f1L41) [[4]](diffhunk://#diff-1eb2ec9164ddd81069ea68f09a2101536b6fa645ac5541bbda106ce4594921d2L1-R1) [[5]](diffhunk://#diff-f84382de3a3f4b0acad278da4d85bd63c44fa77a221a647e116e6757e795895dL6-R6) [[6]](diffhunk://#diff-071c449a7eb3a0aec4deb1488aa21e344fa74755d4923842f82bdda2b98fee8aL5-R5) [[7]](diffhunk://#diff-613673a154d00a52abad3ef967e298ddb3fb36304a5e1c0537cb2a0b14445950L10-R10) [[8]](diffhunk://#diff-f0119127a051b02bbf50323b94f33be9e6203fd63e6907a3be68166fdd27953eL11-R12) [[9]](diffhunk://#diff-c699a0270b0ddb9f06480224ce811b1bc47335d275fe9ffa9c3da396c065e400L37-R37) [[10]](diffhunk://#diff-d3c22cf0ac2d57f6d02b13c6120b253c92d8c8f5a3948dfe8e19a29d61f1fb2aL17-R18) [[11]](diffhunk://#diff-c4c77fba3abe168b6fcc536e786ae05dc32bc3f04bd31a2effecc79decab5fb2L51-L59) [[12]](diffhunk://#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9R24-R31) * Updated the implementation of `FieldUtil.isColumnBreak` usage to directly compare with `DotCMSClazzes.COLUMN_BREAK` instead of calling the method, simplifying the logic. **Test helper improvements:** * Replaced generic `createFakeTextField` calls in calendar field tests with more specific helpers (`createFakeDateField`, `createFakeDateTimeField`, `createFakeTimeField`) for better clarity and accuracy in test cases. (Fd7ae35aL1, [[1]](diffhunk://#diff-35a422266bdff3888f61420da49b048cd4bca48cd1303e85ffeee171839162f3L511-R517) [[2]](diffhunk://#diff-35a422266bdff3888f61420da49b048cd4bca48cd1303e85ffeee171839162f3L534-R539) [[3]](diffhunk://#diff-35a422266bdff3888f61420da49b048cd4bca48cd1303e85ffeee171839162f3L553-R557) [[4]](diffhunk://#diff-35a422266bdff3888f61420da49b048cd4bca48cd1303e85ffeee171839162f3L580-R581) [[5]](diffhunk://#diff-35a422266bdff3888f61420da49b048cd4bca48cd1303e85ffeee171839162f3L613-R615) **Other code cleanups:** * Removed unused imports (e.g., `faker`) from component files and replaced random number generation with standard JavaScript functions where appropriate. [[1]](diffhunk://#diff-b6e7f5a1ad7c221178b3ddf3f3dfc06021ba87b4e18ef9d7f6c6c9a6eab016d3L1-L2) [[2]](diffhunk://#diff-b6e7f5a1ad7c221178b3ddf3f3dfc06021ba87b4e18ef9d7f6c6c9a6eab016d3L111-R109) * Moved the definition of `EMPTY_ROWS_VALUE` from a mock file into the main gridstack utilities file for better accessibility and maintainability. [[1]](diffhunk://#diff-f3792a46b295fb618b6d4a8d8f4ecef72ec5e3c41a470d6a44886881a6b93659L5-L6) [[2]](diffhunk://#diff-f3792a46b295fb618b6d4a8d8f4ecef72ec5e3c41a470d6a44886881a6b93659R17-R44) * Fixed import of `EMPTY_FIELD` in test files to use the main utilities package. ### Checklist - [ ] Tests - [ ] Translations - [ ] Security Implications Contemplated (add notes if applicable) ### Additional Info ** any additional useful context or info ** ### Screenshots ![Uploading share.png…]() This PR fixes: #32952
1 parent 190b703 commit 1881587

File tree

19 files changed

+1193
-236
lines changed

19 files changed

+1193
-236
lines changed

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-drop-zone/content-type-fields-drop-zone.component.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ import {
4848
DotIconModule,
4949
DotMessagePipe
5050
} from '@dotcms/ui';
51-
import { DotLoadingIndicatorService } from '@dotcms/utils';
51+
import { DotLoadingIndicatorService, FieldUtil } from '@dotcms/utils';
5252
import {
5353
cleanUpDialog,
5454
CoreWebServiceMock,
5555
dotcmsContentTypeBasicMock,
5656
dotcmsContentTypeFieldBasicMock,
5757
fieldsBrokenWithColumns,
5858
fieldsWithBreakColumn,
59-
FieldUtil,
6059
MockDotMessageService
6160
} from '@dotcms/utils-testing';
6261

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-drop-zone/content-type-fields-drop-zone.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import { takeUntil } from 'rxjs/operators';
2121

2222
import { DotEventsService, DotMessageService } from '@dotcms/data-access';
2323
import {
24+
DotCMSClazzes,
2425
DotCMSContentType,
2526
DotCMSContentTypeField,
2627
DotCMSContentTypeLayoutColumn,
2728
DotCMSContentTypeLayoutRow,
2829
DotDialogActions
2930
} from '@dotcms/dotcms-models';
30-
import { DotLoadingIndicatorService } from '@dotcms/utils';
31-
import { FieldUtil } from '@dotcms/utils-testing';
31+
import { DotLoadingIndicatorService, FieldUtil } from '@dotcms/utils';
3232

3333
import { ContentTypeFieldsPropertiesFormComponent } from '../content-type-fields-properties-form';
3434
import { FieldType } from '../models';
@@ -114,7 +114,7 @@ export class ContentTypeFieldsDropZoneComponent implements OnInit, OnChanges, On
114114

115115
private static findColumnBreakIndex(fields: DotCMSContentTypeField[]): number {
116116
return fields.findIndex((item: DotCMSContentTypeField) => {
117-
return FieldUtil.isColumnBreak(item.clazz);
117+
return item.clazz === DotCMSClazzes.COLUMN_BREAK;
118118
});
119119
}
120120

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-row/content-type-fields-row.component.spec.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ import {
1414
DotCMSContentTypeLayoutRow
1515
} from '@dotcms/dotcms-models';
1616
import { DotMessagePipe } from '@dotcms/ui';
17-
import {
18-
dotcmsContentTypeFieldBasicMock,
19-
FieldUtil,
20-
MockDotMessageService
21-
} from '@dotcms/utils-testing';
17+
import { FieldUtil } from '@dotcms/utils';
18+
import { dotcmsContentTypeFieldBasicMock, MockDotMessageService } from '@dotcms/utils-testing';
2219

2320
import { ContentTypeFieldsRowComponent } from '.';
2421

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-row/content-type-fields-row.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnInit, Output, inject } from '@angular
22

33
import { DotAlertConfirmService, DotMessageService } from '@dotcms/data-access';
44
import { DotCMSContentTypeField, DotCMSContentTypeLayoutRow } from '@dotcms/dotcms-models';
5-
import { FieldUtil } from '@dotcms/utils-testing';
5+
import { FieldUtil } from '@dotcms/utils';
66

77
/**
88
* Display all the Field Types

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-types-fields-list/content-types-fields-icon-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FieldUtil } from '@dotcms/utils-testing';
1+
import { FieldUtil } from '@dotcms/utils';
22

33
const COLUMN_BREAK = FieldUtil.createColumnBreak();
44

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-types-fields-list/content-types-fields-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, inject, Input, OnInit, signal } from '@angular/core';
33
import { filter, mergeMap, take, toArray } from 'rxjs/operators';
44

55
import { DotCMSClazz, DotCMSClazzes } from '@dotcms/dotcms-models';
6-
import { FieldUtil } from '@dotcms/utils-testing';
6+
import { FieldUtil } from '@dotcms/utils';
77

88
import { FIELD_ICONS } from './content-types-fields-icon-map';
99

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/dot-content-type-fields-variables/dot-content-type-fields-variables.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { DotMessageDisplayService } from '@dotcms/data-access';
88
import { LoginService } from '@dotcms/dotcms-js';
99
import { DotCMSClazzes, DotCMSContentTypeField, DotFieldVariable } from '@dotcms/dotcms-models';
1010
import { DotKeyValueComponent } from '@dotcms/ui';
11+
import { EMPTY_FIELD } from '@dotcms/utils';
1112
import {
1213
dotcmsContentTypeFieldBasicMock,
1314
DotFieldVariablesServiceMock,
14-
EMPTY_FIELD,
1515
LoginServiceMock,
1616
mockFieldVariables
1717
} from '@dotcms/utils-testing';

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/service/field-drag-drop.service.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { TestBed } from '@angular/core/testing';
88
import { filter, map } from 'rxjs/operators';
99

1010
import { DotAlertConfirmService, DotMessageService } from '@dotcms/data-access';
11-
import { FieldUtil, MockDotMessageService } from '@dotcms/utils-testing';
11+
import { FieldUtil } from '@dotcms/utils';
12+
import { MockDotMessageService } from '@dotcms/utils-testing';
1213

1314
import { FieldDragDropService } from './field-drag-drop.service';
1415

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/service/field-drag-drop.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { filter, map, tap } from 'rxjs/operators';
77

88
import { DotAlertConfirmService, DotMessageService } from '@dotcms/data-access';
99
import { DotCMSContentTypeField, DotCMSContentTypeLayoutRow } from '@dotcms/dotcms-models';
10-
import { FieldUtil } from '@dotcms/utils-testing';
10+
import { FieldUtil } from '@dotcms/utils';
1111

1212
const MAX_COLS_PER_ROW = 4;
1313

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/form/content-types-form.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ import {
3434
DotCMSWorkflow,
3535
FeaturedFlags
3636
} from '@dotcms/dotcms-models';
37-
import { isEqual } from '@dotcms/utils';
38-
import { FieldUtil } from '@dotcms/utils-testing';
37+
import { isEqual, FieldUtil } from '@dotcms/utils';
3938

4039
/**
4140
* Form component to create or edit content types

0 commit comments

Comments
 (0)