Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/integration/next-image-legacy/default/pages/priority.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ const Page = () => {
layout="responsive"
/>
<p id="stubtext">This is the priority page</p>
<div style={{ height: '1000vh' }} />
<Image
priority
id="belowthefold"
src="/test.tiff"
width="400"
height="400"
alt=""
/>
</div>
)
}
Expand Down
8 changes: 8 additions & 0 deletions test/integration/next-image-legacy/default/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ function runTests(mode) {
imagesrcset:
'/_next/image?url=%2Fwide.png&w=640&q=75 640w, /_next/image?url=%2Fwide.png&w=750&q=75 750w, /_next/image?url=%2Fwide.png&w=828&q=75 828w, /_next/image?url=%2Fwide.png&w=1080&q=75 1080w, /_next/image?url=%2Fwide.png&w=1200&q=75 1200w, /_next/image?url=%2Fwide.png&w=1920&q=75 1920w, /_next/image?url=%2Fwide.png&w=2048&q=75 2048w, /_next/image?url=%2Fwide.png&w=3840&q=75 3840w',
},
{
imagesizes: '',
imagesrcset:
'/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x',
},
])

// When priority={true}, we should _not_ set loading="lazy"
Expand All @@ -171,6 +176,9 @@ function runTests(mode) {
expect(
await browser.elementById('responsive2').getAttribute('loading')
).toBe(null)
expect(
await browser.elementById('belowthefold').getAttribute('loading')
).toBe(null)

const warnings = (await browser.log())
.map((log) => log.message)
Expand Down
9 changes: 9 additions & 0 deletions test/integration/next-image-new/app-dir/app/priority/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ const Page = () => {
fetchPriority="low"
/>
<p id="stubtext">This is the priority page</p>
<div style={{ height: '1000vh' }} />
<Image
priority
id="belowthefold"
src="/test.tiff"
width="400"
height="400"
alt=""
/>
</div>
)
}
Expand Down
22 changes: 22 additions & 0 deletions test/integration/next-image-new/app-dir/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ function runTests(mode) {
referrerpolicy: 'no-referrer',
})

expect(
entries.find(
(item) =>
item.imagesrcset ===
'/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x'
)
).toEqual({
fetchpriority: 'high',
imagesizes: '',
imagesrcset:
'/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x',
crossorigin: '',
referrerpolicy: '',
})

// When priority={true}, we should _not_ set loading="lazy"
expect(
await browser.elementById('basic-image').getAttribute('loading')
Expand Down Expand Up @@ -216,6 +231,13 @@ function runTests(mode) {
'lazy'
)

expect(
await browser.elementById('belowthefold').getAttribute('fetchpriority')
).toBe('high')
expect(
await browser.elementById('belowthefold').getAttribute('loading')
).toBe(null)

const warnings = (await browser.log('browser'))
.map((log) => log.message)
.join('\n')
Expand Down
9 changes: 9 additions & 0 deletions test/integration/next-image-new/default/pages/priority.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ const Page = () => {
fetchPriority="low"
/>
<p id="stubtext">This is the priority page</p>
<div style={{ height: '1000vh' }} />
<Image
priority
id="belowthefold"
src="/test.tiff"
width="400"
height="400"
alt=""
/>
</div>
)
}
Expand Down
22 changes: 22 additions & 0 deletions test/integration/next-image-new/default/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ function runTests(mode) {
referrerpolicy: 'no-referrer',
})

expect(
entries.find(
(item) =>
item.imagesrcset ===
'/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x'
)
).toEqual({
fetchpriority: 'high',
imagesizes: '',
imagesrcset:
'/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x',
crossorigin: '',
referrerpolicy: '',
})

// When priority={true}, we should _not_ set loading="lazy"
expect(
await browser.elementById('basic-image').getAttribute('loading')
Expand Down Expand Up @@ -217,6 +232,13 @@ function runTests(mode) {
'lazy'
)

expect(
await browser.elementById('belowthefold').getAttribute('fetchpriority')
).toBe('high')
expect(
await browser.elementById('belowthefold').getAttribute('loading')
).toBe(null)

const warnings = (await browser.log('browser'))
.map((log) => log.message)
.join('\n')
Expand Down