Skip to content

Conversation

skipper-vp
Copy link
Contributor

@skipper-vp skipper-vp commented May 20, 2025

#406

Summary by CodeRabbit

  • New Features
    • Added support for filling datetime fields with separate date and time inputs in forms.
  • Documentation
    • Updated documentation to include usage examples and Gherkin syntax for date, time, and datetime field steps.
  • Tests
    • Introduced new end-to-end tests to verify correct handling and display of datetime fields in the user interface.
  • Configuration
    • Added new datetime fields to the article content type with corresponding form and view display settings.

Copy link

coderabbitai bot commented May 20, 2025

"""

Walkthrough

Support for datetime fields has been added to the FieldTrait by introducing new methods to fill date, time, and combined datetime inputs. Documentation in STEPS.md was extended with new step definitions and usage examples. A new Behat feature test verifies the handling and display of datetime fields via the UI. Configuration files for the article content type were updated to include field_date_and_time and field_date_only datetime fields with appropriate form and view display settings.

Changes

File(s) Change Summary
src/FieldTrait.php Added fieldFillDateTime, fieldFillDate, and helper method to fill datetime fields with date and time inputs. Updated documentation.
STEPS.md Extended documentation with step definitions and usage examples for filling date, time, and datetime fields.
tests/behat/features/field_datetime.feature Added Behat feature test to verify filling and displaying datetime and date-only fields via the UI.
tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_and_time.yml Added new datetime field configuration for field_date_and_time on article content type.
tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_and_time.yml Added new field storage configuration for the datetime field field_date_and_time.
tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_only.yml Added new datetime field configuration for field_date_only on article content type.
tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_only.yml Added new field storage configuration for the date-only field field_date_only.
tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml Added field_date_and_time and field_date_only with datetime_default widget to article node form display.
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml Added field_date_and_time and field_date_only display configurations with datetime_default formatter for article node view.
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.rss.yml Added field_date_and_time and field_date_only to dependencies and hidden fields in RSS view mode for article nodes.
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_index.yml Added field_date_and_time and field_date_only as hidden field dependencies in search_index view mode for article nodes.
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_result.yml Added field_date_and_time and field_date_only as hidden field dependencies in search_result view mode for article nodes.
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.teaser.yml Added field_date_and_time and field_date_only as hidden field dependencies in teaser view mode for article nodes.

Sequence Diagram(s)

sequenceDiagram
    participant Tester
    participant FieldTrait
    participant Form
    Tester->>FieldTrait: fieldFillDateTime(label, date, time)
    FieldTrait->>Form: Locate date input by label
    FieldTrait->>Form: Set date input value
    FieldTrait->>Form: Locate time input by label
    FieldTrait->>Form: Set time input value
    Form-->>Tester: Datetime field filled
Loading

Suggested labels

PR: Needs review

Suggested reviewers

  • AlexSkrypnyk

Poem

A hop and a skip, a date and a time,
Now fields can be filled in rhythm and rhyme.
With widgets for moments both morning and night,
The tests leap ahead, all features in sight.
🐇✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 48f6c68 and 2316f40.

📒 Files selected for processing (23)
  • STEPS.md (2 hunks)
  • src/FieldTrait.php (2 hunks)
  • tests/behat/features/field_datetime.feature (1 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml (3 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.rss.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_index.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_result.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.teaser.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_and_time.yml (1 hunks)
  • tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_only.yml (1 hunks)
  • tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_and_time.yml (1 hunks)
  • tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_only.yml (1 hunks)
  • tests/behat/fixtures/d11/config/sync/core.entity_form_display.node.article.default.yml (3 hunks)
  • tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.default.yml (2 hunks)
  • tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.rss.yml (2 hunks)
  • tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.search_index.yml (2 hunks)
  • tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.search_result.yml (2 hunks)
  • tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.teaser.yml (2 hunks)
  • tests/behat/fixtures/d11/config/sync/field.field.node.article.field_date_and_time.yml (1 hunks)
  • tests/behat/fixtures/d11/config/sync/field.field.node.article.field_date_only.yml (1 hunks)
  • tests/behat/fixtures/d11/config/sync/field.storage.node.field_date_and_time.yml (1 hunks)
  • tests/behat/fixtures/d11/config/sync/field.storage.node.field_date_only.yml (1 hunks)
🔇 Additional comments (41)
tests/behat/fixtures/d11/config/sync/field.storage.node.field_date_only.yml (1)

1-21: New field storage configuration for field_date_only is valid.
The YAML correctly defines a date-only datetime field with single cardinality, translation enabled, and appropriate module dependencies (datetime, node). All necessary storage settings are present.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_result.yml (2)

9-10: Dependencies for new datetime fields properly added.
Both field_date_and_time and field_date_only are listed under dependencies.config, ensuring the view mode picks up the new fields.


58-59: Hidden flags for new datetime fields are correctly applied.
Marking field_date_and_time and field_date_only as hidden maintains the existing appearance of the search result view.

tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.search_result.yml (2)

9-10: Dependencies for new datetime fields properly added.
Both field_date_and_time and field_date_only are listed under dependencies.config, ensuring the view mode picks up the new fields in the D11 fixture.


58-59: Hidden flags for new datetime fields are correctly applied.
Marking field_date_and_time and field_date_only as hidden maintains the existing appearance of the search result view in the D11 fixture.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_index.yml (2)

10-11: Dependencies for new datetime fields properly added.
The search_index view now depends on field_date_and_time and field_date_only, matching the new field additions.


56-57: Hidden flags for new datetime fields are correctly applied.
Fields are marked hidden to prevent UI changes in the search index display.

tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.search_index.yml (2)

10-11: Dependencies for new datetime fields properly added.
The search_index view in the D11 fixture now includes field_date_and_time and field_date_only dependencies.


56-57: Hidden flags for new datetime fields are correctly applied.
Ensures consistent hiding of the new fields in the search index display for the D11 fixture.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.teaser.yml (2)

9-11: Add new datetime field dependencies
The field_date_and_time, field_date_only, and field_file entries have been correctly added under dependencies.config. Please confirm that this aligns with other view modes (default, rss, search_index, search_result) to maintain consistency.


64-65: Hide new datetime fields in teaser view
Marking field_date_and_time and field_date_only as hidden is appropriate for the teaser display. Verify that these fields remain hidden in all relevant display modes where they shouldn’t surface.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.rss.yml (2)

9-11: Include datetime fields as dependencies in RSS view
The field_date_and_time, field_date_only, and field_file have been added to the RSS mode dependencies. Ensure the added dependencies match the pattern used in other view modes for this content type.


35-36: Hide datetime fields in RSS output
field_date_and_time and field_date_only are now correctly hidden. Confirm that these fields are intentionally excluded from RSS feeds to prevent unintended data exposure.

tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml (3)

8-9: Add datetime fields to form display dependencies
Good addition of field_date_and_time and field_date_only under dependencies.config—necessary for correct import ordering.


19-19: Add datetime module dependency
Including the datetime module is required for the new widget. Ensure this module is enabled in your test environment.


53-64: Configure datetime and date-only widgets
The new fields use the datetime_default widget with appropriate weights (26 & 27). Verify these weight assignments place them in the intended order relative to existing fields.

STEPS.md (3)

484-484: Document FieldTrait datetime support
The bullet has been updated to reflect support for datetime, date, and time. The change accurately describes the new capabilities of FieldTrait.


529-541:

✅ Verification successful

Verify implementation of date-only step definition
The step @When I fill in the date field :label with date :date is documented here. Ensure a matching method and annotation are present in src/FieldTrait.php.


🏁 Script executed:

#!/bin/bash
# Check for date field step definition in FieldTrait.php
grep -R "@When I fill in the date field" src/FieldTrait.php

Length of output: 120


🏁 Script executed:

#!/bin/bash
# Show context around the date field step definition in FieldTrait.php
grep -R -n -A5 -B2 "@When I fill in the date field" src/FieldTrait.php

Length of output: 320


Step definition verified
The @When I fill in the date field :label with date :date annotation and its handler fieldFillDate exist in src/FieldTrait.php (lines 232–236), invoking fieldFillDateTimeField($label, 'date', $date).


515-526:

✅ Verification successful

Verify implementation of datetime step definition
You've added the Gherkin step for @When I fill in the datetime field :label with date :date and time :time. Please confirm that the corresponding method and @When annotation exist in src/FieldTrait.php.


🏁 Script executed:

#!/bin/bash
# Check for datetime field step definition in FieldTrait.php
grep -R "@When I fill in the datetime field" src/FieldTrait.php

Length of output: 143


🏁 Script executed:

#!/bin/bash
# Show the @When annotation and its method implementation context
grep -R -n -A10 "@When I fill in the datetime field" src/FieldTrait.php

Length of output: 475


Implementation Verified: datetime field step definition added
The @When I fill in the datetime field :label with date :date and time :time annotation and its handler method fieldFillDateTime(string $label, string $date, string $time) are present in src/FieldTrait.php (lines 218–223). No further action required.

tests/behat/fixtures/d11/config/sync/core.entity_form_display.node.article.default.yml (3)

8-9: New datetime fields added to form display dependencies
The two new field dependencies have been correctly included under config.


19-19: Module dependency for datetime widget
The datetime module is now properly listed to support the datetime_default widget.


53-64: Form display configuration for date/time fields
The field_date_and_time and field_date_only widgets are correctly configured with datetime_default, weights, regions, and empty settings.

tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.rss.yml (2)

9-11: Add new datetime field dependencies to RSS view
The two datetime fields and the existing file field have been correctly added under config dependencies.


35-36: Hide new datetime fields in RSS output
Both field_date_and_time and field_date_only are now hidden in the RSS view, matching the intended visibility.

tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_only.yml (1)

1-21: Field configuration for date-only field
The field_date_only field is defined with correct UUID, dependencies, module, and field type.

tests/behat/fixtures/d11/config/sync/field.field.node.article.field_date_and_time.yml (1)

1-21: Field configuration for combined date/time field
The field_date_and_time field is defined with correct UUID, dependencies, module, and field type.

tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.default.yml (3)

9-10: Add new datetime field dependencies to default view
The new datetime fields have been correctly added under config dependencies.


18-18: Module dependency for datetime formatter
The datetime module is now listed, ensuring the datetime_default formatter is available.


51-68: View display configuration for datetime fields
The field_date_and_time and field_date_only formatters are correctly set with label, format, weights, and region.

tests/behat/fixtures/d11/config/sync/field.field.node.article.field_date_only.yml (2)

1-21: Correctly defined date-only field configuration
The field configuration for field_date_only on the article content type is declared with the proper id, field_name, entity_type, and field_type. Dependencies on the storage config and the datetime module are accurate, and the required/translatable flags align with expectations.


4-9:

✅ Verification successful

Ensure form and view display include new field
I don’t see updates to core.entity_form_display.*.node.article.*.yml or core.entity_view_display.*.node.article.*.yml for field_date_only. Please verify these fixtures include the new field with the appropriate widget and formatter.


🏁 Script executed:

#!/bin/bash
# Verify entity form and view display configs for field_date_only
rg -l 'field_date_only' tests/behat/fixtures/{d10,d11}/config/sync/core.entity_form_display.node.article.*.yml
rg -l 'field_date_only' tests/behat/fixtures/{d10,d11}/config/sync/core.entity_view_display.node.article.*.yml

Length of output: 2159


All display fixtures updated with field_date_only
I’ve confirmed that both the form and view display configs include the new field in the D10 and D11 fixtures:

  • tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml
  • tests/behat/fixtures/d11/config/sync/core.entity_form_display.node.article.default.yml
  • All core.entity_view_display.node.article.*.yml files under tests/behat/fixtures/{d10,d11}/config/sync/

No further changes are required here.

tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_only.yml (1)

1-20: Validated storage configuration for date-only field
The storage definition correctly specifies type: datetime with settings.datetime_type: date. Dependencies (datetime, node), cardinality, and translatability are appropriately set, matching Drupal standards.

tests/behat/fixtures/d11/config/sync/field.storage.node.field_date_and_time.yml (1)

1-20: Validated storage configuration for combined datetime field
The storage config for field_date_and_time uses type: datetime with settings.datetime_type: datetime. Dependencies, cardinality, and translatability align with expectations for a single-valued datetime field.

tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_and_time.yml (2)

1-21: Correctly defined combined datetime field configuration
The configuration for field_date_and_time on the article bundle matches its storage definition and includes the correct dependencies (field.storage.node.field_date_and_time, node.type.article, datetime).


4-9:

✅ Verification successful

Ensure form and view display include new datetime field
Like field_date_only, confirm that field_date_and_time is present in your entity form and view display fixtures with the datetime_default widget and formatter.


🏁 Script executed:

#!/bin/bash
# Verify entity form and view display configs for field_date_and_time
rg -l 'field_date_and_time' tests/behat/fixtures/{d10,d11}/config/sync/core.entity_form_display.node.article.*.yml
rg -l 'field_date_and_time' tests/behat/fixtures/{d10,d11}/config/sync/core.entity_view_display.node.article.*.yml

Length of output: 2167


🏁 Script executed:

#!/bin/bash
echo "===== Form Display d10 ====="
rg -C3 'field_date_and_time' tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml
echo "===== Form Display d11 ====="
rg -C3 'field_date_and_time' tests/behat/fixtures/d11/config/sync/core.entity_form_display.node.article.default.yml
echo "===== View Display d10 ====="
rg -C3 'field_date_and_time' tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml
echo "===== View Display d11 ====="
rg -C3 'field_date_and_time' tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.default.yml

Length of output: 2507


field_date_and_time form & view displays validated
The field_date_and_time field is present in both the form and view display fixtures for Drupal 10 and 11, using the datetime_default widget and formatter as expected.

Affected files:

  • tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml
  • tests/behat/fixtures/d11/config/sync/core.entity_form_display.node.article.default.yml
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml
  • tests/behat/fixtures/d11/config/sync/core.entity_view_display.node.article.default.yml
tests/behat/features/field_datetime.feature (3)

1-5: LGTM! Well-structured feature description.

The feature file has a clear description that explains the purpose of the datetime field handling tests.


7-17: LGTM! Complete datetime field test scenario.

The scenario correctly tests filling both date and time values in a datetime field and verifies the expected output format.


19-30: LGTM! Well-defined date-only field test scenario.

This scenario appropriately tests the date-only field functionality with clear steps and assertions.

src/FieldTrait.php (3)

18-18: LGTM! Documentation update for datetime support.

The trait documentation has been appropriately updated to include the new datetime field support.


211-223: LGTM! Well-implemented method for filling datetime fields.

The fieldFillDateTime method effectively delegates to the helper method to fill both date and time components.


225-236: LGTM! Clean implementation for date-only fields.

The fieldFillDate method correctly implements filling only the date component of a datetime field.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@skipper-vp skipper-vp added the Do not review Do not review this pull request label May 20, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d27528 and c69397f.

📒 Files selected for processing (3)
  • STEPS.md (2 hunks)
  • src/FieldTrait.php (2 hunks)
  • tests/behat/features/field_datetime.feature (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
STEPS.md

484-484: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


484-484: Multiple spaces after blockquote symbol
null

(MD027, no-multiple-space-blockquote)


515-515: Inline HTML
Element: details

(MD033, no-inline-html)


516-516: Inline HTML
Element: summary

(MD033, no-inline-html)


516-516: Inline HTML
Element: code

(MD033, no-inline-html)


518-518: Inline HTML
Element: br

(MD033, no-inline-html)


520-520: Inline HTML
Element: br

(MD033, no-inline-html)


520-520: Inline HTML
Element: br

(MD033, no-inline-html)


529-529: Inline HTML
Element: details

(MD033, no-inline-html)


530-530: Inline HTML
Element: summary

(MD033, no-inline-html)


530-530: Inline HTML
Element: code

(MD033, no-inline-html)


532-532: Inline HTML
Element: br

(MD033, no-inline-html)


534-534: Inline HTML
Element: br

(MD033, no-inline-html)


534-534: Inline HTML
Element: br

(MD033, no-inline-html)


543-543: Inline HTML
Element: details

(MD033, no-inline-html)


544-544: Inline HTML
Element: summary

(MD033, no-inline-html)


544-544: Inline HTML
Element: code

(MD033, no-inline-html)


546-546: Inline HTML
Element: br

(MD033, no-inline-html)


548-548: Inline HTML
Element: br

(MD033, no-inline-html)


548-548: Inline HTML
Element: br

(MD033, no-inline-html)

🔇 Additional comments (7)
src/FieldTrait.php (2)

18-18: Documentation update correctly reflects new functionality.

The trait documentation has been appropriately updated to mention the new support for datetime field widgets.


211-223: Implementation for datetime field handling looks good.

The new public method provides a clean interface for filling datetime fields with separate date and time components. The method signature and documentation are clear and follow the established pattern in the trait.

STEPS.md (2)

484-484: Documentation update properly reflects the new functionality.

The FieldTrait description has been updated to include support for datetime field widgets.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

484-484: Unordered list indentation
Expected: 0; Actual: 1

(MD007, ul-indent)


484-484: Multiple spaces after blockquote symbol
null

(MD027, no-multiple-space-blockquote)


543-555: Step definition for datetime fields matches implementation.

This documentation correctly describes the implemented datetime field functionality and provides a clear example that matches the implementation in FieldTrait.php.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

543-543: Inline HTML
Element: details

(MD033, no-inline-html)


544-544: Inline HTML
Element: summary

(MD033, no-inline-html)


544-544: Inline HTML
Element: code

(MD033, no-inline-html)


546-546: Inline HTML
Element: br

(MD033, no-inline-html)


548-548: Inline HTML
Element: br

(MD033, no-inline-html)


548-548: Inline HTML
Element: br

(MD033, no-inline-html)

tests/behat/features/field_datetime.feature (3)

1-17: Test scenario validates the datetime field functionality.

This is a well-structured Behat test scenario that:

  1. Sets up the context (admin user, content creation form)
  2. Exercises the new datetime field functionality
  3. Verifies the expected output (field label and formatted datetime value)

The test provides good coverage for the newly added feature.


11-11: Usage example aligns with implementation.

This line demonstrates the proper usage of the new step definition for filling in a datetime field, matching the implementation in FieldTrait.php and the documentation in STEPS.md.


17-17: Verification of formatted output is a good practice.

Checking for the formatted datetime output validates that the field was not only filled but also properly processed and displayed by the application.

Comment on lines +251 to +262
throw new \Exception(sprintf('Date field with label "%s" value not found', $label));
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Error message could be more specific.

The error message only mentions "Date field" even when the method might be looking for a time input element.

Consider making the error message reflect the actual field type being searched:

-      throw new \Exception(sprintf('Date field with label "%s" value not found', $label));
+      throw new \Exception(sprintf('%s field with label "%s" value not found', ucfirst($field), $label));

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/FieldTrait.php around lines 251 to 252, the error message always refers
to a "Date field" even when the method might be searching for a time input
element. Modify the error message to dynamically include the actual field type
being searched for, such as "Date field" or "Time field," to make the error more
specific and informative.

STEPS.md Outdated
Comment on lines 529 to 527
<details>
<summary><code>@When I fill in the time field :label with :time</code></summary>

<br/>
Fill a time field with a time value
<br/><br/>

```gherkin
When I fill in the time field "Event time" with "14:30:00"
```

</details>
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Step definition for time fields is well documented.

The documentation for filling time fields is clear and includes a proper Gherkin syntax example.

Similarly, please verify that this step definition is implemented elsewhere or needs to be added:


🏁 Script executed:

#!/bin/bash
# Check if there's an implementation for the time field step
grep -r "fill in the time field" src/

Length of output: 39


🏁 Script executed:

#!/bin/bash
# Search entire repository for any implementation of the "fill in the time field" step
grep -R "fill in the time field" -n .
grep -R "I fill in the time field" -n .
# Also look specifically in the typical Cucumber step definitions folder
grep -R "time field" -n features/step_definitions

Length of output: 536


Missing step definition for “fill in the time field”
The documentation in STEPS.md defines the Gherkin step, but no matching implementation exists under features/step_definitions. Please add or update a step definition. For example:

# File: features/step_definitions/time_field_steps.rb
When(/^I fill in the time field "([^"]+)" with "([^"]+)"$/) do |label, time|
  fill_in(label, with: time)
end
  • Create features/step_definitions/time_field_steps.rb (if it doesn’t exist)
  • Implement the step as shown (or adjust to your project’s conventions)
  • Ensure this file is loaded by Cucumber
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

529-529: Inline HTML
Element: details

(MD033, no-inline-html)


530-530: Inline HTML
Element: summary

(MD033, no-inline-html)


530-530: Inline HTML
Element: code

(MD033, no-inline-html)


532-532: Inline HTML
Element: br

(MD033, no-inline-html)


534-534: Inline HTML
Element: br

(MD033, no-inline-html)


534-534: Inline HTML
Element: br

(MD033, no-inline-html)

🤖 Prompt for AI Agents
In STEPS.md around lines 529 to 541, the Gherkin step for filling in a time
field is documented but lacks a corresponding step definition implementation in
features/step_definitions. To fix this, create a new Ruby step definition file
named time_field_steps.rb under features/step_definitions if it does not exist,
and add a step definition matching the documented step that uses fill_in to set
the time field value. Ensure this step definition file is properly loaded by
Cucumber during test runs.

STEPS.md Outdated
Comment on lines 515 to 527
<details>
<summary><code>@When I fill in the date field :label with :date</code></summary>

<br/>
Fill a date field with a date value
<br/><br/>

```gherkin
When I fill in the date field "Event date" with "2024-07-15"
```

</details>
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Step definition for date fields is well documented.

The documentation for filling date fields is clear and includes a proper Gherkin syntax example.

It seems this step definition is documented but I don't see a corresponding implementation method in the FieldTrait.php file. Please verify that this step definition is implemented elsewhere or needs to be added:


🏁 Script executed:

#!/bin/bash
# Check if there's an implementation for the date field step
grep -r "fill in the date field" src/

Length of output: 39


To ensure we didn’t miss a differently named implementation, let’s search the codebase for any mention of “date” in the context of FieldTrait and step annotations:


🏁 Script executed:

#!/bin/bash
# 1. Locate the FieldTrait.php file
field_trait=$(find src -type f -name FieldTrait.php)
echo "FieldTrait.php found at: $field_trait"

# 2. Check for any use of “date” within that trait
grep -R "date" -n "$field_trait"

# 3. Look for @When annotations mentioning “date field”
grep -R "@When.*date field" -n src/

# 4. Search for any method named fillInDateField
grep -R "fillInDateField" -n src/

Length of output: 870


Missing step implementation for date fields

The documentation in STEPS.md clearly defines a

@When I fill in the date field :label with :date

step, but there’s no corresponding method in FieldTrait.php (or any Context) handling it. Please add something like:

/**
 * Fill a date field with a date value.
 *
 * @When I fill in the date field :label with :date
 */
public function fieldFillDateField(string $label, string $date): void
{
    // Reuse the datetime helper for the date component
    $this->fieldFillDateTimeField($label, 'date', $date);
}

• File: src/FieldTrait.php
• Location: alongside the existing fieldFillDateTime method

If date-only fields are meant to be covered by another implementation, please either add an alias there or update the documentation to avoid confusion.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

515-515: Inline HTML
Element: details

(MD033, no-inline-html)


516-516: Inline HTML
Element: summary

(MD033, no-inline-html)


516-516: Inline HTML
Element: code

(MD033, no-inline-html)


518-518: Inline HTML
Element: br

(MD033, no-inline-html)


520-520: Inline HTML
Element: br

(MD033, no-inline-html)


520-520: Inline HTML
Element: br

(MD033, no-inline-html)

🤖 Prompt for AI Agents
In STEPS.md lines 515 to 527, the step definition for filling a date field is
documented but lacks a corresponding implementation in src/FieldTrait.php or any
Context file. To fix this, add a new method in FieldTrait.php similar to the
existing datetime method, annotated with @When for "I fill in the date field
:label with :date". This method should accept the label and date string
parameters and internally call the datetime helper method with the 'date'
component to handle the input. This ensures the documented step is properly
implemented and functional.

@skipper-vp skipper-vp force-pushed the feature/406-datetime-handling branch from c69397f to 23c6d1c Compare May 20, 2025 05:19
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (4)
STEPS.md (2)

515-527: 🛠️ Refactor suggestion

Missing implementation for date field step definition

The documentation defines a step for filling in a date field, but the implementation in src/FieldTrait.php only includes the combined datetime method (fieldFillDateTime), not a dedicated method for date fields only.

You should implement a dedicated method in FieldTrait.php to support this step:

/**
 * Fill a date field with a date value.
 *
 * @code
 * When I fill in the date field "Event date" with "2024-07-15"
 * @endcode
 *
 * @When I fill in the date field :label with :date
 */
public function fieldFillDateField(string $label, string $date): void {
  $this->fieldFillDateTimeField($label, 'date', $date);
}

529-541: 🛠️ Refactor suggestion

Missing implementation for time field step definition

The documentation defines a step for filling in a time field, but the implementation in src/FieldTrait.php only includes the combined datetime method (fieldFillDateTime), not a dedicated method for time fields only.

You should implement a dedicated method in FieldTrait.php to support this step:

/**
 * Fill a time field with a time value.
 *
 * @code
 * When I fill in the time field "Event time" with "14:30:00"
 * @endcode
 *
 * @When I fill in the time field :label with :time
 */
public function fieldFillTimeField(string $label, string $time): void {
  $this->fieldFillDateTimeField($label, 'time', $time);
}
src/FieldTrait.php (2)

238-253: 🛠️ Refactor suggestion

XPath selector should be more robust

The XPath selector assumes a specific HTML structure with the label in a span element with a specific parent-child relationship to the input fields.

Consider enhancing the method to be more robust by:

protected function fieldFillDateTimeField(string $label, string $field, string $value): void {
-  $xpath = sprintf(
-    '//span[contains(text(), "%s")]/../../div//input[contains(@name, "[%s]")]',
-    $label,
-    $field
-  );
+  // Try multiple selector strategies to find the field
+  $xpaths = [
+    // Strategy 1: Find by label text in a span element
+    sprintf('//span[contains(text(), "%s")]/../../div//input[contains(@name, "[%s]")]', $label, $field),
+    // Strategy 2: Find by label with 'for' attribute
+    sprintf('//label[contains(text(), "%s")]/@for', $label) . 
+      sprintf('/following::input[contains(@name, "[%s]")]', $field),
+    // Strategy 3: Find by fieldset legend
+    sprintf('//fieldset//legend[contains(text(), "%s")]/..//input[contains(@name, "[%s]")]', $label, $field),
+  ];
+
+  $page = $this->getSession()->getPage();
+  $element = null;
+
+  // Try each strategy until we find a matching element
+  foreach ($xpaths as $xpath) {
+    $element = $page->find('xpath', $xpath);
+    if ($element instanceof NodeElement) {
+      break;
+    }
+  }

-  $page = $this->getSession()->getPage();
-  $element = $page->find('xpath', $xpath);
   if ($element instanceof NodeElement) {
     $element->setValue($value);
   }
   else {
-    throw new \Exception(sprintf('Date field with label "%s" value not found', $label));
+    throw new \Exception(sprintf('%s field with label "%s" value not found', ucfirst($field), $label));
   }
}

251-252: 🧹 Nitpick (assertive)

Error message should reflect the field type

The error message always mentions "Date field" even when the method might be searching for a time input element.

- throw new \Exception(sprintf('Date field with label "%s" value not found', $label));
+ throw new \Exception(sprintf('%s field with label "%s" value not found', ucfirst($field), $label));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between c69397f and 23c6d1c.

📒 Files selected for processing (11)
  • STEPS.md (2 hunks)
  • src/FieldTrait.php (2 hunks)
  • tests/behat/features/field_datetime.feature (1 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml (3 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.rss.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_index.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_result.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.teaser.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_and_time.yml (1 hunks)
  • tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_and_time.yml (1 hunks)
🔇 Additional comments (18)
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_result.yml (2)

9-9: Added field_date_and_time to view dependencies

The new datetime field is correctly declared as a dependency in the search_result view display configuration.


57-57: Hide the field_date_and_time in search results

Marking the datetime field as hidden in this view mode aligns with the intended display settings.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_index.yml (2)

10-10: Include field_date_and_time in search index dependencies

The dependency list now correctly includes the new datetime field for the search_index view mode.


55-55: Hide the field_date_and_time in search index

The datetime field is properly hidden in the search index view, matching the configuration pattern of other fields.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.teaser.yml (2)

9-10: Dependencies updated for teaser view

Both field_date_and_time and field_file are added to the teaser view’s dependency list, ensuring the new field is known to the config.


63-63: Hide the field_date_and_time in teaser view

The datetime field is correctly hidden in the teaser display, consistent with other view modes.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.rss.yml (2)

9-10: Dependencies updated for RSS view

The RSS view display now depends on field_date_and_time alongside the existing fields.


34-34: Hide the field_date_and_time in RSS output

The datetime field is appropriately hidden in the RSS feed configuration.

tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml (3)

8-8: Verify default view display config updated

I don’t see the corresponding default view display config (core.entity_view_display.node.article.default.yml) in the fixtures; please confirm it’s been updated to include or hide the field_date_and_time consistently.


18-18: Added datetime module dependency for form display

Including the datetime module ensures the form widget for the new field will work as expected.


52-57: Configured new datetime field widget

The field_date_and_time is correctly added to the form display with the datetime_default widget, weight, region, and default settings.

STEPS.md (1)

543-555: Great documentation for the datetime field step

The documentation for the datetime field step is clear and comprehensive, providing good examples for users.

tests/behat/features/field_datetime.feature (1)

1-17: Well-structured test for datetime field handling

This feature test effectively validates the datetime field functionality, providing good coverage of the fill and display operations. The scenario follows a clear workflow from content creation to verification of the displayed values.

The test could be further enhanced in the future by adding scenarios for:

  1. Date-only field interactions
  2. Time-only field interactions
  3. Validation of incorrect date/time formats
tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_and_time.yml (1)

1-21: Correct field configuration for datetime implementation

The field configuration is correctly defined with appropriate dependencies and settings for a datetime field. The field label is clear and descriptive.

tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_and_time.yml (1)

1-20: Correct field storage configuration

The field storage configuration is properly defined with the datetime type set to handle both date and time values. The settings are appropriate for a standard datetime field implementation.

src/FieldTrait.php (2)

18-18: Good documentation update for the trait

The trait documentation is clearly updated to include datetime field support alongside other field types.


211-224: Well-implemented datetime field handling method

The fieldFillDateTime method provides a clean interface for filling both date and time components of a datetime field, with good code documentation and examples.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml (1)

17-17: Confirm the module dependency.

Including datetime under module dependencies is correct to ensure the datetime UI formatter is available at import time. No further changes needed here.

- core.entity_view_display.comment.comment.default
- field.field.node.article.body
- field.field.node.article.comment
- field.field.node.article.field_date_and_time
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Validate configuration dependencies for field storage.

The new view display adds a dependency on the field config field.field.node.article.field_date_and_time but omits the required field storage config field.storage.node.field_date_and_time. Without this, importing the configuration may fail.

Apply this diff to add the storage dependency:

 dependencies:
   config:
     - core.entity_view_display.comment.comment.default
     - field.field.node.article.body
     - field.field.node.article.comment
+    - field.storage.node.field_date_and_time
     - field.field.node.article.field_date_and_time
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- field.field.node.article.field_date_and_time
dependencies:
config:
- core.entity_view_display.comment.comment.default
- field.field.node.article.body
- field.field.node.article.comment
- field.storage.node.field_date_and_time
- field.field.node.article.field_date_and_time
🤖 Prompt for AI Agents
In
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml
at line 9, the configuration dependencies are missing the required field storage
config 'field.storage.node.field_date_and_time'. Add this field storage
dependency alongside the existing field config dependency to ensure proper
configuration import and avoid failures.

Comment on lines +50 to +59
field_date_and_time:
type: datetime_default
label: above
settings:
timezone_override: ''
format_type: medium
third_party_settings: { }
weight: 7
region: content
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Review view display settings for the datetime field.

The field_date_and_time display entry is correctly configured, but you may consider:

  1. Omitting the empty timezone_override: '' if you don’t intend to override the default site timezone.
  2. Removing the empty third_party_settings: {} for brevity.
  3. Verifying that weight: 7 places the field in the intended order relative to other content.
@@ content:
-  field_date_and_time:
-    type: datetime_default
-    label: above
-    settings:
-      timezone_override: ''
-      format_type: medium
-    third_party_settings: {  }
-    weight: 7
-    region: content
+  field_date_and_time:
+    type: datetime_default
+    label: above
+    settings:
+      format_type: medium
+    weight: 7   # ensure this ordering matches UX requirements
+    region: content
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
field_date_and_time:
type: datetime_default
label: above
settings:
timezone_override: ''
format_type: medium
third_party_settings: { }
weight: 7
region: content
field_date_and_time:
type: datetime_default
label: above
settings:
format_type: medium
weight: 7 # ensure this ordering matches UX requirements
region: content
🤖 Prompt for AI Agents
In
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml
around lines 50 to 58, the datetime field display settings include an empty
timezone_override and an empty third_party_settings object, which are
unnecessary. Remove the empty timezone_override line and the empty
third_party_settings entry to clean up the configuration. Also, double-check
that the weight value of 7 correctly positions the field in the desired display
order relative to other fields.

@skipper-vp skipper-vp force-pushed the feature/406-datetime-handling branch from 23c6d1c to 48f6c68 Compare May 20, 2025 23:41
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

♻️ Duplicate comments (4)
STEPS.md (2)

515-527: Verify existence of date field step implementation.
Ensure that the documented Gherkin step (@When I fill in the date field :label with :date) has a corresponding method annotated in FieldTrait.php or another context file.


529-541: Verify existence of time field step implementation.
Confirm that there is a matching step definition for (@When I fill in the time field :label with :time) in the codebase to avoid broken tests.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml (1)

51-59: 🧹 Nitpick (assertive)

Cleanup unnecessary empty settings.
The timezone_override: '' and empty third_party_settings: {} entries can be removed for brevity:

   field_date_and_time:
-    settings:
-      timezone_override: ''
-      format_type: medium
-    third_party_settings: {  }
+    settings:
+      format_type: medium
src/FieldTrait.php (1)

261-262: 🧹 Nitpick (assertive)

Error message could be more specific.

The error message only mentions "Date field" even when the method might be looking for a time input element.

-      throw new \Exception(sprintf('Date field with label "%s" value not found', $label));
+      throw new \Exception(sprintf('%s field with label "%s" value not found', ucfirst($field), $label));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 23c6d1c and 48f6c68.

📒 Files selected for processing (13)
  • STEPS.md (2 hunks)
  • src/FieldTrait.php (2 hunks)
  • tests/behat/features/field_datetime.feature (1 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml (3 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.rss.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_index.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_result.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.teaser.yml (2 hunks)
  • tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_and_time.yml (1 hunks)
  • tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_only.yml (1 hunks)
  • tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_and_time.yml (1 hunks)
  • tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_only.yml (1 hunks)
🔇 Additional comments (23)
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_result.yml (2)

9-10: Add new datetime field dependencies
Added field.field.node.article.field_date_and_time and field.field.node.article.field_date_only to the dependencies list for the search_result view mode.


58-59: Hide datetime fields in search_result view
Both field_date_and_time and field_date_only are correctly marked as hidden in this view mode to prevent them from displaying in search results.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.search_index.yml (2)

10-11: Add datetime field dependencies to search_index view
The search_index view mode dependencies now include field.field.node.article.field_date_and_time and field.field.node.article.field_date_only, keeping consistency with other view modes.


56-57: Hide datetime fields in search_index view
The new datetime fields are correctly hidden under the hidden section for the search_index view mode.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.rss.yml (2)

9-11: Add datetime and file field dependencies to RSS view
Added field_date_and_time, field_date_only, and field_file to the dependencies list for the RSS view mode, ensuring the configuration is aware of these fields.


35-36: Hide datetime fields in RSS view
The new datetime fields are correctly set to true under the hidden section for the RSS view mode.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.teaser.yml (2)

9-11: Add datetime and file field dependencies to teaser view
The teaser view mode now depends on field_date_and_time, field_date_only, and field_file, aligning it with other view modes.


64-65: Hide datetime fields in teaser view
field_date_and_time and field_date_only are correctly hidden in the teaser view mode.

tests/behat/fixtures/d10/config/sync/core.entity_form_display.node.article.default.yml (4)

8-9: Add datetime fields to form display dependencies
The form display config now includes dependencies on field.field.node.article.field_date_and_time and field.field.node.article.field_date_only.


19-19: Add datetime module dependency
Including the datetime module is required to support the new datetime widgets in the form display.


53-58: Configure field_date_and_time widget
The field_date_and_time field is correctly configured with the datetime_default widget, weight, region, and empty settings.


59-64: Configure field_date_only widget
The field_date_only field is correctly configured with the datetime_default widget, weight, region, and empty settings.

tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_only.yml (1)

1-21: Configuration for field_date_only is correct.
Dependencies, settings (datetime_type: date), and module requirements are properly declared; no issues found.

STEPS.md (2)

484-484: Approve update to FieldTrait documentation.
The new bullet point clarifying support for datetime field widgets is concise and aligns with the recent code additions.


543-556: Verify existence of datetime field step implementation.
Check that the step definition (@When I fill in the datetime field :label with date :date and time :time) is implemented and correctly wired to your helper methods.

tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_only.yml (1)

1-21: Valid field storage configuration.
The storage definition for field_date_only correctly specifies datetime_type: date, module dependencies, cardinality, and translatability. No issues found.

tests/behat/fixtures/d10/config/sync/field.field.node.article.field_date_and_time.yml (1)

1-22: Field configuration for field_date_and_time is correct.
Dependencies, field type, and bundle configuration match expected requirements for date+time storage. Good to go.

tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml (1)

16-18: Module dependency inclusion is appropriate.
The addition of datetime under module dependencies ensures the formatter is available. No concerns.

tests/behat/fixtures/d10/config/sync/field.storage.node.field_date_and_time.yml (1)

1-21: Configuration looks good and follows Drupal standards.

The field storage configuration for the datetime field is properly set up with all required properties. The datetime_type: datetime configuration correctly enables both date and time storage, which aligns with the PR's objective of adding datetime handling.

tests/behat/features/field_datetime.feature (1)

1-31: Feature file is well-structured and tests the core functionality.

The feature file properly tests both datetime and date-only field types with appropriate assertions. The test cases follow a logical flow from field input to verification of displayed values and include proper setup with authentication.

src/FieldTrait.php (3)

18-18: Documentation update is clear and comprehensive.

The class documentation has been appropriately updated to include the new datetime field handling capability.


211-237: New public methods for datetime fields are well-designed.

The implementation of fieldFillDateTime and fieldFillDate follows the established pattern in the trait. The methods have clear documentation with examples and appropriate method signatures.


252-257: XPath selector is more robust than previous implementations.

The XPath selector has been significantly improved compared to previous implementations mentioned in past review comments. It now properly handles multiple HTML elements (span, label, h4) and different CSS classes, making it more flexible and robust.

Comment on lines +60 to +68
field_date_only:
type: datetime_default
label: above
settings:
timezone_override: ''
format_type: medium
third_party_settings: { }
weight: 8
region: content
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Cleanup unnecessary empty settings.
Similarly, for field_date_only, remove empty timezone_override and third_party_settings:

   field_date_only:
-    settings:
-      timezone_override: ''
-      format_type: medium
-    third_party_settings: {  }
+    settings:
+      format_type: medium
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
field_date_only:
type: datetime_default
label: above
settings:
timezone_override: ''
format_type: medium
third_party_settings: { }
weight: 8
region: content
field_date_only:
type: datetime_default
label: above
settings:
format_type: medium
weight: 8
region: content
🤖 Prompt for AI Agents
In
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml
around lines 60 to 68, remove the empty settings 'timezone_override' under
'settings' and the empty 'third_party_settings' key from the 'field_date_only'
configuration to clean up unnecessary empty values.

Comment on lines +9 to +10
- field.field.node.article.field_date_and_time
- field.field.node.article.field_date_only
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing storage dependencies for datetime fields.
Configuration import may fail without including the corresponding storage dependencies. Please add:

     dependencies:
       config:
         - field.field.node.article.field_date_and_time
+        - field.storage.node.field_date_and_time
         - field.field.node.article.field_date_only
+        - field.storage.node.field_date_only
🤖 Prompt for AI Agents
In
tests/behat/fixtures/d10/config/sync/core.entity_view_display.node.article.default.yml
around lines 9 to 10, the configuration is missing storage dependencies for the
datetime fields field_date_and_time and field_date_only. Add these storage
dependencies explicitly to ensure the configuration import succeeds without
errors related to missing dependencies.

Comment on lines +238 to +264
/**
* Helper method to fill datetime field components.
*
* @param string $label
* The field label.
* @param string $field
* The field component: 'date' or 'time'.
* @param string $value
* The value to set.
*
* @throws \Exception
* If the field is not found.
*/
protected function fieldFillDateTimeField(string $label, string $field, string $value): void {
$xpath = sprintf(
'//*[self::span or self::label or self::h4][contains(normalize-space(.), "%s")]/ancestor::div[contains(@class,"form-item") or contains(@class,"field--widget-datetime-default")]//input[contains(@name,"[%s]")]',
$label,
$field
);

$page = $this->getSession()->getPage();
$element = $page->find('xpath', $xpath);
if (!$element) {
throw new \Exception(sprintf('Date field with label "%s" value not found', $label));
}
$element->setValue($value);
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Helper method implementation is solid but could use additional validation.

The fieldFillDateTimeField helper method effectively handles the task of locating and filling datetime input fields. Consider adding validation for the $field parameter to ensure it only accepts 'date' or 'time' values.

 protected function fieldFillDateTimeField(string $label, string $field, string $value): void {
+    // Validate that field is either 'date' or 'time'
+    if (!in_array($field, ['date', 'time'])) {
+      throw new \InvalidArgumentException(sprintf('Invalid field type "%s". Expected "date" or "time".', $field));
+    }
+
     $xpath = sprintf(
       '//*[self::span or self::label or self::h4][contains(normalize-space(.), "%s")]/ancestor::div[contains(@class,"form-item") or contains(@class,"field--widget-datetime-default")]//input[contains(@name,"[%s]")]',
       $label,
       $field
     );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Helper method to fill datetime field components.
*
* @param string $label
* The field label.
* @param string $field
* The field component: 'date' or 'time'.
* @param string $value
* The value to set.
*
* @throws \Exception
* If the field is not found.
*/
protected function fieldFillDateTimeField(string $label, string $field, string $value): void {
$xpath = sprintf(
'//*[self::span or self::label or self::h4][contains(normalize-space(.), "%s")]/ancestor::div[contains(@class,"form-item") or contains(@class,"field--widget-datetime-default")]//input[contains(@name,"[%s]")]',
$label,
$field
);
$page = $this->getSession()->getPage();
$element = $page->find('xpath', $xpath);
if (!$element) {
throw new \Exception(sprintf('Date field with label "%s" value not found', $label));
}
$element->setValue($value);
}
/**
* Helper method to fill datetime field components.
*
* @param string $label
* The field label.
* @param string $field
* The field component: 'date' or 'time'.
* @param string $value
* The value to set.
*
* @throws \Exception
* If the field is not found.
*/
protected function fieldFillDateTimeField(string $label, string $field, string $value): void {
// Validate that field is either 'date' or 'time'
if (!in_array($field, ['date', 'time'])) {
throw new \InvalidArgumentException(
sprintf('Invalid field type "%s". Expected "date" or "time".', $field)
);
}
$xpath = sprintf(
'//*[self::span or self::label or self::h4][contains(normalize-space(.), "%s")]/ancestor::div[contains(@class,"form-item") or contains(@class,"field--widget-datetime-default")]//input[contains(@name,"[%s]")]',
$label,
$field
);
$page = $this->getSession()->getPage();
$element = $page->find('xpath', $xpath);
if (!$element) {
throw new \Exception(sprintf('Date field with label "%s" value not found', $label));
}
$element->setValue($value);
}
🤖 Prompt for AI Agents
In src/FieldTrait.php between lines 238 and 264, the method
fieldFillDateTimeField accepts a $field parameter but does not validate its
value. Add validation to ensure $field is either 'date' or 'time' before
proceeding. If $field is invalid, throw an exception with a clear message. This
prevents incorrect usage and potential errors in XPath construction.

@skipper-vp skipper-vp force-pushed the feature/406-datetime-handling branch from 48f6c68 to 2316f40 Compare May 21, 2025 00:41
Copy link

codecov bot commented May 21, 2025

Codecov Report

Attention: Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.33%. Comparing base (6d27528) to head (2316f40).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/FieldTrait.php 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #409      +/-   ##
==========================================
+ Coverage   80.25%   80.33%   +0.07%     
==========================================
  Files          29       29              
  Lines        1965     1978      +13     
==========================================
+ Hits         1577     1589      +12     
- Misses        388      389       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@skipper-vp skipper-vp added Needs review Pull request needs a review from assigned developers and removed Do not review Do not review this pull request labels May 21, 2025
@skipper-vp skipper-vp requested a review from AlexSkrypnyk May 21, 2025 00:50
@AlexSkrypnyk AlexSkrypnyk added Requires more work Pull request was reviewed and reviver(s) asked to work further on the pull request and removed Needs review Pull request needs a review from assigned developers labels May 21, 2025
@AlexSkrypnyk AlexSkrypnyk changed the title [#406]: Added datetime handling. [#406] Added datetime handling. Jun 2, 2025
Copy link
Member

@AlexSkrypnyk AlexSkrypnyk left a comment

Choose a reason for hiding this comment

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

Changes required:

  1. Address reviewer's issues
  2. Add dield_time_only
  3. Add negative and exception assertions to tests/behat/features/field_datetime.feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Requires more work Pull request was reviewed and reviver(s) asked to work further on the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants