File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
extensions/ql-vscode/src/stories/variant-analysis Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change 11import type { Meta , StoryFn } from "@storybook/react" ;
22
33import { faker } from "@faker-js/faker" ;
4+ import { customAlphabet } from "nanoid" ;
45
56import { VariantAnalysisContainer } from "../../view/variant-analysis/VariantAnalysisContainer" ;
67import { VariantAnalysisAnalyzedRepos } from "../../view/variant-analysis/VariantAnalysisAnalyzedRepos" ;
@@ -125,22 +126,19 @@ Example.args = {
125126} ;
126127
127128faker . seed ( 42 ) ;
128- const uniqueNumbers = [ ...Array ( 1000 ) . keys ( ) ] . sort ( ( ) => Math . random ( ) - 0.5 ) ;
129129
130130const 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} ) ;
You can’t perform that action at this time.
0 commit comments