kibana/test/common/services
Spencer 3b8e95758c
[retry] implement waitFor method (#21747)
We currently use the `retry` service to call a function over and over in a loop, waiting for it to run without throwing an error, and ultimately failing if it does not succeed before a timeout is exceeded. This is the easiest way to get certain interactions to work, either because we don't know when we should be able to execute the interaction successfully, or because the timing is just too tricky to plan out correctly. Another place where we are using the `retry` service, which I don't think is appropriate, is when we need to wait for a certain condition to be met. This is where `retry.waitFor()` comes in:

```js
await retry.waitFor('dashboard search to be enabled', async () => {
  const searchInput = await testSubjects.find('savedObjectFinderSearchInput');
  return await searchInput.isEnabled();
})
```

The `retry.waitFor()` method behaves much like the `retry.try()` method behind the scenes, calling a function over and over, but instead of waiting for it to run without throwing an error it waits for it to return a "truthy" value. It also requires a description string that is used to make rather nice log output and a more descriptive error message than something like https://github.com/elastic/kibana/blob/master/test/functional/apps/dashboard/_data_shared_attributes.js#L61-L67
2018-08-14 13:35:32 -07:00
..
kibana_server Reverts breaking change for Status API (#21927) 2018-08-13 17:26:20 -05:00
retry [retry] implement waitFor method (#21747) 2018-08-14 13:35:32 -07:00
es.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
es_archiver.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
index.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00