Skip to content

feat(content-types): Introduce field types for content model #31964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

nicobytes
Copy link
Contributor

@nicobytes nicobytes commented Apr 23, 2025

Proposed Changes

This pull request introduces several updates to improve test data management and enhance the clarity of mock data in the dotcms-ui tests. The most significant changes include the addition of the forceIncludeInApi property to mock content type fields, the use of strongly typed mock objects, and the replacement of repetitive mock definitions with reusable helper functions.

Enhancements to mock data:

  • Added the forceIncludeInApi property to mock content type fields in multiple test cases to reflect updated field attributes. (dot-add-variable.component.spec.ts: [1] [2] [3] [4]; dot-block-editor-sidebar.component.spec.ts: [5]

Refactoring of mock definitions:

  • Replaced inline mock definitions with reusable helper functions like createFakeTextField, createFakeBlockEditorField, createFakeRowField, and others, to improve code maintainability and readability. (content-type-fields-drop-zone.component.spec.ts: [1] [2] [3] [4] [5] [6] [7] [8] [9]

Strongly typed mock objects:

  • Updated mock objects to use the DotCMSContentTypeField type explicitly, ensuring type safety and consistency across test cases. (content-type-field-dragabble-item.component.spec.ts: [1] [2] [3] [4] [5] [6] [7] [8] [9]

These changes improve test reliability, streamline mock data creation, and ensure better alignment with the application's evolving data model.

Checklist

  • Tests
  • Translations
  • Security Implications Contemplated (add notes if applicable)

Copy link

Please use a Conventional Commit title format for this PR. For more information, see https://www.conventionalcommits.org/en/v1.0.0/

@nicobytes nicobytes changed the title feat(content-types): Introduce new data types and field types for Dot… feat(content-types): Introduce field types for content model Apr 23, 2025
Copy link

Please use a Conventional Commit title format for this PR. For more information, see https://www.conventionalcommits.org/en/v1.0.0/

…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…ntentType in unit tests for improved clarity and consistencys
…ce mock data creation for improved test clarity and maintainability
…ional data types and update related components for improved flexibility
…ck data creation for enhanced test clarity and maintainability
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…BasicMock in unit tests for improved clarity and maintainability
…-aligning-resolutionvalue-and-getfinalcastedvalue' of github.com:dotCMS/core into 31911-refactor-unify-field-type-transformation-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
… improved clarity and maintainability, and enhance mock data consistency across components
…FakeBaseField to use static boolean values for improved consistency and clarity
…m and ContentTypesForm components to enhance mock data consistency and improve test clarity
…onditionally render relationship tree and improve type safety in field definitions
@nicobytes nicobytes requested a review from Copilot April 24, 2025 16:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors and enhances test data management for content types by replacing inline mock definitions with reusable helper functions and introducing a new property (forceIncludeInApi) to better simulate field attributes. Key changes include:

  • Replacing spread-based mock objects with strongly typed createFake* helper functions.
  • Adding the forceIncludeInApi property in multiple test cases.
  • Updating various test files for improved maintainability and clarity.

Reviewed Changes

Copilot reviewed 69 out of 69 changed files in this pull request and generated no comments.

File Description
core-web/libs/dotcms-field-elements/src/components/dot-form/utils/index.ts Minor formatting improvements and helper refactoring in utility functions.
core-web/libs/dotcms-field-elements/src/components/dot-form/utils/fields.tsx Refactored mock definitions to use typed helper functions.
dot-content-types-edit.component.spec.ts and related tests Replaced inline mocks with reusable createFake* helpers and updated test expectations.
dot-add-variable.component.spec.ts, dot-block-editor-sidebar.component.spec.ts Added forceIncludeInApi property to updated test mock objects.
Comments suppressed due to low confidence (2)

core-web/libs/dotcms-field-elements/src/components/dot-form/utils/index.ts:110

  • Consider adding error handling (e.g., try-catch) around JSON.parse to prevent runtime exceptions when the message is not valid JSON.
const messageObj = JSON.parse(message);

core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-field-dragabble-item/content-type-field-dragabble-item.component.spec.ts:62

  • [nitpick] Consider using the createFakeTextField helper for consistency with the rest of the test suite instead of spreading dotcmsContentTypeFieldBasicMock.
const field: DotCMSContentTypeField = { ...dotcmsContentTypeFieldBasicMock, fixed: true, ... }

…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
@nicobytes nicobytes marked this pull request as ready for review April 24, 2025 16:19
…ed utility file for improved clarity and maintainability
…tions for improved clarity and maintainability
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…tilize consistent mock data and improve clarity
…rSeoComponent and enhance test assertions for clarity
… Time, Select, Radio, and Flattened Field resolutions with comprehensive cases and assertions
…support numeric timestamps and improve form value processing in DotEditContentFormComponent
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…-aligning-resolutionvalue-and-getfinalcastedvalue' of github.com:dotCMS/core into 31911-refactor-unify-field-type-transformation-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
@nicobytes nicobytes requested review from oidacra and hmoreras April 28, 2025 15:50
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
@Input({ required: true })
set field(contentTypeField: DotCMSContentTypeField) {
this.$field.set(contentTypeField);
}
@Input({ required: true }) contentlet: DotCMSContentlet;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new api?

@Input({ required: true }) contentlet: DotCMSContentlet;
@Input() imageEditor = false;

$field = signal<DotCMSContentTypeField>({} as DotCMSContentTypeField);
$field = input.required<ContentTypeBinaryField>({ alias: 'field' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we use the old api here because we use this in DOJO. The new api failed.

'com.dotcms.contenttype.model.field.ImmutableTextAreaField',
'com.dotcms.contenttype.model.field.ImmutableTextField'
#dotFormFields: string[] = [
DotCMSClazzes.BINARY,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

nicobytes added 2 commits May 2, 2025 10:15
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
nicobytes added 7 commits May 6, 2025 11:03
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
…on-logic-by-aligning-resolutionvalue-and-getfinalcastedvalue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor: Unify field type transformation logic by aligning resolutionValue and getFinalCastedValue
3 participants