Improve ReportingPageObject.getReportURL error handling (#212684)

## Summary

We've been experiencing some flakiness with serverless reporting
functional tests (e.g. [this
one](https://buildkite.com/elastic/appex-qa-serverless-kibana-ftr-tests/builds/4446#019547ec-baca-445b-ad04-c591d45c26ab)).
We suspect it's timeout related, but it's hard to know for sure because
the error handling code also throws an error when
`[data-test-errorText]` isn't found, obscuring the original error.

This PR updates `ReportingPageObject.getReportURL` to check for
`[data-test-errorText]` before attempting to select it, and ensures the
original error is surfaced even when not found.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

Co-authored-by: Tim Sullivan <tsullivan@users.noreply.github.com>
This commit is contained in:
Davis McPhee 2025-03-05 16:15:17 -04:00 committed by GitHub
parent c240b035d4
commit d8be937da0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,10 +50,12 @@ export class ReportingPageObject extends FtrService {
return url;
} catch (err) {
const errorTextEl = await this.find.byCssSelector('[data-test-errorText]');
const errorText = await errorTextEl.getAttribute('data-test-errorText');
const newError = new Error(`Test report failed: ${errorText}: ${err}`);
throw newError;
let errorText = 'Unknown error';
if (await this.find.existsByCssSelector('[data-test-errorText]')) {
const errorTextEl = await this.find.byCssSelector('[data-test-errorText]');
errorText = (await errorTextEl.getAttribute('data-test-errorText')) ?? errorText;
}
throw new Error(`Test report failed: ${errorText}: ${err}`, { cause: err });
}
}