Skip to content

Commit

Permalink
Update flakey next-image tests (vercel#55838)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Sep 22, 2023
1 parent 7f1c055 commit 2cc30fc
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 27 deletions.
40 changes: 28 additions & 12 deletions test/integration/next-image-legacy/base-path/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,13 @@ function runTests(mode) {
const height = 700
const delta = 250
const id = 'intrinsic1'
expect(await getSrc(browser, id)).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75'
)

await check(async () => {
expect(await getSrc(browser, id)).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75'
)
return 'success'
}, 'success')
expect(await browser.elementById(id).getAttribute('srcset')).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=1200&q=75 1x, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75 2x'
)
Expand Down Expand Up @@ -260,9 +264,13 @@ function runTests(mode) {
const height = 350
const delta = 150
const id = 'fill1'
expect(await getSrc(browser, id)).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75'
)

await check(async () => {
expect(await getSrc(browser, id)).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75'
)
return 'success'
}, 'success')
expect(await browser.elementById(id).getAttribute('srcset')).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=640&q=75 640w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=750&q=75 750w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=828&q=75 828w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=1080&q=75 1080w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=1200&q=75 1200w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=1920&q=75 1920w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=2048&q=75 2048w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75 3840w'
)
Expand Down Expand Up @@ -300,9 +308,13 @@ function runTests(mode) {
const width = await getComputed(browser, id, 'width')
const height = await getComputed(browser, id, 'height')
await browser.eval(`document.getElementById("${id}").scrollIntoView()`)
expect(await getSrc(browser, id)).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75'
)

await check(async () => {
expect(await getSrc(browser, id)).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75'
)
return 'success'
}, 'success')
expect(await browser.elementById(id).getAttribute('srcset')).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=640&q=75 640w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=750&q=75 750w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=828&q=75 828w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=1080&q=75 1080w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=1200&q=75 1200w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=1920&q=75 1920w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=2048&q=75 2048w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75 3840w'
)
Expand Down Expand Up @@ -350,9 +362,13 @@ function runTests(mode) {
const height = 700
const delta = 250
const id = 'sizes1'
expect(await getSrc(browser, id)).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75'
)

await check(async () => {
expect(await getSrc(browser, id)).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75'
)
return 'success'
}, 'success')
expect(await browser.elementById(id).getAttribute('srcset')).toBe(
'/docs/_next/image?url=%2Fdocs%2Fwide.png&w=16&q=75 16w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=32&q=75 32w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=48&q=75 48w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=64&q=75 64w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=96&q=75 96w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=128&q=75 128w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=256&q=75 256w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=384&q=75 384w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=640&q=75 640w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=750&q=75 750w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=828&q=75 828w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=1080&q=75 1080w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=1200&q=75 1200w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=1920&q=75 1920w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=2048&q=75 2048w, /docs/_next/image?url=%2Fdocs%2Fwide.png&w=3840&q=75 3840w'
)
Expand Down
50 changes: 35 additions & 15 deletions test/integration/next-image-legacy/default/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,13 @@ function runTests(mode) {
const height = 700
const delta = 250
const id = 'fixed1'
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)

await check(async () => {
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)
return 'success'
}, 'success')
expect(await browser.elementById(id).getAttribute('srcset')).toBe(
'/_next/image?url=%2Fwide.png&w=1200&q=75 1x, /_next/image?url=%2Fwide.png&w=3840&q=75 2x'
)
Expand Down Expand Up @@ -503,9 +507,13 @@ function runTests(mode) {
const height = 700
const delta = 250
const id = 'intrinsic1'
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)

await check(async () => {
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)
return 'success'
}, 'success')
expect(await browser.elementById(id).getAttribute('srcset')).toBe(
'/_next/image?url=%2Fwide.png&w=1200&q=75 1x, /_next/image?url=%2Fwide.png&w=3840&q=75 2x'
)
Expand Down Expand Up @@ -587,9 +595,13 @@ function runTests(mode) {
const height = 350
const delta = 150
const id = 'fill1'
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)

await check(async () => {
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)
return 'success'
}, 'success')
expect(await browser.elementById(id).getAttribute('srcset')).toBe(
'/_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'
)
Expand Down Expand Up @@ -627,9 +639,13 @@ function runTests(mode) {
const width = await getComputed(browser, id, 'width')
const height = await getComputed(browser, id, 'height')
await browser.eval(`document.getElementById("${id}").scrollIntoView()`)
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)

await check(async () => {
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)
return 'success'
}, 'success')

await check(() => {
return browser.eval(
Expand Down Expand Up @@ -694,9 +710,13 @@ function runTests(mode) {
const height = 700
const delta = 250
const id = 'sizes1'
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)

await check(async () => {
expect(await getSrc(browser, id)).toBe(
'/_next/image?url=%2Fwide.png&w=3840&q=75'
)
return 'success'
}, 'success')
expect(await browser.elementById(id).getAttribute('srcset')).toBe(
'/_next/image?url=%2Fwide.png&w=16&q=75 16w, /_next/image?url=%2Fwide.png&w=32&q=75 32w, /_next/image?url=%2Fwide.png&w=48&q=75 48w, /_next/image?url=%2Fwide.png&w=64&q=75 64w, /_next/image?url=%2Fwide.png&w=96&q=75 96w, /_next/image?url=%2Fwide.png&w=128&q=75 128w, /_next/image?url=%2Fwide.png&w=256&q=75 256w, /_next/image?url=%2Fwide.png&w=384&q=75 384w, /_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'
)
Expand Down

0 comments on commit 2cc30fc

Please sign in to comment.