Skip to content

Stabilize descending threaded-comments integration assertions#421

Merged
ThomasPe merged 2 commits into
mainfrom
copilot/fix-integration-tests
Apr 7, 2026
Merged

Stabilize descending threaded-comments integration assertions#421
ThomasPe merged 2 commits into
mainfrom
copilot/fix-integration-tests

Conversation

Copilot AI commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

The integration suite was failing intermittently in the threaded comments descending-order test. The failure came from validating top-level ordering against the full threaded list, which includes interleaved child comments.

  • Root cause

    • CommentsThreaded_Sort_Extension_Desc filtered top-level comments into firstLvl, but its final ordering assertions still indexed into threaded.
    • That made the test compare unrelated child comments and fail depending on comment timestamps.
  • Change

    • Updated the descending-order assertions to use firstLvl consistently for the top-level ordering check.
    • Removed the extra ID-based assertion from that loop so the test verifies the behavior that actually matters: descending date order among root comments.
  • Regression coverage

    • Added a focused unit test for ThreadedCommentsHelper.ToThreaded(true) that constructs a root/child/root comment shape and asserts that:
      • children remain attached to their parent in threaded order
      • top-level comments remain ordered by descending date
List<CommentThreaded>? threaded = comments.ToThreaded(true);
List<CommentThreaded> firstLevel = threaded.Where(comment => comment.Depth == 0).ToList();

CollectionAssert.AreEqual(new[] { 1, 3 }, firstLevel.Select(comment => comment.Id).ToList());
Assert.IsTrue(firstLevel[0].Date >= firstLevel[1].Date);

Copilot AI linked an issue Apr 7, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix integration tests Stabilize descending threaded-comments integration assertions Apr 7, 2026
Copilot AI requested a review from ThomasPe April 7, 2026 10:42
@ThomasPe ThomasPe marked this pull request as ready for review April 7, 2026 11:20
Copilot AI review requested due to automatic review settings April 7, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Stabilizes the self-hosted integration test coverage for threaded comments in descending order by ensuring top-level ordering assertions are applied only to top-level comments (not the full interleaved threaded list), and adds a focused regression test for ThreadedCommentsHelper.ToThreaded(true).

Changes:

  • Fix descending-order assertions in CommentsThreaded_Sort_Extension_Desc to consistently validate ordering using the top-level (Depth == 0) subset.
  • Remove the ID-based ordering assertion that was coupling the test to unrelated threaded/child ordering.
  • Add a new self-hosted utility test that verifies top-level descending date order while keeping children attached to their parent in the threaded output.

Reviewed changes

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

File Description
WordPressPCL.Tests.Selfhosted/CommentsThreaded_Tests.cs Updates descending-order assertions to use the filtered top-level list (firstLvl) for ordering checks.
WordPressPCL.Tests.Selfhosted/Utility/ThreadedCommentsHelper_Tests.cs Adds a regression test validating ToThreaded(true) keeps root comments in descending date order and preserves parent/child adjacency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ThomasPe ThomasPe merged commit 96fb301 into main Apr 7, 2026
7 checks passed
@ThomasPe ThomasPe deleted the copilot/fix-integration-tests branch April 7, 2026 12:05
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.

Fix integration tests

3 participants