Skip to content

Commit

Permalink
#184 Ignore iOS home indicator (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
GRiMe2D authored Jun 1, 2023
1 parent abfa064 commit ce34677
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 7 deletions.
12 changes: 10 additions & 2 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import looksSame from 'looks-same';
import imageSize from 'image-size';
import nodeFetch from 'node-fetch';

var swatcherVersion = '1.6.0';
var swatcherVersion = '1.6.1';

class GithubActionsEnvironment {
constructor (githubPayload) {
Expand Down Expand Up @@ -397,7 +397,15 @@ const doesClusterContains = (bigger, smaller) => (
);

const isClusterHomeIndicator = (dimensions, cluster) => (
isInRange(cluster.height, 4, 6) && isInRange(dimensions.height - cluster.bottom, 7, 9)
doesClusterContains(
{
left: (dimensions.width - 148) / 2,
top: dimensions.height - 15,
right: (dimensions.width + 148) / 2,
bottom: dimensions.height
},
cluster
)
);

const isClusterTextFieldCaret = (dimensions, cluster) => (
Expand Down
Binary file added e2e/fixtures/iphone_home_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/fixtures/iphone_home_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@del-systems/swatcher",
"version": "1.6.0",
"version": "1.6.1",
"description": "Screenshot Watcher",
"keywords": [
"screenshots",
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/compare_pngs_ignore_home_indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ it('should ignore iOS home indicator but nothing else', async () => {
)
expect(equal).toBeFalsy()
}, DEFAULT_TIMEOUT)

it('should ignore iOS home indicator', async () => {
const { equal } = await comparePNGs(
fixturePath('iphone_home_1.png'),
fixturePath('iphone_home_2.png')
)
expect(equal).toBeTruthy()
}, DEFAULT_TIMEOUT)
10 changes: 9 additions & 1 deletion src/compare_pngs.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ const doesClusterContains = (bigger, smaller) => (
)

const isClusterHomeIndicator = (dimensions, cluster) => (
isInRange(cluster.height, 4, 6) && isInRange(dimensions.height - cluster.bottom, 7, 9)
doesClusterContains(
{
left: (dimensions.width - 148) / 2,
top: dimensions.height - 15,
right: (dimensions.width + 148) / 2,
bottom: dimensions.height
},
cluster
)
)

const isClusterTextFieldCaret = (dimensions, cluster) => (
Expand Down
2 changes: 1 addition & 1 deletion version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default '1.6.0'
export default '1.6.1'

0 comments on commit ce34677

Please sign in to comment.