1- import { v4 as uuidv4 } from 'uuid' ;
21import dbInit , {
32 type ITestDb ,
43} from '../../../test/e2e/helpers/database-init.js' ;
@@ -13,7 +12,7 @@ import {
1312 FEATURE_DEPENDENCY_ADDED ,
1413 FEATURE_DEPENDENCY_REMOVED ,
1514} from '../../events/index.js' ;
16- import { DEFAULT_ENV } from '../../util/index.js' ;
15+ import { DEFAULT_ENV , randomId } from '../../util/index.js' ;
1716import type { IEventStore } from '../../server-impl.js' ;
1817
1918let app : IUnleashTest ;
@@ -169,9 +168,9 @@ const checkDependenciesExist = async (expectedCode = 200) => {
169168} ;
170169
171170test ( 'should add and delete feature dependencies' , async ( ) => {
172- const parent = uuidv4 ( ) ;
173- const child = uuidv4 ( ) ;
174- const child2 = uuidv4 ( ) ;
171+ const parent = randomId ( ) ;
172+ const child = randomId ( ) ;
173+ const child2 = randomId ( ) ;
175174 await app . createFeature ( parent ) ;
176175 await app . createFeature ( child ) ;
177176 await app . createFeature ( child2 ) ;
@@ -209,10 +208,10 @@ test('should add and delete feature dependencies', async () => {
209208} ) ;
210209
211210test ( 'should sort potential parent features alphabetically' , async ( ) => {
212- const parent1 = `a${ uuidv4 ( ) } ` ;
213- const parent2 = `c${ uuidv4 ( ) } ` ;
214- const parent3 = `b${ uuidv4 ( ) } ` ;
215- const child = uuidv4 ( ) ;
211+ const parent1 = `a${ randomId ( ) } ` ;
212+ const parent2 = `c${ randomId ( ) } ` ;
213+ const parent3 = `b${ randomId ( ) } ` ;
214+ const child = randomId ( ) ;
216215 await app . createFeature ( parent1 ) ;
217216 await app . createFeature ( parent2 ) ;
218217 await app . createFeature ( parent3 ) ;
@@ -223,7 +222,7 @@ test('should sort potential parent features alphabetically', async () => {
223222} ) ;
224223
225224test ( 'should sort potential parent variants' , async ( ) => {
226- const parent = uuidv4 ( ) ;
225+ const parent = randomId ( ) ;
227226 await app . createFeature ( parent ) ;
228227 await addFeatureEnvironmentVariant ( parent , 'e' ) ;
229228 await addStrategyVariants ( parent , [ 'c' , 'a' , 'd' ] ) ;
@@ -235,9 +234,9 @@ test('should sort potential parent variants', async () => {
235234} ) ;
236235
237236test ( 'should not allow to add grandparent' , async ( ) => {
238- const grandparent = uuidv4 ( ) ;
239- const parent = uuidv4 ( ) ;
240- const child = uuidv4 ( ) ;
237+ const grandparent = randomId ( ) ;
238+ const parent = randomId ( ) ;
239+ const child = randomId ( ) ;
241240 await app . createFeature ( grandparent ) ;
242241 await app . createFeature ( parent ) ;
243242 await app . createFeature ( child ) ;
@@ -255,9 +254,9 @@ test('should not allow to add grandparent', async () => {
255254} ) ;
256255
257256test ( 'should not allow to add grandchild' , async ( ) => {
258- const grandparent = uuidv4 ( ) ;
259- const parent = uuidv4 ( ) ;
260- const child = uuidv4 ( ) ;
257+ const grandparent = randomId ( ) ;
258+ const parent = randomId ( ) ;
259+ const child = randomId ( ) ;
261260 await app . createFeature ( grandparent ) ;
262261 await app . createFeature ( parent ) ;
263262 await app . createFeature ( child ) ;
@@ -276,8 +275,8 @@ test('should not allow to add grandchild', async () => {
276275} ) ;
277276
278277test ( 'should not allow to add non-existent parent dependency' , async ( ) => {
279- const parent = uuidv4 ( ) ;
280- const child = uuidv4 ( ) ;
278+ const parent = randomId ( ) ;
279+ const child = randomId ( ) ;
281280 await app . createFeature ( child ) ;
282281
283282 await addFeatureDependency (
@@ -290,8 +289,8 @@ test('should not allow to add non-existent parent dependency', async () => {
290289} ) ;
291290
292291test ( 'should not allow to add archived parent dependency' , async ( ) => {
293- const parent = uuidv4 ( ) ;
294- const child = uuidv4 ( ) ;
292+ const parent = randomId ( ) ;
293+ const child = randomId ( ) ;
295294 await app . createFeature ( child ) ;
296295 await app . createFeature ( parent ) ;
297296 await app . archiveFeature ( parent ) ;
@@ -306,8 +305,8 @@ test('should not allow to add archived parent dependency', async () => {
306305} ) ;
307306
308307test ( 'should check if any dependencies exist' , async ( ) => {
309- const parent = uuidv4 ( ) ;
310- const child = uuidv4 ( ) ;
308+ const parent = randomId ( ) ;
309+ const child = randomId ( ) ;
311310 await app . createFeature ( child ) ;
312311 await app . createFeature ( parent ) ;
313312
@@ -323,7 +322,7 @@ test('should check if any dependencies exist', async () => {
323322} ) ;
324323
325324test ( 'should not allow to add dependency to self' , async ( ) => {
326- const parent = uuidv4 ( ) ;
325+ const parent = randomId ( ) ;
327326 await app . createFeature ( parent ) ;
328327
329328 await addFeatureDependency (
@@ -336,8 +335,8 @@ test('should not allow to add dependency to self', async () => {
336335} ) ;
337336
338337test ( 'should not allow to add dependency to feature from another project' , async ( ) => {
339- const child = uuidv4 ( ) ;
340- const parent = uuidv4 ( ) ;
338+ const child = randomId ( ) ;
339+ const parent = randomId ( ) ;
341340 await app . createFeature ( parent ) ;
342341 await createProject ( 'another-project' ) ;
343342 await app . createFeature ( child , 'another-project' ) ;
@@ -351,8 +350,8 @@ test('should not allow to add dependency to feature from another project', async
351350 ) ;
352351} ) ;
353352test ( 'should create feature-dependency-removed when archiving and has dependency' , async ( ) => {
354- const child = uuidv4 ( ) ;
355- const parent = uuidv4 ( ) ;
353+ const child = randomId ( ) ;
354+ const parent = randomId ( ) ;
356355 await app . createFeature ( parent ) ;
357356 await app . createFeature ( child ) ;
358357
@@ -369,8 +368,8 @@ test('should create feature-dependency-removed when archiving and has dependency
369368} ) ;
370369
371370test ( 'should not create feature-dependency-removed when archiving and no dependency' , async ( ) => {
372- const child = uuidv4 ( ) ;
373- const parent = uuidv4 ( ) ;
371+ const child = randomId ( ) ;
372+ const parent = randomId ( ) ;
374373 await app . createFeature ( parent ) ;
375374 await app . createFeature ( child ) ;
376375
0 commit comments