{/* eslint-disable-next-line @next/next/no-img-element */}

{/* red duotone */}
-
+
-
-
+
+
{/* HUD */}
diff --git a/src/lib/__tests__/github-sync.test.ts b/src/lib/__tests__/github-sync.test.ts
index 68e6111..8c28627 100644
--- a/src/lib/__tests__/github-sync.test.ts
+++ b/src/lib/__tests__/github-sync.test.ts
@@ -38,3 +38,20 @@ test('preserves settings of a recreated repo and does not clean up after failed
test('invalid explicit usernames do not silently sync a different account', async () => {
await expect(resolveGitHubUsername(db, 'https://evilgithub.com/owner')).rejects.toMatchObject({ status: 400 });
});
+
+test.each([
+ ['https://storage.public.blob.vercel-storage.com/profile/photo.jpg', false],
+ ['https://example.com/my-photo.png', false],
+ ['https://avatars.githubusercontent.com/u/123?v=4', true],
+ ['', true],
+])('profile sync preserves custom photo %s', async (avatarUrl, shouldUpdate) => {
+ const personalData = {
+ findFirst: jest.fn().mockResolvedValue({ id: 'profile', avatarUrl, location: 'Kolkata', github: 'https://github.com/Owner', bio: 'Bio' }),
+ update: jest.fn(),
+ };
+ api.getUser.mockResolvedValue({ login: 'Owner', avatar_url: 'https://avatars.githubusercontent.com/u/456?v=4' });
+ repos.findMany.mockResolvedValue([]);
+ await syncGitHub({ ...db, personalData } as unknown as PrismaClient, { username: 'Owner' });
+ if (shouldUpdate) expect(personalData.update).toHaveBeenCalledWith(expect.objectContaining({ data: { avatarUrl: 'https://avatars.githubusercontent.com/u/456?v=4' } }));
+ else expect(personalData.update).not.toHaveBeenCalled();
+});
diff --git a/src/lib/__tests__/profile-photo.test.ts b/src/lib/__tests__/profile-photo.test.ts
new file mode 100644
index 0000000..94040da
--- /dev/null
+++ b/src/lib/__tests__/profile-photo.test.ts
@@ -0,0 +1,14 @@
+/** @jest-environment node */
+import { photoFormat } from '../profile-photo';
+
+test('identifies supported photo bytes independently of MIME and extension', () => {
+ expect(photoFormat(new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 0]))?.extension).toBe('png');
+ expect(photoFormat(new Uint8Array([255, 216, 255, 224, 0, 0, 0, 0, 0, 0, 0, 0]))?.extension).toBe('jpg');
+ expect(photoFormat(new TextEncoder().encode('RIFF0000WEBP0000'))?.extension).toBe('webp');
+});
+
+test('rejects SVG, HTML, PDFs and truncated uploads', () => {
+ for (const value of ['