Skip to content

Commit 4479319

Browse files
author
Peter Rushforth
committed
Add timeouts to mitigate flakiness
1 parent 19d1e00 commit 4479319

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

test/e2e/elements/layer-/layer-dash-src.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ test.describe('layer- local/inline vs remote content/src tests', () => {
3737

3838
await layer.evaluate((layer) => layer.removeAttribute('src'));
3939
await page.waitForTimeout(500);
40-
expect(layer).toHaveAttribute('disabled');
40+
// Wait for the disabled attribute to be set asynchronously
41+
await expect(layer).toHaveAttribute('disabled', '', { timeout: 2000 });
4142

4243
// append the template map-extent to the local / inline content
4344
await page.evaluate(() => {

test/e2e/elements/map-layer/layer-src.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ test.describe('map-layer local/inline vs remote content/src tests', () => {
3535
// remove the src attribute
3636

3737
await layer.evaluate((layer) => layer.removeAttribute('src'));
38-
expect(layer).toHaveAttribute('disabled');
38+
// Wait for the disabled attribute to be set asynchronously
39+
await expect(layer).toHaveAttribute('disabled', '', { timeout: 2000 });
3940

4041
// append the template map-extent to the local / inline content
4142
await page.evaluate(() => {

test/e2e/elements/map-layer/map-layer-media.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ enabled and added to the layer control when mq removed`, async () => {
8585
test(`An invalid media query is the same as a non-matching media query`, async () => {
8686
const noInitialQueryLayer = page.getByTestId('no-initial-mq');
8787
await noInitialQueryLayer.evaluate((l) => l.setAttribute('media', '(foo '));
88-
await page.waitForTimeout(500);
89-
await expect(noInitialQueryLayer).toHaveAttribute('disabled', '');
88+
// Wait for the invalid media query to trigger the disabled attribute
89+
await expect(noInitialQueryLayer).toHaveAttribute('disabled', '', { timeout: 2000 });
9090
});
9191
});

test/e2e/elements/map/map-in-shadow-root.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ test.describe('Playwright map[is=web-map] fullscreen tests', () => {
2929
// the first mapml-viewer should be returned by document.fullscreen
3030
expect(fullscreenElement).toEqual('map1');
3131
await fullscreenButton.click();
32-
await page.waitForTimeout(500);
32+
// Wait for fullscreen to exit properly
33+
await page.waitForFunction(() => !document.fullscreenElement, { timeout: 2000 });
3334
fullscreenElement = await page.evaluate(`document.fullscreenElement`);
3435
expect(fullscreenElement).toBeFalsy();
3536

test/e2e/layers/featureLayer.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ test.describe('Playwright featureLayer (Static Features) Layer Tests', () => {
4545

4646
test('Loading in retrieved features', async () => {
4747
await page.waitForTimeout(350);
48+
// Wait for the layer to be ready and SVG to be created
49+
await page.waitForFunction(() => {
50+
const layer = document.querySelector('map-layer#US');
51+
return layer &&
52+
layer._layer &&
53+
layer._layer._container &&
54+
layer._layer._container.querySelector('svg') &&
55+
layer._layer._container.querySelector('svg').firstChild;
56+
}, { timeout: 5000 });
57+
4858
const features = await page.$eval(
4959
'map-layer#US',
5060
(layer) =>

0 commit comments

Comments
 (0)