From 4d9c684258962d35c21a9f006147819336b01b2e Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Sat, 6 Jun 2026 03:15:06 +0000
Subject: [PATCH 1/4] refactor: extract magic number 110 into MAX_BIO_LENGTH
constant
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
---
src/lib/cardElements.tsx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/lib/cardElements.tsx b/src/lib/cardElements.tsx
index 0e0b73cd..5a06d9e7 100644
--- a/src/lib/cardElements.tsx
+++ b/src/lib/cardElements.tsx
@@ -7,6 +7,8 @@ import type {
} from "./cardOptions";
import { resolveBlockLayout } from "./cardOptions";
+const MAX_BIO_LENGTH = 110;
+
export type ThemePalette = {
bg: string;
panel: string;
@@ -98,8 +100,8 @@ function createBioBlock(data: CardData, theme: ThemePalette): ReactElement {
{data.profile.bio ? (
- {data.profile.bio.length > 110
- ? `${data.profile.bio.slice(0, 110)}...`
+ {data.profile.bio.length > MAX_BIO_LENGTH
+ ? `${data.profile.bio.slice(0, MAX_BIO_LENGTH)}...`
: data.profile.bio}
) : null}
From ceb4e52dd30a823f5a5b266889d21d03a9a3fe5a Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Sat, 6 Jun 2026 03:24:49 +0000
Subject: [PATCH 2/4] refactor: extract magic number 110 into MAX_BIO_LENGTH
constant
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
---
src/lib/__tests__/cardElements.test.tsx | 45 ++++++++++++++++++++++++-
src/lib/cardElements.tsx | 2 +-
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/src/lib/__tests__/cardElements.test.tsx b/src/lib/__tests__/cardElements.test.tsx
index 51ae4165..07c327dc 100644
--- a/src/lib/__tests__/cardElements.test.tsx
+++ b/src/lib/__tests__/cardElements.test.tsx
@@ -1,5 +1,7 @@
+import React from "react";
import { describe, it, expect } from "vitest";
-import { estimateHeight, levelColor } from "../cardElements";
+import { estimateHeight, levelColor, createBlock, MAX_BIO_LENGTH } from "../cardElements";
+import type { CardData } from "../cardDataFetcher";
import type { CardRenderOptions } from "../cardOptions";
describe("cardElements utility functions", () => {
@@ -107,4 +109,45 @@ describe("cardElements utility functions", () => {
expect(levelColor(15, 10, mockTheme)).toBe("#15803d"); // > 1
});
});
+
+ describe("createBlock - bio", () => {
+ const mockTheme = {
+ bg: "#fff",
+ panel: "#f8f9fa",
+ text: "#000",
+ subtext: "#666",
+ border: "#ccc",
+ success: "#0f0",
+ accent: "#3b82f6",
+ };
+
+ const mockData = {
+ profile: {
+ avatarUrl: "https://example.com/avatar.png",
+ name: "Test User",
+ login: "testuser",
+ bio: "",
+ }
+ } as unknown as CardData;
+
+ it("truncates bio if it exceeds MAX_BIO_LENGTH", () => {
+ const longBio = "A".repeat(MAX_BIO_LENGTH + 10);
+ mockData.profile.bio = longBio;
+
+ const element = createBlock("bio", mockData, mockTheme, new Set()) as React.ReactElement;
+ const bioDiv = element.props.children[1].props.children[2];
+ const renderedText = bioDiv.props.children;
+ expect(renderedText).toBe("A".repeat(MAX_BIO_LENGTH) + "...");
+ });
+
+ it("does not truncate bio if it is within MAX_BIO_LENGTH", () => {
+ const shortBio = "A".repeat(MAX_BIO_LENGTH);
+ mockData.profile.bio = shortBio;
+
+ const element = createBlock("bio", mockData, mockTheme, new Set()) as React.ReactElement;
+ const bioDiv = element.props.children[1].props.children[2];
+ const renderedText = bioDiv.props.children;
+ expect(renderedText).toBe(shortBio);
+ });
+ });
});
diff --git a/src/lib/cardElements.tsx b/src/lib/cardElements.tsx
index 5a06d9e7..5bcf4b54 100644
--- a/src/lib/cardElements.tsx
+++ b/src/lib/cardElements.tsx
@@ -7,7 +7,7 @@ import type {
} from "./cardOptions";
import { resolveBlockLayout } from "./cardOptions";
-const MAX_BIO_LENGTH = 110;
+export const MAX_BIO_LENGTH = 110;
export type ThemePalette = {
bg: string;
From a9de1e226719045662a7bb962d58688b82a712f8 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Sat, 6 Jun 2026 03:29:13 +0000
Subject: [PATCH 3/4] refactor: extract magic number 110 into MAX_BIO_LENGTH
constant
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
---
src/lib/__tests__/cardElements.test.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lib/__tests__/cardElements.test.tsx b/src/lib/__tests__/cardElements.test.tsx
index 07c327dc..e42c57ea 100644
--- a/src/lib/__tests__/cardElements.test.tsx
+++ b/src/lib/__tests__/cardElements.test.tsx
@@ -135,7 +135,7 @@ describe("cardElements utility functions", () => {
mockData.profile.bio = longBio;
const element = createBlock("bio", mockData, mockTheme, new Set()) as React.ReactElement;
- const bioDiv = element.props.children[1].props.children[2];
+ const bioDiv = (element as React.ReactElement).props.children[1].props.children[2];
const renderedText = bioDiv.props.children;
expect(renderedText).toBe("A".repeat(MAX_BIO_LENGTH) + "...");
});
@@ -145,7 +145,7 @@ describe("cardElements utility functions", () => {
mockData.profile.bio = shortBio;
const element = createBlock("bio", mockData, mockTheme, new Set()) as React.ReactElement;
- const bioDiv = element.props.children[1].props.children[2];
+ const bioDiv = (element as React.ReactElement).props.children[1].props.children[2];
const renderedText = bioDiv.props.children;
expect(renderedText).toBe(shortBio);
});
From 0c82c4ef1d3a71185b3073be406471d0a6b126bb Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Sat, 6 Jun 2026 03:35:55 +0000
Subject: [PATCH 4/4] refactor: extract magic number 110 into MAX_BIO_LENGTH
constant
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
---
src/lib/__tests__/cardElements.test.tsx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/lib/__tests__/cardElements.test.tsx b/src/lib/__tests__/cardElements.test.tsx
index e42c57ea..6e159c2c 100644
--- a/src/lib/__tests__/cardElements.test.tsx
+++ b/src/lib/__tests__/cardElements.test.tsx
@@ -135,7 +135,8 @@ describe("cardElements utility functions", () => {
mockData.profile.bio = longBio;
const element = createBlock("bio", mockData, mockTheme, new Set()) as React.ReactElement;
- const bioDiv = (element as React.ReactElement).props.children[1].props.children[2];
+ // @ts-expect-error - inline bypass for complex React tree props
+ const bioDiv = (element as React.ReactElement).props.children[1].props.children[2];
const renderedText = bioDiv.props.children;
expect(renderedText).toBe("A".repeat(MAX_BIO_LENGTH) + "...");
});
@@ -145,7 +146,8 @@ describe("cardElements utility functions", () => {
mockData.profile.bio = shortBio;
const element = createBlock("bio", mockData, mockTheme, new Set()) as React.ReactElement;
- const bioDiv = (element as React.ReactElement).props.children[1].props.children[2];
+ // @ts-expect-error - inline bypass for complex React tree props
+ const bioDiv = (element as React.ReactElement).props.children[1].props.children[2];
const renderedText = bioDiv.props.children;
expect(renderedText).toBe(shortBio);
});