Skip to content

XWIKI-24806: TextAreaImageUploadIT is flickering and its missing edit-mode cleanup fails the rest of AllIT - #6309

Merged
vmassol merged 1 commit into
masterfrom
XWIKI-24806
Sep 4, 2026
Merged

XWIKI-24806: TextAreaImageUploadIT is flickering and its missing edit-mode cleanup fails the rest of AllIT#6309
vmassol merged 1 commit into
masterfrom
XWIKI-24806

Conversation

@vmassol

@vmassol vmassol commented Sep 4, 2026

Copy link
Copy Markdown
Member

Jira URL

https://jira.xwiki.org/browse/XWIKI-24806

Changes

Description

  • Discard the unsaved changes after each test of TextAreaImageUploadIT, so that a test failing in the middle of an edit no longer leaves the page with an armed beforeunload handler.
  • Add CKEditor#discardUnsavedChanges() to the CKEditor page objects, marking every editor instance on the current page as clean.

Clarifications

AllIT runs all its @Nested ITs in a single shared browser session, with NestedTextAreaImageUploadIT first. TextAreaImageUploadIT had no @AfterEach, so when one of its tests failed mid-edit the leave confirmation stayed armed and the next navigation died with UnhandledAlertException: Unexpected beforeunload dialog detected (InvalidArgumentException: Unexpected dialog type beforeunload on Chrome). Every remaining nested IT then failed in its setup, so a single flickering test produced six failures — see the two builds of 2026-09-03 linked from the issue, one of which also spent 422 s hung on a single driver.get().

The cleanup needs two steps because two different mechanisms ask for confirmation:

  • the comment, the annotation and the in-place property are edited on a view page, where TestUtils#maybeLeaveEditMode() is a no-op (window.XWiki.editor is empty). There the confirmation comes from the CKEditor xwiki-save plugin, whose beforeunload handler tests editor.checkDirty() — hence the new CKEditor#discardUnsavedChanges(), which calls resetDirty() on every instance;
  • the object editor asks based on its own form state (dataeditors.js sets window.onbeforeunload from unsavedChanges), which only leaving the edit mode resets — hence the maybeLeaveEditMode() call, done after the editors are marked clean so that leaving doesn't trigger the dialog itself.

This only contains the damage. The underlying flicker — ckeditor.getToolBar().insertImage() occasionally not opening the image dialog within the 10 s wait, seen on master, stable-17.10.x and stable-18.4.x — is still open on XWIKI-24806.

Screenshots & Video

N/A — test-only change, no UI change.

Executed Tests

  • mvn clean verify -B -ntp -pl xwiki-platform-core/xwiki-platform-edit/xwiki-platform-edit-test/xwiki-platform-edit-test-docker -Pdocker,integration-tests -Dit.test=AllIT — 17 tests, 0 failures, 0 errors.
  • mvn clean install -B -ntp -Plegacy,quality,docker,integration-tests -pl xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-test/xwiki-platform-ckeditor-test-pageobjects — 0 Checkstyle violations, Revapi clean.

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    • stable-18.4.x
    • stable-17.10.x

🤖 Generated with Claude Code

…-mode cleanup fails the rest of AllIT

* Discard the unsaved changes after each test, so that a failure no longer leaves an armed
  beforeunload handler that blocks every test running after it in the shared browser session.
* Add CKEditor#discardUnsavedChanges() to the page objects, marking every editor instance on the
  page as clean. This is what arms the leave confirmation for the comment, the annotation and the
  in-place property, all edited on a view page where there is no edit mode to leave.
* Leave the edit mode for the object editor, which asks for confirmation based on its own form state.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

@vmassol
vmassol merged commit 879250a into master Sep 4, 2026
6 checks passed
@vmassol
vmassol deleted the XWIKI-24806 branch September 4, 2026 10:04
github-actions Bot pushed a commit that referenced this pull request Sep 4, 2026
…-mode cleanup fails the rest of AllIT (#6309)

* Discard the unsaved changes after each test, so that a failure no longer leaves an armed
  beforeunload handler that blocks every test running after it in the shared browser session.
* Add CKEditor#discardUnsavedChanges() to the page objects, marking every editor instance on the
  page as clean. This is what arms the leave confirmation for the comment, the annotation and the
  in-place property, all edited on a view page where there is no edit mode to leave.
* Leave the edit mode for the object editor, which asks for confirmation based on its own form state.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 879250a)
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

💚 All backports created successfully

Status Branch Result
stable-17.10.x
stable-18.4.x

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

github-actions Bot pushed a commit that referenced this pull request Sep 4, 2026
…-mode cleanup fails the rest of AllIT (#6309)

* Discard the unsaved changes after each test, so that a failure no longer leaves an armed
  beforeunload handler that blocks every test running after it in the shared browser session.
* Add CKEditor#discardUnsavedChanges() to the page objects, marking every editor instance on the
  page as clean. This is what arms the leave confirmation for the comment, the annotation and the
  in-place property, all edited on a view page where there is no edit mode to leave.
* Leave the edit mode for the object editor, which asks for confirmation based on its own form state.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 879250a)
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

💚 All backports created successfully

Status Branch Result
stable-17.10.x
stable-18.4.x

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

@vmassol vmassol self-assigned this Sep 4, 2026
vmassol added a commit that referenced this pull request Sep 4, 2026
…-mode cleanup fails the rest of AllIT (#6309) (#6310)

* Discard the unsaved changes after each test, so that a failure no longer leaves an armed
  beforeunload handler that blocks every test running after it in the shared browser session.
* Add CKEditor#discardUnsavedChanges() to the page objects, marking every editor instance on the
  page as clean. This is what arms the leave confirmation for the comment, the annotation and the
  in-place property, all edited on a view page where there is no edit mode to leave.
* Leave the edit mode for the object editor, which asks for confirmation based on its own form state.


(cherry picked from commit 879250a)

Co-authored-by: Vincent Massol <vincent@massol.net>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
vmassol added a commit that referenced this pull request Sep 4, 2026
…-mode cleanup fails the rest of AllIT (#6309) (#6311)

* Discard the unsaved changes after each test, so that a failure no longer leaves an armed
  beforeunload handler that blocks every test running after it in the shared browser session.
* Add CKEditor#discardUnsavedChanges() to the page objects, marking every editor instance on the
  page as clean. This is what arms the leave confirmation for the comment, the annotation and the
  in-place property, all edited on a view page where there is no edit mode to leave.
* Leave the edit mode for the object editor, which asks for confirmation based on its own form state.


(cherry picked from commit 879250a)

Co-authored-by: Vincent Massol <vincent@massol.net>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant