Skip to content

Commit 93af917

Browse files
committed
fix: fix ios incorrect cropping and stitching
- update tests and snapshots
1 parent 5788bb5 commit 93af917

File tree

9 files changed

+209
-50
lines changed

9 files changed

+209
-50
lines changed

packages/image-comparison-core/src/methods/__snapshots__/images.test.ts.snap

Lines changed: 93 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,10 @@ exports[`makeFullPageBase64Image > should create full page base64 image with mul
854854
[
855855
[
856856
{
857+
"bitmap": {
858+
"height": 800,
859+
"width": 1000,
860+
},
857861
"composite": [MockFunction spy],
858862
"crop": [MockFunction spy] {
859863
"calls": [
@@ -906,6 +910,10 @@ exports[`makeFullPageBase64Image > should create full page base64 image with mul
906910
],
907911
[
908912
{
913+
"bitmap": {
914+
"height": 800,
915+
"width": 1000,
916+
},
909917
"composite": [MockFunction spy],
910918
"crop": [MockFunction spy] {
911919
"calls": [
@@ -958,6 +966,10 @@ exports[`makeFullPageBase64Image > should create full page base64 image with mul
958966
],
959967
[
960968
{
969+
"bitmap": {
970+
"height": 800,
971+
"width": 1000,
972+
},
961973
"composite": [MockFunction spy],
962974
"crop": [MockFunction spy] {
963975
"calls": [
@@ -1025,6 +1037,10 @@ exports[`makeFullPageBase64Image > should handle canvas Y positions correctly 1`
10251037
[
10261038
[
10271039
{
1040+
"bitmap": {
1041+
"height": 800,
1042+
"width": 1000,
1043+
},
10281044
"composite": [MockFunction spy],
10291045
"crop": [MockFunction spy] {
10301046
"calls": [
@@ -1077,6 +1093,10 @@ exports[`makeFullPageBase64Image > should handle canvas Y positions correctly 1`
10771093
],
10781094
[
10791095
{
1096+
"bitmap": {
1097+
"height": 800,
1098+
"width": 1000,
1099+
},
10801100
"composite": [MockFunction spy],
10811101
"crop": [MockFunction spy] {
10821102
"calls": [
@@ -1129,6 +1149,10 @@ exports[`makeFullPageBase64Image > should handle canvas Y positions correctly 1`
11291149
],
11301150
[
11311151
{
1152+
"bitmap": {
1153+
"height": 800,
1154+
"width": 1000,
1155+
},
11321156
"composite": [MockFunction spy],
11331157
"crop": [MockFunction spy] {
11341158
"calls": [
@@ -1234,6 +1258,10 @@ exports[`makeFullPageBase64Image > should handle different device pixel ratios 3
12341258
[
12351259
[
12361260
{
1261+
"bitmap": {
1262+
"height": 800,
1263+
"width": 1000,
1264+
},
12371265
"composite": [MockFunction spy],
12381266
"crop": [MockFunction spy] {
12391267
"calls": [
@@ -1286,6 +1314,10 @@ exports[`makeFullPageBase64Image > should handle different device pixel ratios 3
12861314
],
12871315
[
12881316
{
1317+
"bitmap": {
1318+
"height": 800,
1319+
"width": 1000,
1320+
},
12891321
"composite": [MockFunction spy],
12901322
"crop": [MockFunction spy] {
12911323
"calls": [
@@ -1338,6 +1370,10 @@ exports[`makeFullPageBase64Image > should handle different device pixel ratios 3
13381370
],
13391371
[
13401372
{
1373+
"bitmap": {
1374+
"height": 800,
1375+
"width": 1000,
1376+
},
13411377
"composite": [MockFunction spy],
13421378
"crop": [MockFunction spy] {
13431379
"calls": [
@@ -1478,6 +1514,10 @@ exports[`makeFullPageBase64Image > should handle landscape mode with rotation 3`
14781514
[
14791515
[
14801516
{
1517+
"bitmap": {
1518+
"height": 800,
1519+
"width": 1000,
1520+
},
14811521
"composite": [MockFunction spy],
14821522
"crop": [MockFunction spy] {
14831523
"calls": [
@@ -1582,6 +1622,10 @@ exports[`makeFullPageBase64Image > should handle landscape mode with rotation 3`
15821622
],
15831623
[
15841624
{
1625+
"bitmap": {
1626+
"height": 800,
1627+
"width": 1000,
1628+
},
15851629
"composite": [MockFunction spy],
15861630
"crop": [MockFunction spy] {
15871631
"calls": [
@@ -1686,6 +1730,10 @@ exports[`makeFullPageBase64Image > should handle landscape mode with rotation 3`
16861730
],
16871731
[
16881732
{
1733+
"bitmap": {
1734+
"height": 800,
1735+
"width": 1000,
1736+
},
16891737
"composite": [MockFunction spy],
16901738
"crop": [MockFunction spy] {
16911739
"calls": [
@@ -1843,6 +1891,10 @@ exports[`makeFullPageBase64Image > should handle landscape mode without rotation
18431891
[
18441892
[
18451893
{
1894+
"bitmap": {
1895+
"height": 800,
1896+
"width": 1000,
1897+
},
18461898
"composite": [MockFunction spy],
18471899
"crop": [MockFunction spy] {
18481900
"calls": [
@@ -1895,6 +1947,10 @@ exports[`makeFullPageBase64Image > should handle landscape mode without rotation
18951947
],
18961948
[
18971949
{
1950+
"bitmap": {
1951+
"height": 800,
1952+
"width": 1000,
1953+
},
18981954
"composite": [MockFunction spy],
18991955
"crop": [MockFunction spy] {
19001956
"calls": [
@@ -1947,6 +2003,10 @@ exports[`makeFullPageBase64Image > should handle landscape mode without rotation
19472003
],
19482004
[
19492005
{
2006+
"bitmap": {
2007+
"height": 800,
2008+
"width": 1000,
2009+
},
19502010
"composite": [MockFunction spy],
19512011
"crop": [MockFunction spy] {
19522012
"calls": [
@@ -2015,8 +2075,8 @@ exports[`makeFullPageBase64Image > should handle large canvas dimensions 2`] = `
20152075
[
20162076
[
20172077
{
2018-
"h": 2000,
2019-
"w": 3000,
2078+
"h": 800,
2079+
"w": 1000,
20202080
"x": 0,
20212081
"y": 0,
20222082
},
@@ -2028,13 +2088,17 @@ exports[`makeFullPageBase64Image > should handle large canvas dimensions 3`] = `
20282088
[
20292089
[
20302090
{
2091+
"bitmap": {
2092+
"height": 800,
2093+
"width": 1000,
2094+
},
20312095
"composite": [MockFunction spy],
20322096
"crop": [MockFunction spy] {
20332097
"calls": [
20342098
[
20352099
{
2036-
"h": 2000,
2037-
"w": 3000,
2100+
"h": 800,
2101+
"w": 1000,
20382102
"x": 0,
20392103
"y": 0,
20402104
},
@@ -2085,6 +2149,10 @@ exports[`makeFullPageBase64Image > should handle screenshots with cropping posit
20852149
[
20862150
[
20872151
{
2152+
"bitmap": {
2153+
"height": 800,
2154+
"width": 1000,
2155+
},
20882156
"composite": [MockFunction spy],
20892157
"crop": [MockFunction spy] {
20902158
"calls": [
@@ -2134,15 +2202,15 @@ exports[`makeFullPageBase64Image > should handle screenshots with different dime
21342202
[
21352203
{
21362204
"h": 600,
2137-
"w": 1200,
2205+
"w": 1000,
21382206
"x": 0,
21392207
"y": 0,
21402208
},
21412209
],
21422210
[
21432211
{
2144-
"h": 900,
2145-
"w": 1200,
2212+
"h": 800,
2213+
"w": 1000,
21462214
"x": 0,
21472215
"y": 0,
21482216
},
@@ -2154,21 +2222,25 @@ exports[`makeFullPageBase64Image > should handle screenshots with different dime
21542222
[
21552223
[
21562224
{
2225+
"bitmap": {
2226+
"height": 800,
2227+
"width": 1000,
2228+
},
21572229
"composite": [MockFunction spy],
21582230
"crop": [MockFunction spy] {
21592231
"calls": [
21602232
[
21612233
{
21622234
"h": 600,
2163-
"w": 1200,
2235+
"w": 1000,
21642236
"x": 0,
21652237
"y": 0,
21662238
},
21672239
],
21682240
[
21692241
{
2170-
"h": 900,
2171-
"w": 1200,
2242+
"h": 800,
2243+
"w": 1000,
21722244
"x": 0,
21732245
"y": 0,
21742246
},
@@ -2194,21 +2266,25 @@ exports[`makeFullPageBase64Image > should handle screenshots with different dime
21942266
],
21952267
[
21962268
{
2269+
"bitmap": {
2270+
"height": 800,
2271+
"width": 1000,
2272+
},
21972273
"composite": [MockFunction spy],
21982274
"crop": [MockFunction spy] {
21992275
"calls": [
22002276
[
22012277
{
22022278
"h": 600,
2203-
"w": 1200,
2279+
"w": 1000,
22042280
"x": 0,
22052281
"y": 0,
22062282
},
22072283
],
22082284
[
22092285
{
2210-
"h": 900,
2211-
"w": 1200,
2286+
"h": 800,
2287+
"w": 1000,
22122288
"x": 0,
22132289
"y": 0,
22142290
},
@@ -2263,6 +2339,10 @@ exports[`makeFullPageBase64Image > should handle single screenshot 3`] = `
22632339
[
22642340
[
22652341
{
2342+
"bitmap": {
2343+
"height": 800,
2344+
"width": 1000,
2345+
},
22662346
"composite": [MockFunction spy],
22672347
"crop": [MockFunction spy] {
22682348
"calls": [

packages/image-comparison-core/src/methods/images.executeImageCompare.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe('executeImageCompare', () => {
205205
diffFilePath: '/mock/diff/test.png'
206206
})
207207
vi.mocked(rectangles.determineStatusAddressToolBarRectangles).mockReturnValue(null as any)
208-
vi.mocked(rectangles.prepareIgnoreRectangles).mockReturnValue({
208+
vi.mocked(rectangles.prepareIgnoreRectangles).mockResolvedValue({
209209
ignoredBoxes: [],
210210
hasIgnoreRectangles: false
211211
})
@@ -281,7 +281,7 @@ describe('executeImageCompare', () => {
281281
}
282282
}
283283

284-
vi.mocked(rectangles.prepareIgnoreRectangles).mockReturnValue({
284+
vi.mocked(rectangles.prepareIgnoreRectangles).mockResolvedValue({
285285
ignoredBoxes: [{ left: 0, top: 0, right: 100, bottom: 50 }],
286286
hasIgnoreRectangles: true
287287
})
@@ -317,7 +317,7 @@ describe('executeImageCompare', () => {
317317
folderOptions: { ...mockOptions.folderOptions, isMobile: true }
318318
}
319319

320-
vi.mocked(rectangles.prepareIgnoreRectangles).mockReturnValue({
320+
vi.mocked(rectangles.prepareIgnoreRectangles).mockResolvedValue({
321321
ignoredBoxes: [{ left: 10, top: 10, right: 60, bottom: 60 }], // Only non-zero rectangle
322322
hasIgnoreRectangles: true
323323
})
@@ -361,7 +361,7 @@ describe('executeImageCompare', () => {
361361
}
362362
}
363363

364-
vi.mocked(rectangles.prepareIgnoreRectangles).mockReturnValue({
364+
vi.mocked(rectangles.prepareIgnoreRectangles).mockResolvedValue({
365365
ignoredBoxes: [],
366366
hasIgnoreRectangles: false
367367
})
@@ -403,7 +403,7 @@ describe('executeImageCompare', () => {
403403
}
404404
}
405405

406-
vi.mocked(rectangles.prepareIgnoreRectangles).mockReturnValue({
406+
vi.mocked(rectangles.prepareIgnoreRectangles).mockResolvedValue({
407407
ignoredBoxes: [
408408
{ left: 0, top: 0, right: 100, bottom: 50 },
409409
{ left: 200, top: 200, right: 300, bottom: 300 }
@@ -591,7 +591,7 @@ describe('executeImageCompare', () => {
591591
ignoreRegions: [{ x: 0, y: 0, width: 100, height: 50 }]
592592
}
593593

594-
vi.mocked(rectangles.prepareIgnoreRectangles).mockReturnValue({
594+
vi.mocked(rectangles.prepareIgnoreRectangles).mockResolvedValue({
595595
ignoredBoxes: [{ left: 0, top: 0, right: 100, bottom: 50 }],
596596
hasIgnoreRectangles: true
597597
})
@@ -713,7 +713,7 @@ describe('executeImageCompare', () => {
713713
}
714714
}
715715

716-
vi.mocked(rectangles.prepareIgnoreRectangles).mockReturnValue({
716+
vi.mocked(rectangles.prepareIgnoreRectangles).mockResolvedValue({
717717
ignoredBoxes: [{ bottom: 50, right: 100, left: 0, top: 0 }],
718718
hasIgnoreRectangles: true
719719
})

packages/image-comparison-core/src/methods/images.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,10 @@ describe('makeFullPageBase64Image', () => {
11961196
getBase64: vi.fn().mockResolvedValue('data:image/png;base64,fullPageImageData'),
11971197
}
11981198
mockImage = {
1199+
bitmap: {
1200+
width: 1000,
1201+
height: 800,
1202+
},
11991203
crop: vi.fn().mockReturnThis(),
12001204
composite: vi.fn().mockReturnThis(),
12011205
getBase64: vi.fn().mockResolvedValue('data:image/png;base64,mockImageData'),

0 commit comments

Comments
 (0)