Skip to content

Assert dates in content editing integration tests to millisecond only #19513

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 3 commits into
base: main
Choose a base branch
from

Conversation

AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Jun 9, 2025

Have seen some tests failing on main due to date comparisons going beyond the millisecond and see dates as different when we should consider them the same.

E.g.:

  Failed Updating_Single_Variant_Property_Does_Not_Change_Update_Dates_Of_Other_Variants
  Error Message:
     Expected: 2025-06-07 00:32:57.9074126
  But was:  2025-06-07 00:32:57.907

This fixes that for the two cases seen on a recent pipeline run. Maybe we'll need to cherry-pick this into release/16.0 and perhaps branches for older versions.

@Copilot Copilot AI review requested due to automatic review settings June 9, 2025 11:03
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 PR ensures date comparisons in content editing integration tests are truncated to millisecond precision and adds corresponding support in the DateTimeExtensions helper.

  • Added a Millisecond enum member and updated TruncateTo to handle millisecond truncation.
  • Updated integration tests to call .TruncateTo(DateTruncate.Millisecond) in date assertions.
  • Fixed a typo in a test method name (VaiantsVariants).

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEditingServiceTests.Update.cs Renamed test method, updated Assert calls to truncate dates to milliseconds
src/Umbraco.Core/Extensions/DateTimeExtensions.cs Added DateTruncate.Millisecond and reworked TruncateTo logic to include milliseconds
Comments suppressed due to low confidence (1)

src/Umbraco.Core/Extensions/DateTimeExtensions.cs:70

  • Consider adding unit tests specifically for TruncateTo(DateTruncate.Millisecond) to verify that millisecond truncation behaves correctly.
return new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Millisecond, dt.Kind);

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.

1 participant