Browse Source

Query node & cont dir integration: dont cache data in apollo client & rest test coverage adjustments

root 4 years ago
parent
commit
053eabb817

+ 22 - 29
tests/network-tests/src/Api.ts

@@ -323,9 +323,9 @@ export class Api {
 
   public estimateAcceptApplicationsFee(module: WorkingGroups): BN {
     return this.estimateTxFee(
-      (this.api.tx[module].acceptApplications(
-        this.api.createType('OpeningId', 0)
-      ) as unknown) as SubmittableExtrinsic<'promise'>
+      (this.api.tx[module].acceptApplications(this.api.createType('OpeningId', 0)) as unknown) as SubmittableExtrinsic<
+        'promise'
+      >
     )
   }
 
@@ -362,19 +362,17 @@ export class Api {
 
   public estimateIncreaseStakeFee(module: WorkingGroups): BN {
     return this.estimateTxFee(
-      (this.api.tx[module].increaseStake(
-        this.api.createType('WorkerId', 0),
-        0
-      ) as unknown) as SubmittableExtrinsic<'promise'>
+      (this.api.tx[module].increaseStake(this.api.createType('WorkerId', 0), 0) as unknown) as SubmittableExtrinsic<
+        'promise'
+      >
     )
   }
 
   public estimateDecreaseStakeFee(module: WorkingGroups): BN {
     return this.estimateTxFee(
-      (this.api.tx[module].decreaseStake(
-        this.api.createType('WorkerId', 0),
-        0
-      ) as unknown) as SubmittableExtrinsic<'promise'>
+      (this.api.tx[module].decreaseStake(this.api.createType('WorkerId', 0), 0) as unknown) as SubmittableExtrinsic<
+        'promise'
+      >
     )
   }
 
@@ -423,10 +421,9 @@ export class Api {
 
   public estimateSlashStakeFee(module: WorkingGroups): BN {
     return this.estimateTxFee(
-      (this.api.tx[module].slashStake(
-        this.api.createType('WorkerId', 0),
-        0
-      ) as unknown) as SubmittableExtrinsic<'promise'>
+      (this.api.tx[module].slashStake(this.api.createType('WorkerId', 0), 0) as unknown) as SubmittableExtrinsic<
+        'promise'
+      >
     )
   }
 
@@ -1481,12 +1478,9 @@ export class Api {
     type: string,
     module: WorkingGroups
   ): SubmittableExtrinsic<'promise'> {
-    return (this.api.tx[module].addOpening(
-      actiavteAt,
-      commitment,
-      text,
-      type
-    ) as unknown) as SubmittableExtrinsic<'promise'>
+    return (this.api.tx[module].addOpening(actiavteAt, commitment, text, type) as unknown) as SubmittableExtrinsic<
+      'promise'
+    >
   }
 
   public async acceptApplications(
@@ -1660,10 +1654,9 @@ export class Api {
     module: WorkingGroups
   ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
-      (this.api.tx[module].updateRewardAccount(
-        workerId,
-        newRewardAccount
-      ) as unknown) as SubmittableExtrinsic<'promise'>,
+      (this.api.tx[module].updateRewardAccount(workerId, newRewardAccount) as unknown) as SubmittableExtrinsic<
+        'promise'
+      >,
       worker,
       false
     )
@@ -1839,9 +1832,9 @@ export class Api {
   }
 
   public async getApplicationsIdsByRoleAccount(address: string, module: WorkingGroups): Promise<ApplicationId[]> {
-    const applicationsAndIds: [StorageKey, Application][] = await this.api.query[
-      module
-    ].applicationById.entries<Application>()
+    const applicationsAndIds: [StorageKey, Application][] = await this.api.query[module].applicationById.entries<
+      Application
+    >()
     return applicationsAndIds
       .map((applicationWithId) => {
         const application: Application = applicationWithId[1]
@@ -2090,7 +2083,7 @@ export class QueryNodeApi extends Api {
         search(text: $text) {
           item {
             ... on Video {
-              handle
+              title
               description
               duration
               thumbnailUrl

+ 3 - 3
tests/network-tests/src/flows/contentDirectory/creatingVideo.ts

@@ -58,8 +58,8 @@ export default async function createVideo(api: QueryNodeApi) {
 
   await createVideoHappyCaseFixture.runner(false)
 
-  // Temporary solution (wait 3 minutes)
-  await Utils.wait(180000)
+  // Temporary solution (wait 2 minutes)
+  await Utils.wait(120000)
 
   // Perform number of full text searches on Channel title, that is a slight variation on title that one expects would return the video.
   let channelFullTextSearchResult = await api.performFullTextSearchOnChannelTitle('video')
@@ -96,7 +96,7 @@ export default async function createVideo(api: QueryNodeApi) {
 
   videoFullTextSearchResult = await api.performFullTextSearchOnVideoTitle('Example video')
 
-  assert(videoFullTextSearchResult.data.titles.length === 1, 'Should contain exactly one video')
+  assert(videoFullTextSearchResult.data.search.length === 1, 'Should contain exactly one video')
 
   // Perform number full text searches on Video title, that absolutely should NOT return the video.
   videoFullTextSearchResult = await api.performFullTextSearchOnVideoTitle('unknown')

+ 17 - 9
tests/network-tests/src/flows/contentDirectory/updatingChannel.ts

@@ -4,10 +4,14 @@ import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntit
 import { assert } from 'chai'
 import { Utils } from '../../utils'
 
-export function createUpdateChannelHandleFixture(api: QueryNodeApi, handle: string): UpdateChannelFixture {
+export function createUpdateChannelHandleFixture(
+  api: QueryNodeApi,
+  handle: string,
+  description: string
+): UpdateChannelFixture {
   // Create partial channel entity, only containing the fields we wish to update
   const channelUpdateInput: Partial<ChannelEntity> = {
-    handle,
+    description,
   }
 
   const uniquePropVal: Record<string, any> = { handle }
@@ -16,11 +20,12 @@ export function createUpdateChannelHandleFixture(api: QueryNodeApi, handle: stri
 }
 
 export default async function updateChannel(api: QueryNodeApi) {
-  const channelResult = await api.getChannelbyHandle('New channel example')
+  const handle = 'New channel example'
+  const channelResult = await api.getChannelbyHandle(handle)
   const channel = channelResult.data.channels[0]
 
-  const handle = 'Updated handle'
-  const createUpdateChannelDescriptionHappyCaseFixture = createUpdateChannelHandleFixture(api, handle)
+  const description = 'Updated description'
+  const createUpdateChannelDescriptionHappyCaseFixture = createUpdateChannelHandleFixture(api, handle, description)
 
   await createUpdateChannelDescriptionHappyCaseFixture.runner(false)
 
@@ -30,10 +35,13 @@ export default async function updateChannel(api: QueryNodeApi) {
   const channelAfterUpdateResult = await api.getChannelbyHandle(handle)
   const channelAfterUpdate = channelAfterUpdateResult.data.channels[0]
 
-  // handle field should be updated to provided one
-  assert(channelAfterUpdate.handle === handle)
-  assert(channelAfterUpdate.description === channel.description, 'Should be equal')
+  console.log(channelAfterUpdate.description)
+
+  // description field should be updated to provided one
+  assert(channelAfterUpdate.description === description, 'Should be equal')
+
+  assert(channelAfterUpdate.handle === channel.handle, 'Should be equal')
   assert(channelAfterUpdate.coverPhotoUrl === channel.coverPhotoUrl, 'Should be equal')
-  assert(channelAfterUpdate.avatarPhotoUrl === channel.avatarPhotoURL, 'Should be equal')
+  assert(channelAfterUpdate.avatarPhotoUrl === channel.avatarPhotoUrl, 'Should be equal')
   assert(channelAfterUpdate.isPublic === channel.isPublic, 'Should be equal')
 }

+ 2 - 1
tests/network-tests/src/scenarios/content-directory.ts

@@ -22,6 +22,7 @@ const scenario = async () => {
   const queryNodeProvider = new ApolloClient({
     uri: queryNodeUrl,
     cache: new InMemoryCache(),
+    defaultOptions: { query: { fetchPolicy: 'no-cache', errorPolicy: 'all' } },
   })
 
   const api: QueryNodeApi = await QueryNodeApi.new(
@@ -42,7 +43,7 @@ const scenario = async () => {
 
   await createVideo(api)
 
-  // await updateChannel(api)
+  await updateChannel(api)
 
   // Note: disconnecting and then reconnecting to the chain in the same process
   // doesn't seem to work!