Skip to content

Commit 06ca3b9

Browse files
committed
avoid duplicate keys in JobList stories
The JobList Storybook warnings came from `buildList(10)` over a factory configuration that reused a single prebuilt running job template, including its ID. That generated duplicate React keys in the list. Build running jobs one at a time so each entry gets a distinct factory instance and unique `id`, eliminating duplicate-key warnings in story execution.
1 parent 0625907 commit 06ca3b9

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/components/JobList.stories.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ export default meta;
1515

1616
type Story = StoryObj<typeof JobList>;
1717

18+
const buildRunningJobs = (count: number) =>
19+
Array.from({ length: count }, () => jobMinimalFactory.running().build());
20+
1821
// Default running jobs story
1922
export const Running: Story = {
2023
args: {
21-
jobs: jobMinimalFactory.running().buildList(10),
24+
jobs: buildRunningJobs(10),
2225
setJobRefetchesPaused: () => {},
2326
state: JobState.Running,
2427
},
@@ -34,7 +37,7 @@ export const Running: Story = {
3437
export const ArgsHiddenByDefault: Story = {
3538
args: {
3639
...Running.args,
37-
jobs: jobMinimalFactory.running().buildList(10),
40+
jobs: buildRunningJobs(10),
3841
},
3942
parameters: {
4043
features: createFeatures({
@@ -48,7 +51,7 @@ export const ArgsHiddenByDefault: Story = {
4851
export const ArgsVisibleUserOverride: Story = {
4952
args: {
5053
...Running.args,
51-
jobs: jobMinimalFactory.running().buildList(10),
54+
jobs: buildRunningJobs(10),
5255
},
5356
parameters: {
5457
features: createFeatures({
@@ -62,7 +65,7 @@ export const ArgsVisibleUserOverride: Story = {
6265
export const ArgsHiddenUserOverride: Story = {
6366
args: {
6467
...Running.args,
65-
jobs: jobMinimalFactory.running().buildList(10),
68+
jobs: buildRunningJobs(10),
6669
},
6770
parameters: {
6871
features: createFeatures({

0 commit comments

Comments
 (0)