Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for appdir referenced images (#49242)
### What? Regression test for #49236 ### Why? ### How?
- Loading branch information
1 parent
4743dc6
commit ba4c2f2
Showing
6 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/app/input/app/layout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function RootLayout({ children }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/app/input/app/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Image from 'next/image' | ||
import img from '../public/triangle-black.png' | ||
import Test from './test' | ||
|
||
export default function Home() { | ||
return [ | ||
<Image | ||
id="imported" | ||
alt="test imported image" | ||
src={img} | ||
placeholder="blur" | ||
/>, | ||
<Test />, | ||
] | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/app/input/app/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use client' | ||
import { useTestHarness } from '@turbo/pack-test-harness' | ||
|
||
export default function Test() { | ||
useTestHarness(runTests) | ||
} | ||
|
||
function runTests() { | ||
it('should link to imported image', async () => { | ||
const img = document.querySelector('#imported') | ||
expect(img.src).toContain(encodeURIComponent('_next/static/assets')) | ||
|
||
const res = await fetch(img.src) | ||
expect(res.status).toBe(200) | ||
}) | ||
} |
8 changes: 8 additions & 0 deletions
8
...ages/next-swc/crates/next-dev-tests/tests/integration/next/image/app/input/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
module.exports = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
} |
Binary file added
BIN
+4.19 KB
...next-dev-tests/tests/integration/next/image/app/input/public/triangle-black.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters