diff --git a/core/src/components/img/test/basic/img.e2e.ts b/core/src/components/img/test/basic/img.e2e.ts index d65bac6e78..8dbed904f0 100644 --- a/core/src/components/img/test/basic/img.e2e.ts +++ b/core/src/components/img/test/basic/img.e2e.ts @@ -5,8 +5,26 @@ test.describe('img: basic', () => { test('should not have visual regressions', async ({ page }) => { await page.goto('/src/components/img/test/basic'); + /** + * The first `ion-img` resolves before the spy can be created, + * since the image is initially visible and the IO fires. + * + * We manually look at the image's completion state to determine + * that it loaded, before creating a spy for the second image. + */ + const img = await page.locator('.img-part img'); + await img.evaluate((el: HTMLImageElement) => el.complete); + + const ionImgDidLoad = await page.spyOnEvent('ionImgDidLoad'); + /** + * Resizing the viewport will cause the intersection observers of + * the remaining images to fire, which will cause the `ionImgDidLoad` + * event to fire. + */ await page.setIonViewport(); + await ionImgDidLoad.next(); + expect(await page.screenshot()).toMatchSnapshot(`img-basic-${page.getSnapshotSettings()}.png`); }); }); diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Chrome-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Chrome-linux.png index 4e2da946f7..a25a99ce7e 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Chrome-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Firefox-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Firefox-linux.png index 6d9ae9f020..2c9c0aeac3 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Firefox-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Safari-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Safari-linux.png index 21920588a4..99593005d0 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Safari-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Chrome-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Chrome-linux.png index d539d2dd15..114a770119 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Chrome-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Chrome-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Firefox-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Firefox-linux.png index 1be1bbefb2..1e2860bd6f 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Firefox-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Firefox-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Safari-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Safari-linux.png index 2aee2af1a1..3559bc57b7 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Safari-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-ios-rtl-Mobile-Safari-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Chrome-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Chrome-linux.png index ef750ca1c6..2d5ccb3be2 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Chrome-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Chrome-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Firefox-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Firefox-linux.png index ed4d736a9a..34c2dc317a 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Firefox-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Firefox-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Safari-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Safari-linux.png index f24fa67a91..7f771b0796 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Safari-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-ltr-Mobile-Safari-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Chrome-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Chrome-linux.png index f201a9e5bc..090988a3cb 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Chrome-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Chrome-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Firefox-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Firefox-linux.png index a92e56035c..9063cbc12e 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Firefox-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Firefox-linux.png differ diff --git a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Safari-linux.png b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Safari-linux.png index 404ac1a4a3..8b026e7344 100644 Binary files a/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Safari-linux.png and b/core/src/components/img/test/basic/img.e2e.ts-snapshots/img-basic-md-rtl-Mobile-Safari-linux.png differ diff --git a/core/src/components/img/test/basic/index.html b/core/src/components/img/test/basic/index.html index a9e2ab8fcd..517ffcab84 100644 --- a/core/src/components/img/test/basic/index.html +++ b/core/src/components/img/test/basic/index.html @@ -28,7 +28,8 @@ + > + @@ -36,9 +37,9 @@ + > + @@ -68,6 +69,13 @@ background: blue; } + ion-img:not(#hidden) { + margin: 0 auto; + + max-width: 150px; + height: 150px; + } + #hidden { width: 300px; }