From 3794f5e3be35e3f5d457731e11087c2b2f900436 Mon Sep 17 00:00:00 2001 From: Laityned Date: Fri, 21 Oct 2022 00:14:41 +0200 Subject: [PATCH] Tests: next-image-legacy image loaded in static props --- .../default/pages/static-img.js | 13 ++++++++++- .../default/test/static.test.ts | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/test/integration/next-image-legacy/default/pages/static-img.js b/test/integration/next-image-legacy/default/pages/static-img.js index 4712c6d2de231..1ff35c5495847 100644 --- a/test/integration/next-image-legacy/default/pages/static-img.js +++ b/test/integration/next-image-legacy/default/pages/static-img.js @@ -1,5 +1,6 @@ import React from 'react' import testImg from '../public/foo/test-rect.jpg' +import testImgProp from '../public/exif-rotation.jpg' import Image from 'next/legacy/image' import testJPG from '../public/test.jpg' @@ -13,7 +14,11 @@ import testICO from '../public/test.ico' import TallImage from '../components/TallImage' -const Page = () => { +export const getStaticProps = () => ({ + props: { testImgProp }, +}) + +const Page = ({ testImgProp }) => { return (

Static Image

@@ -23,6 +28,12 @@ const Page = () => { layout="fixed" placeholder="blur" /> + { `style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%;background-size:cover;background-position:0% 0%;filter:blur(20px);background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAAOklEQVR42iWGsQkAIBDE0iuIdiLOJjiGIzjiL/Meb4okiNYIlLjK3hJMzCQG1/0qmXXOUkjAV+m9wAMe3QiV6Ne8VgAAAABJRU5ErkJggg==")` ) }) + + it('should load direct imported image', async () => { + const src = await browser.elementById('basic-static').getAttribute('src') + expect(src).toMatch( + /_next\/image\?url=%2F_next%2Fstatic%2Fmedia%2Ftest-rect(.+)\.jpg&w=828&q=75/ + ) + const fullSrc = new URL(src, `http://localhost:${appPort}`) + const res = await fetch(fullSrc) + expect(res.status).toBe(200) + }) + + it('should load staticprops imported image', async () => { + const src = await browser + .elementById('basic-staticprop') + .getAttribute('src') + expect(src).toMatch( + /_next\/image\?url=%2F_next%2Fstatic%2Fmedia%2Fexif-rotation(.+)\.jpg&w=256&q=75/ + ) + const fullSrc = new URL(src, `http://localhost:${appPort}`) + const res = await fetch(fullSrc) + expect(res.status).toBe(200) + }) } describe('Build Error Tests', () => {