Skip to content

Commit df295b5

Browse files
te6-inclaude
andcommitted
test(stories): replace external image sources with inline data URIs
External image hosts caused flaky Chromatic diffs: picsum.photos is unreliable and avatars.githubusercontent.com changes when the GitHub user updates their profile photo. Replace both with deterministic inline SVG data URIs, defined per story file. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQ6efpa1qn6RJN1mq3A1fy
1 parent af51b27 commit df295b5

8 files changed

Lines changed: 56 additions & 38 deletions

docs/stories/AttachmentDisplay.stories.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,20 @@ import { createStoryWithParameters } from "@/stories/utils/parameters";
77
import { SeedThemeDecorator } from "./components/decorator";
88
import { VariantTable } from "./components/variant-table";
99

10-
const sampleThumbnailUrl = (seed: string) => `https://picsum.photos/seed/${seed}/200/200`;
10+
const sampleThumbnailColors: Record<string, string> = {
11+
pending: "#f4a261",
12+
uploading: "#2a9d8f",
13+
success: "#8ab17d",
14+
error: "#e76f51",
15+
a: "#577590",
16+
b: "#43aa8b",
17+
c: "#f9c74f",
18+
};
19+
20+
const sampleThumbnailUrl = (seed: string) =>
21+
`data:image/svg+xml,${encodeURIComponent(
22+
`<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><rect width='200' height='200' fill='${sampleThumbnailColors[seed] ?? "#adb5bd"}'/></svg>`,
23+
)}`;
1124

1225
interface AttachmentDisplayStoryProps
1326
extends Omit<React.ComponentProps<typeof AttachmentDisplayField>, "children"> {}

docs/stories/AttachmentDisplayReorderable.stories.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,18 @@ import { createStoryWithParameters } from "@/stories/utils/parameters";
88
import { SeedThemeDecorator } from "./components/decorator";
99
import { VariantTable } from "./components/variant-table";
1010

11-
const sampleThumbnailUrl = (seed: string) => `https://picsum.photos/seed/${seed}/200/200`;
11+
const sampleThumbnailColors: Record<string, string> = {
12+
a: "#577590",
13+
b: "#43aa8b",
14+
c: "#f9c74f",
15+
d: "#9b5de5",
16+
e: "#e76f51",
17+
};
18+
19+
const sampleThumbnailUrl = (seed: string) =>
20+
`data:image/svg+xml,${encodeURIComponent(
21+
`<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><rect width='200' height='200' fill='${sampleThumbnailColors[seed] ?? "#adb5bd"}'/></svg>`,
22+
)}`;
1223

1324
interface AttachmentDisplayReorderableStoryProps
1425
extends Omit<React.ComponentProps<typeof AttachmentDisplayField>, "children"> {}

docs/stories/ImageFrame.stories.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { createStoryWithParameters } from "@/stories/utils/parameters";
77
import { SeedThemeDecorator } from "./components/decorator";
88
import { VariantTable } from "./components/variant-table";
99

10+
const SAMPLE_IMAGE = `data:image/svg+xml,${encodeURIComponent(
11+
"<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='#6ba6ff'/><stop offset='1' stop-color='#b06bff'/></linearGradient></defs><rect width='200' height='200' fill='url(#g)'/></svg>",
12+
)}`;
13+
1014
const meta = {
1115
component: ImageFrame,
1216
decorators: [SeedThemeDecorator],
@@ -32,7 +36,7 @@ const conditionMap = {
3236

3337
const CommonStoryTemplate: Story = {
3438
args: {
35-
src: "https://avatars.githubusercontent.com/u/54893898?v=4",
39+
src: SAMPLE_IMAGE,
3640
alt: "ImageFrame placeholder",
3741
},
3842
render: (args) => (

docs/stories/ListButtonItem.stories.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { IdentityPlaceholder } from "seed-design/ui/identity-placeholder";
1616
import { ActionButton } from "seed-design/ui/action-button";
1717
import { ListHeader } from "seed-design/ui/list-header";
1818

19+
const SAMPLE_IMAGE = `data:image/svg+xml,${encodeURIComponent(
20+
"<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='#6ba6ff'/><stop offset='1' stop-color='#b06bff'/></linearGradient></defs><rect width='200' height='200' fill='url(#g)'/></svg>",
21+
)}`;
22+
1923
const meta = {
2024
component: ListButtonItem,
2125
decorators: [SeedThemeDecorator],
@@ -30,13 +34,7 @@ const prefixVariants = [
3034
{ key: "icon", element: <Icon svg={<IconPersonCircleLine />} /> },
3135
{
3236
key: "avatar",
33-
element: (
34-
<Avatar
35-
size="48"
36-
src="https://avatars.githubusercontent.com/u/54893898?v=4"
37-
fallback={<IdentityPlaceholder />}
38-
/>
39-
),
37+
element: <Avatar size="48" src={SAMPLE_IMAGE} fallback={<IdentityPlaceholder />} />,
4038
},
4139
];
4240

docs/stories/ListCheckItem.stories.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { Avatar } from "seed-design/ui/avatar";
1616
import { IdentityPlaceholder } from "seed-design/ui/identity-placeholder";
1717
import { ListHeader } from "seed-design/ui/list-header";
1818

19+
const SAMPLE_IMAGE = `data:image/svg+xml,${encodeURIComponent(
20+
"<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='#6ba6ff'/><stop offset='1' stop-color='#b06bff'/></linearGradient></defs><rect width='200' height='200' fill='url(#g)'/></svg>",
21+
)}`;
22+
1923
const meta = {
2024
component: ListCheckItem,
2125
decorators: [SeedThemeDecorator],
@@ -40,13 +44,7 @@ const prefixVariants = [
4044
{ key: "icon", element: <Icon svg={<IconPersonCircleLine />} /> },
4145
{
4246
key: "avatar",
43-
element: (
44-
<Avatar
45-
size="48"
46-
src="https://avatars.githubusercontent.com/u/54893898?v=4"
47-
fallback={<IdentityPlaceholder />}
48-
/>
49-
),
47+
element: <Avatar size="48" src={SAMPLE_IMAGE} fallback={<IdentityPlaceholder />} />,
5048
},
5149
];
5250

docs/stories/ListItem.stories.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { IdentityPlaceholder } from "seed-design/ui/identity-placeholder";
1616
import { ActionButton } from "seed-design/ui/action-button";
1717
import { ListHeader } from "seed-design/ui/list-header";
1818

19+
const SAMPLE_IMAGE = `data:image/svg+xml,${encodeURIComponent(
20+
"<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='#6ba6ff'/><stop offset='1' stop-color='#b06bff'/></linearGradient></defs><rect width='200' height='200' fill='url(#g)'/></svg>",
21+
)}`;
22+
1923
const meta = {
2024
component: ListItem,
2125
decorators: [SeedThemeDecorator],
@@ -30,13 +34,7 @@ const prefixVariants = [
3034
{ key: "icon", element: <Icon svg={<IconPersonCircleLine />} /> },
3135
{
3236
key: "avatar",
33-
element: (
34-
<Avatar
35-
size="48"
36-
src="https://avatars.githubusercontent.com/u/54893898?v=4"
37-
fallback={<IdentityPlaceholder />}
38-
/>
39-
),
37+
element: <Avatar size="48" src={SAMPLE_IMAGE} fallback={<IdentityPlaceholder />} />,
4038
},
4139
];
4240

docs/stories/ListLinkItem.stories.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { IdentityPlaceholder } from "seed-design/ui/identity-placeholder";
1616
import { ActionButton } from "seed-design/ui/action-button";
1717
import { ListHeader } from "seed-design/ui/list-header";
1818

19+
const SAMPLE_IMAGE = `data:image/svg+xml,${encodeURIComponent(
20+
"<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='#6ba6ff'/><stop offset='1' stop-color='#b06bff'/></linearGradient></defs><rect width='200' height='200' fill='url(#g)'/></svg>",
21+
)}`;
22+
1923
const meta = {
2024
component: ListLinkItem,
2125
decorators: [SeedThemeDecorator],
@@ -30,13 +34,7 @@ const prefixVariants = [
3034
{ key: "icon", element: <Icon svg={<IconPersonCircleLine />} /> },
3135
{
3236
key: "avatar",
33-
element: (
34-
<Avatar
35-
size="48"
36-
src="https://avatars.githubusercontent.com/u/54893898?v=4"
37-
fallback={<IdentityPlaceholder />}
38-
/>
39-
),
37+
element: <Avatar size="48" src={SAMPLE_IMAGE} fallback={<IdentityPlaceholder />} />,
4038
},
4139
];
4240

docs/stories/ListRadioItem.stories.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { Avatar } from "seed-design/ui/avatar";
1818
import { IdentityPlaceholder } from "seed-design/ui/identity-placeholder";
1919
import { ListHeader } from "seed-design/ui/list-header";
2020

21+
const SAMPLE_IMAGE = `data:image/svg+xml,${encodeURIComponent(
22+
"<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='#6ba6ff'/><stop offset='1' stop-color='#b06bff'/></linearGradient></defs><rect width='200' height='200' fill='url(#g)'/></svg>",
23+
)}`;
24+
2125
const meta = {
2226
component: ListRadioItem,
2327
decorators: [SeedThemeDecorator],
@@ -42,13 +46,7 @@ const prefixVariants = [
4246
{ key: "icon", element: <Icon svg={<IconPersonCircleLine />} /> },
4347
{
4448
key: "avatar",
45-
element: (
46-
<Avatar
47-
size="48"
48-
src="https://avatars.githubusercontent.com/u/54893898?v=4"
49-
fallback={<IdentityPlaceholder />}
50-
/>
51-
),
49+
element: <Avatar size="48" src={SAMPLE_IMAGE} fallback={<IdentityPlaceholder />} />,
5250
},
5351
];
5452

0 commit comments

Comments
 (0)