Skip to content

Commit 70461d8

Browse files
committed
Use nanoid
1 parent 12a3af0 commit 70461d8

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

extensions/ql-vscode/src/stories/variant-analysis/VariantAnalysisAnalyzedRepos.stories.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Meta, StoryFn } from "@storybook/react";
22

33
import { faker } from "@faker-js/faker";
4+
import { customAlphabet } from "nanoid";
45

56
import { VariantAnalysisContainer } from "../../view/variant-analysis/VariantAnalysisContainer";
67
import { VariantAnalysisAnalyzedRepos } from "../../view/variant-analysis/VariantAnalysisAnalyzedRepos";
@@ -125,22 +126,19 @@ Example.args = {
125126
};
126127

127128
faker.seed(42);
128-
const uniqueNumbers = [...Array(1000).keys()].sort(() => Math.random() - 0.5);
129129

130130
const manyScannedRepos = Array.from({ length: 1000 }, (_, i) => {
131131
const mockedScannedRepo = createMockScannedRepo();
132-
const randomInt = uniqueNumbers.pop();
133-
const uniqueId =
134-
randomInt === undefined ? Math.random() * 8000 + 1001 : randomInt;
135-
132+
const nanoid = customAlphabet("0123456789");
136133
return {
137134
...mockedScannedRepo,
138135
analysisStatus: VariantAnalysisRepoStatus.Succeeded,
139136
resultCount: faker.number.int({ min: 0, max: 1000 }),
140137
repository: {
141138
...mockedScannedRepo.repository,
142-
id: uniqueId,
143-
fullName: `octodemo/${uniqueId}`,
139+
// We need to ensure the ID is unique for React keys
140+
id: parseInt(nanoid()),
141+
fullName: `octodemo/${nanoid()}`,
144142
},
145143
};
146144
});

0 commit comments

Comments
 (0)