@TestOnly
  // NB: failures applying EDT tasks are not handled - i.e., failed documents are added back to the queue and the method returns
  public void waitForAllCommits(long timeout, @NotNull TimeUnit timeUnit) throws ExecutionException, InterruptedException, TimeoutException {
    if (!ApplicationManager.getApplication().isDispatchThread()) {
      while (!executor.isEmpty()) {
        executor.waitAllTasksExecuted(timeout, timeUnit);
      }
      return;
    }
    assert !ApplicationManager.getApplication().isWriteAccessAllowed();

    EDT.dispatchAllInvocationEvents();
    while (!executor.isEmpty()) {
      executor.waitAllTasksExecuted(timeout, timeUnit);
      EDT.dispatchAllInvocationEvents();
    }
  }
@TestOnly
  // NB: failures applying EDT tasks are not handled - i.e., failed documents are added back to the queue and the method returns
  public void waitForAllCommits(long timeout, @NotNull TimeUnit timeUnit)