@shopify/shop-minis-react 0.0.0-snapshot.20251216185714 → 0.0.0-snapshot.20251217194747
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/shop-minis-react",
|
|
3
3
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
4
|
-
"version": "0.0.0-snapshot.
|
|
4
|
+
"version": "0.0.0-snapshot.20251217194747",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": ">=5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@shopify/shop-minis-platform": "0.0.0-snapshot.
|
|
49
|
+
"@shopify/shop-minis-platform": "0.0.0-snapshot.20251217194747",
|
|
50
50
|
"@tailwindcss/vite": "4.1.8",
|
|
51
51
|
"@tanstack/react-query": "5.86.0",
|
|
52
52
|
"@types/color": "3.0.6",
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import {describe, expect, it, vi} from 'vitest'
|
|
1
|
+
import {describe, expect, it, vi, beforeAll} from 'vitest'
|
|
2
2
|
|
|
3
3
|
import {render, screen, waitFor} from '../../test-utils'
|
|
4
4
|
|
|
5
5
|
import {Image} from './image'
|
|
6
6
|
|
|
7
|
+
// Mock URL.revokeObjectURL for jsdom
|
|
8
|
+
beforeAll(() => {
|
|
9
|
+
URL.revokeObjectURL = vi.fn()
|
|
10
|
+
})
|
|
11
|
+
|
|
7
12
|
// Mock the util functions
|
|
8
13
|
vi.mock('../../utils', () => ({
|
|
9
|
-
|
|
10
|
-
thumbhash ? `
|
|
14
|
+
getThumbhashBlobURL: vi.fn((thumbhash?: string) =>
|
|
15
|
+
thumbhash ? `blob:http://localhost/${thumbhash}` : undefined
|
|
11
16
|
),
|
|
12
17
|
getResizedImageUrl: vi.fn((url?: string) => url),
|
|
13
18
|
}))
|
|
@@ -76,7 +81,7 @@ describe('Image', () => {
|
|
|
76
81
|
expect(wrapper.style.aspectRatio).toBe('16/9')
|
|
77
82
|
})
|
|
78
83
|
|
|
79
|
-
it('uses thumbhash as
|
|
84
|
+
it('uses thumbhash as placeholder when provided with fixed aspect ratio', () => {
|
|
80
85
|
const {container} = render(
|
|
81
86
|
<Image
|
|
82
87
|
src="https://example.com/image.jpg"
|
|
@@ -86,10 +91,15 @@ describe('Image', () => {
|
|
|
86
91
|
/>
|
|
87
92
|
)
|
|
88
93
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
// Thumbhash is now rendered as a separate img element (placeholder)
|
|
95
|
+
const images = container.querySelectorAll('img')
|
|
96
|
+
expect(images).toHaveLength(2) // placeholder + main image
|
|
97
|
+
const placeholderImg = images[0]
|
|
98
|
+
expect(placeholderImg).toHaveAttribute(
|
|
99
|
+
'src',
|
|
100
|
+
'blob:http://localhost/testThumbhash'
|
|
92
101
|
)
|
|
102
|
+
expect(placeholderImg).toHaveAttribute('aria-hidden', 'true')
|
|
93
103
|
})
|
|
94
104
|
|
|
95
105
|
it('renders with natural sizing when aspectRatio is auto', () => {
|
|
@@ -122,13 +132,17 @@ describe('Image', () => {
|
|
|
122
132
|
/>
|
|
123
133
|
)
|
|
124
134
|
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
// Thumbhash is now rendered as a separate img element (placeholder)
|
|
136
|
+
const images = container.querySelectorAll('img')
|
|
137
|
+
expect(images).toHaveLength(2) // placeholder + main image
|
|
138
|
+
const placeholderImg = images[0]
|
|
139
|
+
expect(placeholderImg).toHaveAttribute(
|
|
140
|
+
'src',
|
|
141
|
+
'blob:http://localhost/testThumbhash'
|
|
130
142
|
)
|
|
131
|
-
|
|
143
|
+
|
|
144
|
+
const mainImg = images[1]
|
|
145
|
+
expect(mainImg).toHaveClass('w-full', 'h-auto')
|
|
132
146
|
})
|
|
133
147
|
|
|
134
148
|
it('passes additional props to img element', () => {
|