Skip to content

Commit 1799786

Browse files
committed
test: adjust tests to look for .netlify/images and not _next/image
1 parent 204cb66 commit 1799786

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

adapters-notes.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
## Feedback
22

3-
- Files from `public` directory not listed in `outputs.staticFiles`
4-
- In `onBuildComplete` - `config.images.remotePatterns` type is `(RemotePattern | URL)[]` but in
5-
reality `URL` inputs are converted to `RemotePattern` so type should be just `RemotePattern[]`
3+
- Files from `public` directory not listed in `outputs.staticFiles`. Should they be?
64
- `routes.headers` does not contain immutable cache-control headers for `_next/static`
7-
- `outputs.middleware` does not contain env that exist in `middleware-manifest.json` (i.e.
8-
`NEXT_SERVER_ACTIONS_ENCRYPTION_KEY`, `NEXT_PREVIEW_MODE_ID`, `NEXT_PREVIEW_MODE_SIGNING_KEY` etc)
5+
- In `onBuildComplete` - `config.images.remotePatterns` type is `(RemotePattern | URL)[]` but in
6+
reality `URL` inputs are converted to `RemotePattern` so type should be just `RemotePattern[]` in
7+
`onBuildComplete` (this would require different config type for `modifyConfig` (allow inputs
8+
here?) and `onBuildComplete` (final, normalized config shape)?)
99
- `outputs.middleware.config.matchers` can be undefined per types - can that ever happen? Can we
10-
just have empty array instead to simplify handling.
10+
just have empty array instead to simplify handling (possibly similar as above point where type is
11+
for the input, while "output" will have a default matcher if not defined by user).
12+
- `outputs.middleware` does not contain `env` that exist in `middleware-manifest.json` (i.e.
13+
`NEXT_SERVER_ACTIONS_ENCRYPTION_KEY`, `NEXT_PREVIEW_MODE_ID`, `NEXT_PREVIEW_MODE_SIGNING_KEY` etc)
14+
or `wasm` (tho wasm files are included in assets, so I think I have a way to support those as-is,
15+
but need to to make some assumption about using extension-less file name of wasm file as
16+
identifier)
1117
- `outputs.staticFiles` (i18n enabled) custom fully static (no `getStaticProps`) `/pages/404.js`
1218
`filePath` point to not existing file (it doesn't have i18n locale prefix in `staticFiles` array,
1319
actual 404.html are written to i18n locale prefixed directories)
@@ -45,7 +51,8 @@
4551
handler and convert those files into blobs to upload later
4652
- [partially done - for edge runtime] use middleware output to generate middleware edge function
4753
- [done] don't glob for static files and use `outputs.staticFiles` instead
48-
- don't read various manifest files manually and use provided context in `onBuildComplete` instead
54+
- note any remaining manual manifest files reading in build plugin once everything that could be
55+
adjusted was handled
4956

5057
## To figure out
5158

tests/e2e/export.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ test('Renders the Home page correctly with output export and custom dist dir', a
5454

5555
test.describe('next/image is using Netlify Image CDN', () => {
5656
test('Local images', async ({ page, outputExport }) => {
57-
const nextImageResponsePromise = page.waitForResponse('**/_next/image**')
57+
const nextImageResponsePromise = page.waitForResponse('**/.netlify/images**')
5858

5959
await page.goto(`${outputExport.url}/image/local`)
6060

6161
const nextImageResponse = await nextImageResponsePromise
62-
expect(nextImageResponse.request().url()).toContain('_next/image?url=%2Fsquirrel.jpg')
62+
expect(nextImageResponse.request().url()).toContain('.netlify/images?url=%2Fsquirrel.jpg')
6363

6464
expect(nextImageResponse.status()).toBe(200)
6565
// ensure next/image is using Image CDN

tests/e2e/simple-app.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ test.skip('streams stale responses', async ({ simple }) => {
110110

111111
test.describe('next/image is using Netlify Image CDN', () => {
112112
test('Local images', async ({ page, simple }) => {
113-
const nextImageResponsePromise = page.waitForResponse('**/_next/image**')
113+
const nextImageResponsePromise = page.waitForResponse('**/.netlify/images**')
114114

115115
await page.goto(`${simple.url}/image/local`)
116116

117117
const nextImageResponse = await nextImageResponsePromise
118-
expect(nextImageResponse.request().url()).toContain('_next/image?url=%2Fsquirrel.jpg')
118+
expect(nextImageResponse.request().url()).toContain('.netlify/images?url=%2Fsquirrel.jpg')
119119

120120
expect(nextImageResponse.status()).toBe(200)
121121
// ensure next/image is using Image CDN
@@ -131,14 +131,14 @@ test.describe('next/image is using Netlify Image CDN', () => {
131131
page,
132132
simple,
133133
}) => {
134-
const nextImageResponsePromise = page.waitForResponse('**/_next/image**')
134+
const nextImageResponsePromise = page.waitForResponse('**/.netlify/images**')
135135

136136
await page.goto(`${simple.url}/image/remote-pattern-1`)
137137

138138
const nextImageResponse = await nextImageResponsePromise
139139

140140
expect(nextImageResponse.url()).toContain(
141-
`_next/image?url=${encodeURIComponent(
141+
`.netlify/images?url=${encodeURIComponent(
142142
'https://images.unsplash.com/photo-1574870111867-089730e5a72b',
143143
)}`,
144144
)
@@ -155,14 +155,14 @@ test.describe('next/image is using Netlify Image CDN', () => {
155155
page,
156156
simple,
157157
}) => {
158-
const nextImageResponsePromise = page.waitForResponse('**/_next/image**')
158+
const nextImageResponsePromise = page.waitForResponse('**/.netlify/images**')
159159

160160
await page.goto(`${simple.url}/image/remote-pattern-2`)
161161

162162
const nextImageResponse = await nextImageResponsePromise
163163

164164
expect(nextImageResponse.url()).toContain(
165-
`_next/image?url=${encodeURIComponent(
165+
`.netlify/images?url=${encodeURIComponent(
166166
'https://cdn.pixabay.com/photo/2017/02/20/18/03/cat-2083492_1280.jpg',
167167
)}`,
168168
)
@@ -176,14 +176,14 @@ test.describe('next/image is using Netlify Image CDN', () => {
176176
})
177177

178178
test('Remote images: domains', async ({ page, simple }) => {
179-
const nextImageResponsePromise = page.waitForResponse('**/_next/image**')
179+
const nextImageResponsePromise = page.waitForResponse('**/.netlify/images**')
180180

181181
await page.goto(`${simple.url}/image/remote-domain`)
182182

183183
const nextImageResponse = await nextImageResponsePromise
184184

185185
expect(nextImageResponse.url()).toContain(
186-
`_next/image?url=${encodeURIComponent(
186+
`.netlify/images?url=${encodeURIComponent(
187187
'https://images.pexels.com/photos/406014/pexels-photo-406014.jpeg',
188188
)}`,
189189
)

0 commit comments

Comments
 (0)