[8.x] Fix discover async search relative timerange test (#197740) (#199020)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Fix discover async search relative timerange test
(#197740)](https://github.com/elastic/kibana/pull/197740)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Lukas
Olson","email":"lukas@elastic.co"},"sourceCommit":{"committedDate":"2024-11-05T16:03:49Z","message":"Fix
discover async search relative timerange test (#197740)\n\n##
Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/195955.","sha":"4869b8f21c7bc2e0234bfddf7415646f72429c22","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:DataDiscovery","backport:prev-minor"],"title":"Fix
discover async search relative timerange
test","number":197740,"url":"https://github.com/elastic/kibana/pull/197740","mergeCommit":{"message":"Fix
discover async search relative timerange test (#197740)\n\n##
Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/195955.","sha":"4869b8f21c7bc2e0234bfddf7415646f72429c22"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197740","number":197740,"mergeCommit":{"message":"Fix
discover async search relative timerange test (#197740)\n\n##
Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/195955.","sha":"4869b8f21c7bc2e0234bfddf7415646f72429c22"}}]}]
BACKPORT-->

Co-authored-by: Lukas Olson <lukas@elastic.co>
This commit is contained in:
Kibana Machine 2024-11-06 08:08:55 +11:00 committed by GitHub
parent 7c8fe2fda3
commit 75613ac8ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View file

@ -402,8 +402,8 @@ export class SearchSessionService implements ISearchSessionService {
const session = await this.get(deps, user, sessionId);
const requestHash = createRequestHash(searchRequest.params);
if (!Object.hasOwn(session.attributes.idMapping, requestHash)) {
this.logger.error(`SearchSessionService: getId | ${sessionId} | ${requestHash} not found`);
this.logger.debug(
this.logger.debug(`SearchSessionService: getId | ${sessionId} | ${requestHash} not found`);
this.logger.error(
`SearchSessionService: getId not found search with params: ${JSON.stringify(
searchRequest.params
)}`

View file

@ -37,7 +37,7 @@ export function SearchSessionsPageProvider({ getService, getPageObjects }: FtrPr
id: ((await row.getAttribute('data-test-search-session-id')) ?? '').split('id-')[1],
name: $.findTestSubject('sessionManagementNameCol').text().trim(),
status: $.findTestSubject('sessionManagementStatusLabel').attr('data-test-status'),
mainUrl: $.findTestSubject('sessionManagementNameCol').text(),
mainUrl: $.findTestSubject('sessionManagementNameCol').attr('href'),
created: $.findTestSubject('sessionManagementCreatedCol').text(),
expires: $.findTestSubject('sessionManagementExpiresCol').text(),
searchesCount: Number($.findTestSubject('sessionManagementNumSearchesCol').text()),

View file

@ -114,6 +114,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
it('relative timerange works', async () => {
await common.navigateToApp('discover');
await header.waitUntilLoadingHasFinished();
const url = await browser.getCurrentUrl();
await searchSessions.save();
await searchSessions.expectState('backgroundCompleted');
const searchSessionId = await getSearchSessionId();
@ -124,8 +126,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await searchSessionsManagement.goTo();
const searchSessionListBeforeRestore = await searchSessionsManagement.getList();
const searchesCountBeforeRestore = searchSessionListBeforeRestore[0].searchesCount;
// navigate to Discover
await searchSessionListBeforeRestore[0].view();
// Instead of clicking the link to navigate to Discover, we load Discover from scratch (just like we did when we
// ran the search session before saving). This ensures that the same number of requests are made.
// await searchSessionListBeforeRestore[0].view();
const restoreUrl = new URL(searchSessionListBeforeRestore[0].mainUrl, url).href;
await browser.navigateTo(restoreUrl);
await header.waitUntilLoadingHasFinished();
await searchSessions.expectState('restored');
expect(await discover.hasNoResults()).to.be(true);