## Why `commentAsLoggedInUser` started failing
**Culprit:** commit `37d160160e0` — *"XWIKI-23741: Improve the UI of Comments: Comment look (#5273)"* (LucasC, 2026-06-22). One commit changed `comments.js`, `commentsinline.vm`, `CommentsTab.java`, and the test `CommentsIT.java` together. It's only 2 days old, so Develocity hasn't flagged it as a flicker yet.
**Mechanism:**
1. The commit added a new test line — `CommentsIT.java:128` `commentsTab.toggleCommentThread(commentIndex)` — right after replying to a comment.
2. The new helper `CommentsTab.toggleCommentThread` (line 137) blindly clicks the thread-toggle and then waits for the thread to become **expanded** (`.collapse.in`). It assumes the thread is collapsed before the click.
3. But the same commit also made the JS **auto-expand the thread when you reply** (`comments.js:281-282`) and **preserve that expanded state across the AJAX reload** (`comments.js:362-377`).
4. So at line 128 the thread is *already* expanded → the blind toggle **collapses** it → the wait for `.collapse.in` times out after 10s → `TimeoutException`.
**Why the toggle was added:** `getCommentAuthorByID` uses Selenium `getText()`, which returns `""` for hidden/collapsed elements, so the thread must be expanded to read the reply author. The author added the toggle to force expansion but assumed a collapsed start state.
**Why the sibling test passes:** `commentsAreOrderedByDate:311` also calls `toggleCommentThread`, but there the replies are created via REST, so threads genuinely start collapsed and the toggle correctly expands them.
**Racy element:** the exact outcome depends on whether the Bootstrap expand animation finished before the reload snapshots the expanded threads — biased heavily toward failure on fast CI.
**Bottom line for the author:** it's a test-side bug (blind toggle assumes collapsed state, contradicted by the new auto-expand-on-reply behavior); the product feature itself is intended. A robust fix would be an idempotent, state-aware `expandCommentThread(id)` used at both call sites.
Vincent Massol on 24/Jun/26 09:44
[~Lucas C] Reopening as the CI is failing at https://ci.xwiki.org/job/XWiki/job/xwiki-platform/job/master/8682/testReport/junit/org.xwiki.flamingo.test.docker/AllIT$NestedCommentsIT/Platform_Builds___main___integration_tests___IT_for_xwiki_platform_core_xwiki_platform_flamingo_xwiki_platform_flamingo_skin_xwiki_platform_flamingo_skin_test_xwiki_platform_flamingo_skin_test_docker___Build_for_IT_for_xwiki_platform_core_xwiki_platform_flamingo_xwiki_platform_flamingo_skin_xwiki_platform_flamingo_skin_test_xwiki_platform_flamingo_skin_test_docker___commentAsLoggedInUser_TestUtils__TestReference_/
{noformat}
## Why `commentAsLoggedInUser` started failing
**Culprit:** commit `37d160160e0` — *"XWIKI-23741: Improve the UI of Comments: Comment look (#5273)"* (LucasC, 2026-06-22). One commit changed `comments.js`, `commentsinline.vm`, `CommentsTab.java`, and the test `CommentsIT.java` together. It's only 2 days old, so Develocity hasn't flagged it as a flicker yet.
**Mechanism:** 1. The commit added a new test line — `CommentsIT.java:128` `commentsTab.toggleCommentThread(commentIndex)` — right after replying to a comment. 2. The new helper `CommentsTab.toggleCommentThread` (line 137) blindly clicks the thread-toggle and then waits for the thread to become **expanded** (`.collapse.in`). It assumes the thread is collapsed before the click. 3. But the same commit also made the JS **auto-expand the thread when you reply** (`comments.js:281-282`) and **preserve that expanded state across the AJAX reload** (`comments.js:362-377`). 4. So at line 128 the thread is *already* expanded → the blind toggle **collapses** it → the wait for `.collapse.in` times out after 10s → `TimeoutException`.
**Why the toggle was added:** `getCommentAuthorByID` uses Selenium `getText()`, which returns `""` for hidden/collapsed elements, so the thread must be expanded to read the reply author. The author added the toggle to force expansion but assumed a collapsed start state.
**Why the sibling test passes:** `commentsAreOrderedByDate:311` also calls `toggleCommentThread`, but there the replies are created via REST, so threads genuinely start collapsed and the toggle correctly expands them.
**Racy element:** the exact outcome depends on whether the Bootstrap expand animation finished before the reload snapshots the expanded threads — biased heavily toward failure on fast CI.
**Bottom line for the author:** it's a test-side bug (blind toggle assumes collapsed state, contradicted by the new auto-expand-on-reply behavior); the product feature itself is intended. A robust fix would be an idempotent, state-aware `expandCommentThread(id)` used at both call sites. {noformat}
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.