Browse Source

tests: avoid creating duplicate categories

Mokhtar Naamani 3 years ago
parent
commit
f58632ab66
1 changed files with 12 additions and 4 deletions
  1. 12 4
      tests/network-tests/src/giza/mockContentFlow.ts

+ 12 - 4
tests/network-tests/src/giza/mockContentFlow.ts

@@ -14,10 +14,18 @@ export default async function mockContent({ api }: FlowProps): Promise<void> {
   const debug = extendDebug('flow:createMockContent')
   debug('Started')
 
-  // create categories with lead
-  const createCategories = new CreateMockCategories(api)
-  debug('Creating Categories')
-  await new FixtureRunner(createCategories).run()
+  // Check to avoid creating duplicate categories
+  const nextVideoCategoryId = await api.query.content.nextVideoCategoryId()
+  const nextChannelCategoryId = await api.query.content.nextVideoCategoryId()
+
+  if (nextChannelCategoryId.toNumber() === 1 && nextVideoCategoryId.toNumber() === 1) {
+    // create categories with lead
+    const createCategories = new CreateMockCategories(api)
+    debug('Creating Categories')
+    await new FixtureRunner(createCategories).run()
+  } else {
+    debug('Skipping Category Creation')
+  }
 
   const memberAccount = api.createKeyPairs(1)[0].key.address
   const createMember: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(