Unverified Commit 1cfcc177 authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

[test] Cover external `next/image` in adapter deployments (#99466)

The existing `image-from-node-modules` fixture renders `next/image` when
Next.js prerenders its static page. It does not render the external
image component during an SSR request, when an adapter deployment loads
image configuration from the frozen `required-server-files.json`
manifest. This change adds a `getServerSideProps` route, keeps
`my-cool-image` external, and configures two `images.deviceSizes`.
Before #99394, the adapter deployment fails when `next/image` sorts the
frozen manifest configuration.
parent 4593aec0
...@@ -18,6 +18,14 @@ describe('Image Component from node_modules', () => { ...@@ -18,6 +18,14 @@ describe('Image Component from node_modules', () => {
expect(srcset).toMatch('1234') expect(srcset).toMatch('1234')
}) })
it('renders an external image during server-side rendering', async () => {
const response = await next.fetch('/ssr')
expect(response.status).toBe(200)
const html = await response.text()
expect(html).toContain('id="ssr-image-from-node-modules"')
expect(html).toContain('w=1234')
})
it('should warn when using images.domains config', async () => { it('should warn when using images.domains config', async () => {
expect(next.cliOutput).toContain( expect(next.cliOutput).toContain(
'`images.domains` is deprecated in favor of `images.remotePatterns`. Please update next.config.js to protect your application from malicious users.' '`images.domains` is deprecated in favor of `images.remotePatterns`. Please update next.config.js to protect your application from malicious users.'
......
module.exports = { module.exports = {
serverExternalPackages: ['my-cool-image'],
images: { images: {
domains: ['i.imgur.com'], domains: ['i.imgur.com'],
deviceSizes: [1234], deviceSizes: [1234, 640],
}, },
} }
import MyCoolImage from 'my-cool-image'
export function getServerSideProps() {
return { props: {} }
}
export default function Page() {
return (
<MyCoolImage
id="ssr-image-from-node-modules"
width={640}
height={427}
src="https://i.imgur.com/CgezKMb.jpg"
/>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment