[kbn-scout][maps] waitForRenderComplete (#211265)

## Summary

This PR add a method to wait for map to be loaded to replace generic
`renderable.waitForRender()`.

While investigating the recent test failure on CI I found out that for
maps case we can simplify the logic with few facts:
- before start waiting for render to complete, we need to wait for main
container `#maps-plugin` to be in DOM. It takes 2-3 seconds.
- there is always a single div block with `data-render-complete`
attribute, and there is a comment in source code stating `See if the
"data-render-complete" attribute is "true". If so we're done!` which
means we can simply wait for
`div[data-dom-id][data-render-complete="true"]`


6de2ef0e6d/x-pack/platform/plugins/shared/maps/public/connected_components/map_container/map_container.tsx (L103-L116)

`renderable.waitForRender()` is a good waiter, but probably for
dashboard with multiple panels.
This commit is contained in:
Dzmitry Lemechko 2025-02-17 14:46:44 +01:00 committed by GitHub
parent 0c69f75a37
commit 08400b1f42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View file

@ -9,10 +9,21 @@
import { ScoutPage } from '..';
const DEFAULT_MAP_LOADING_TIMEOUT = 10_000;
export class MapsPage {
constructor(private readonly page: ScoutPage) {}
async gotoNewMap() {
await this.page.gotoApp('maps/map');
return this.page.gotoApp('maps/map');
}
async waitForRenderComplete() {
// first wait for the top level container to be present
await this.page.locator('div#maps-plugin').waitFor({ timeout: DEFAULT_MAP_LOADING_TIMEOUT });
// then wait for the map to be fully rendered
return this.page
.locator('div[data-dom-id][data-render-complete="true"]')
.waitFor({ timeout: DEFAULT_MAP_LOADING_TIMEOUT });
}
}

View file

@ -22,7 +22,7 @@ test.describe(
test.beforeEach(async ({ browserAuth, pageObjects }) => {
await browserAuth.loginAsViewer();
await pageObjects.maps.gotoNewMap();
await pageObjects.renderable.waitForRender();
await pageObjects.maps.waitForRenderComplete();
});
test('Full screen mode', async ({ page }) => {