Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25214

Add test APIs to wait for a document to be saved in the background

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 18.9.0-rc-1
    • 18.4.6
    • Test Framework
    • None
    • Unknown
    • N/A
    • N/A

    Description

      Functional tests that check something saved in the background (e.g. by an editor's auto-save) have to wait for it, and today they do so with getDriver() calls in the test class (raising the driver timeout, polling with waitUntilCondition), which breaks the page-object boundary: the test shouldn't need to know how long to wait or how to poll.

      Add TestUtils.RestTestUtils#waitForVersionChange(reference, fromVersion, timeout): wait for the version of a document to differ from a given one, whatever changes it (a save, a rollback, a version deletion), polling it over REST (so it works whichever browser tab, if any, changes it), and return the new version. It throws a TimeoutException otherwise, which also lets a test check that no new version is created.

      Example: the BlockNote auto-save tests (AutoSaveIT). They use this API, plus page-object methods that wait for the auto-save with timeouts derived from the configured interval (BlockNoteEditor#waitForAutoSave() and BlockNoteEditor#isAutoSavedWithinNextInterval()), and no longer call getDriver().

      Attachments

        Activity

          People

            vmassol Vincent Massol
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: