From 0e3aa5a50135dc57780b3f965ac64c24c68f086c Mon Sep 17 00:00:00 2001 From: David de Kloet <122978264+dskloetd@users.noreply.github.com> Date: Thu, 21 Sep 2023 11:41:57 +0200 Subject: [PATCH] E2E: Work around images not loading (#3344) # Motivation We have an e2e test that tests that images load. Sometimes images don't load and the test times out: https://github.com/dfinity/nns-dapp/actions/runs/6245207559?pr=3337 I'm not sure why they don't always load on CI but let's retry the test when they don't. # Changes 1. Set a timeout on waiting for images to be loaded. 2. Retry the test up to 2 times when it fails. # Tests Still pass, hopefully less flaky. # Todos - [ ] Add entry to changelog (if necessary). not necessary --- frontend/src/tests/e2e/images.spec.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/frontend/src/tests/e2e/images.spec.ts b/frontend/src/tests/e2e/images.spec.ts index 3d47a737d21..c74266c6b4d 100644 --- a/frontend/src/tests/e2e/images.spec.ts +++ b/frontend/src/tests/e2e/images.spec.ts @@ -16,18 +16,24 @@ const expectImagesLoaded = async ({ page, sources }) => { baseImageSources.sort(); expect(baseImageSources).toEqual(sources); - await page.waitForFunction((expectedImageCount) => { - const images = Array.from(document.querySelectorAll("img")); - if (images.length !== expectedImageCount) { - return false; - } - // The browser might decide not to load images that are outside the - // viewport. - images.forEach((img) => img.scrollIntoView()); - return images.every((img) => img.complete); - }, sources.length); + await page.waitForFunction( + (expectedImageCount) => { + const images = Array.from(document.querySelectorAll("img")); + if (images.length !== expectedImageCount) { + return false; + } + // The browser might decide not to load images that are outside the + // viewport. + images.forEach((img) => img.scrollIntoView()); + return images.every((img) => img.complete); + }, + sources.length, + { timeout: 10000 } + ); }; +test.describe.configure({ retries: 2 }); + test("Test images load on accounts page", async ({ page, context }) => { await page.goto("/accounts"); await expect(page).toHaveTitle("My Tokens / NNS Dapp");