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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/ic_stat_onesignal_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
386 changes: 216 additions & 170 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
"@react-native-firebase/remote-config": "26.3.3",
"@sentry/react-native": "~7.11.0",
"@tanstack/react-query": "^5.102.8",
"expo": "~57.0.23",
"expo": "~57.0.24",
"expo-application": "~57.0.3",
"expo-constants": "~57.0.18",
"expo-constants": "~57.0.19",
"expo-dev-client": "~57.0.19",
"expo-font": "~57.0.4",
"expo-in-app-updates": "0.12.0",
"expo-linking": "~57.0.10",
"expo-localization": "~57.0.2",
"expo-router": "~57.0.21",
"expo-router": "~57.0.22",
"expo-splash-screen": "~57.0.9",
"expo-status-bar": "~57.0.1",
"expo-system-ui": "~57.0.4",
Expand Down
75 changes: 69 additions & 6 deletions tests/contracts/app-config.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";

interface PngImage {
data: Uint8Array;
height: number;
width: number;
}

interface PngModule {
PNG: {
sync: {
read(buffer: Buffer): PngImage;
};
};
}

const { PNG } = jest.requireActual<PngModule>("pngjs");

function getOpaqueBounds(imagePath: string): {
height: number;
width: number;
} {
const image = PNG.sync.read(readFileSync(imagePath));
let minX = image.width;
let minY = image.height;
let maxX = -1;
let maxY = -1;

for (let y = 0; y < image.height; y += 1) {
for (let x = 0; x < image.width; x += 1) {
const alpha = image.data[(y * image.width + x) * 4 + 3] ?? 0;

if (alpha > 0) {
minX = Math.min(minX, x);
minY = Math.min(minY, y);
maxX = Math.max(maxX, x);
maxY = Math.max(maxY, y);
}
}
}

return {
height: maxY - minY + 1,
width: maxX - minX + 1,
};
}

function expectNotificationIconOccupancy(imagePath: string): void {
const image = PNG.sync.read(readFileSync(imagePath));
const glyph = getOpaqueBounds(imagePath);

expect(glyph.width / image.width).toBeGreaterThanOrEqual(0.75);
expect(glyph.height / image.height).toBeGreaterThanOrEqual(0.55);
}

interface ExpoConfig {
android?: {
adaptiveIcon?: {
Expand Down Expand Up @@ -45,14 +98,14 @@ describe("native application identity", () => {
) as { dependencies: Record<string, string> };

expect(manifest.dependencies).toMatchObject({
expo: "~57.0.23",
expo: "~57.0.24",
"expo-application": "~57.0.3",
"expo-constants": "~57.0.18",
"expo-constants": "~57.0.19",
"expo-dev-client": "~57.0.19",
"expo-font": "~57.0.4",
"expo-linking": "~57.0.10",
"expo-localization": "~57.0.2",
"expo-router": "~57.0.21",
"expo-router": "~57.0.22",
"expo-splash-screen": "~57.0.9",
"expo-system-ui": "~57.0.4",
});
Expand Down Expand Up @@ -85,12 +138,22 @@ describe("native application identity", () => {
smallIconAccentColor: "#187A68",
smallIcons: ["./assets/images/ic_stat_onesignal_default.png"],
});
expect(existsSync(join(process.cwd(), "assets/images/ic_stat_onesignal_default.png"))).toBe(true);
const notificationIconPath = join(
process.cwd(),
"assets/images/ic_stat_onesignal_default.png",
);

expect(existsSync(notificationIconPath)).toBe(true);
expectNotificationIconOccupancy(notificationIconPath);

["mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"].forEach((density) => {
expect(existsSync(join(
const nativeIconPath = join(
process.cwd(),
`android/app/src/main/res/drawable-${density}/ic_stat_onesignal_default.png`,
))).toBe(true);
);

expect(existsSync(nativeIconPath)).toBe(true);
expectNotificationIconOccupancy(nativeIconPath);
});
});

Expand Down
Loading