Skip to content

Commit

Permalink
Tested one more simple demo
Browse files Browse the repository at this point in the history
  • Loading branch information
verlok committed Apr 2, 2024
1 parent d286264 commit 7cd6189
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/e2e/image_basic.spec.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
import { expect, test } from "@playwright/test";
const limit = 10;

const pagesWithSimpleImages = [
{ url: "/demos/image_basic.html", description: "Basic page" },
{ url: "/demos/async.html", description: "Async initialization" }
{ url: "/demos/async.html", description: "Async initialization" },
{ url: "/demos/async_multiple.html", description: "Async initialization - multiple instances" },
];

for (const { url, description } of pagesWithSimpleImages) {
test(description, async ({ page }) => {
await page.goto(url);
const lazyLoadImages = await page.locator("img[data-src]");
const lazyImages = await page.locator(".lazy");
await page.waitForLoadState("load");
const imageCount = limit //was: await lazyLoadImages.count();
const imageCount = await lazyImages.count();

// Eventually scroll into view and check if it loads
for (let i = 0; i < imageCount; i++) {
const image = lazyLoadImages.nth(i);
const image = lazyImages.nth(i);
await image.scrollIntoViewIfNeeded();

// Check the src attribute
const expectedSrc = await image.getAttribute("data-src");
await expect(image).toHaveAttribute("src", expectedSrc);
}
});

// You can also do it with test.describe() or with multiple tests as long the test name is unique.
}
}

0 comments on commit 7cd6189

Please sign in to comment.