Browse Source

integration tests: remove old content directory tests

Mokhtar Naamani 4 years ago
parent
commit
58b60c8508

+ 0 - 65
tests/network-tests/src/Api.ts

@@ -30,10 +30,6 @@ import {
 } from '@joystream/types/hiring'
 import { FillOpeningParameters, ProposalId } from '@joystream/types/proposals'
 import { v4 as uuid } from 'uuid'
-import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
-import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
-import { InputParser } from '@joystream/cd-schemas'
-import { OperationType } from '@joystream/types/content-directory'
 import { ContentId, DataObject } from '@joystream/types/storage'
 import Debugger from 'debug'
 
@@ -1729,67 +1725,6 @@ export class Api {
     return this.api.createType('u32', this.api.consts[module].maxWorkerNumberLimit)
   }
 
-  async sendContentDirectoryTransaction(operations: OperationType[]): Promise<ISubmittableResult> {
-    const transaction = this.api.tx.contentDirectory.transaction(
-      { Lead: null }, // We use member with id 0 as actor (in this case we assume this is Alice)
-      operations // We provide parsed operations as second argument
-    )
-    const lead = (await this.getGroupLead(WorkingGroups.ContentDirectoryWorkingGroup)) as Worker
-    return this.sender.signAndSend(transaction, lead.role_account_id)
-  }
-
-  public async createChannelEntity(channel: ChannelEntity): Promise<ISubmittableResult> {
-    // Create the parser with known entity schemas (the ones in content-directory-schemas/inputs)
-    const parser = InputParser.createWithKnownSchemas(
-      this.api,
-      // The second argument is an array of entity batches, following standard entity batch syntax ({ className, entries }):
-      [
-        {
-          className: 'Channel',
-          entries: [channel], // We could specify multiple entries here, but in this case we only need one
-        },
-      ]
-    )
-    // We parse the input into CreateEntity and AddSchemaSupportToEntity operations
-    const operations = await parser.getEntityBatchOperations()
-    return this.sendContentDirectoryTransaction(operations)
-  }
-
-  public async createVideoEntity(video: VideoEntity): Promise<ISubmittableResult> {
-    // Create the parser with known entity schemas (the ones in content-directory-schemas/inputs)
-    const parser = InputParser.createWithKnownSchemas(
-      this.api,
-      // The second argument is an array of entity batches, following standard entity batch syntax ({ className, entries }):
-      [
-        {
-          className: 'Video',
-          entries: [video], // We could specify multiple entries here, but in this case we only need one
-        },
-      ]
-    )
-    // We parse the input into CreateEntity and AddSchemaSupportToEntity operations
-    const operations = await parser.getEntityBatchOperations()
-    return this.sendContentDirectoryTransaction(operations)
-  }
-
-  public async updateChannelEntity(
-    channelUpdateInput: Record<string, any>,
-    uniquePropValue: Record<string, any>
-  ): Promise<ISubmittableResult> {
-    // Create the parser with known entity schemas (the ones in content-directory-schemas/inputs)
-    const parser = InputParser.createWithKnownSchemas(this.api)
-
-    // We can reuse InputParser's `findEntityIdByUniqueQuery` method to find entityId of the channel we
-    // created in ./createChannel.ts example (normally we would probably use some other way to do it, ie.: query node)
-    const CHANNEL_ID = await parser.findEntityIdByUniqueQuery(uniquePropValue, 'Channel') // Use getEntityUpdateOperations to parse the update input
-    const updateOperations = await parser.getEntityUpdateOperations(
-      channelUpdateInput,
-      'Channel', // Class name
-      CHANNEL_ID // Id of the entity we want to update
-    )
-    return this.sendContentDirectoryTransaction(updateOperations)
-  }
-
   async getDataByContentId(contentId: ContentId): Promise<DataObject | null> {
     const dataObject = await this.api.query.dataDirectory.dataByContentId<Option<DataObject>>(contentId)
     return dataObject.unwrapOr(null)

+ 0 - 51
tests/network-tests/src/fixtures/contentDirectoryModule.ts

@@ -1,51 +0,0 @@
-import { Api } from '../Api'
-import { BaseFixture } from '../Fixture'
-import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
-import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
-
-export class CreateChannelFixture extends BaseFixture {
-  public channelEntity: ChannelEntity
-
-  public constructor(api: Api, channelEntity: ChannelEntity) {
-    super(api)
-    this.channelEntity = channelEntity
-  }
-
-  public async execute(): Promise<void> {
-    this.expectDispatchSuccess(
-      await this.api.createChannelEntity(this.channelEntity),
-      'Create Channel should have succeeded'
-    )
-  }
-}
-
-export class CreateVideoFixture extends BaseFixture {
-  public videoEntity: VideoEntity
-
-  public constructor(api: Api, videoEntity: VideoEntity) {
-    super(api)
-    this.videoEntity = videoEntity
-  }
-
-  public async execute(): Promise<void> {
-    this.expectDispatchSuccess(await this.api.createVideoEntity(this.videoEntity), 'Create Video should have succeeded')
-  }
-}
-
-export class UpdateChannelFixture extends BaseFixture {
-  private channelUpdateInput: Record<string, any>
-  private uniquePropValue: Record<string, any>
-
-  public constructor(api: Api, channelUpdateInput: Record<string, any>, uniquePropValue: Record<string, any>) {
-    super(api)
-    this.channelUpdateInput = channelUpdateInput
-    this.uniquePropValue = uniquePropValue
-  }
-
-  public async execute(): Promise<void> {
-    this.expectDispatchSuccess(
-      await this.api.updateChannelEntity(this.channelUpdateInput, this.uniquePropValue),
-      'Update Channel should have succeeded'
-    )
-  }
-}

+ 0 - 50
tests/network-tests/src/flows/contentDirectory/creatingChannel.ts

@@ -1,50 +0,0 @@
-import { Api } from '../../Api'
-import { FlowProps } from '../../Flow'
-import { Utils } from '../../utils'
-import { CreateChannelFixture } from '../../fixtures/contentDirectoryModule'
-import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
-import { assert } from 'chai'
-import { FixtureRunner } from '../../Fixture'
-import Debugger from 'debug'
-
-export function createSimpleChannelFixture(api: Api): CreateChannelFixture {
-  const channelEntity: ChannelEntity = {
-    handle: 'New channel example',
-    description: 'This is an example channel',
-    // We can use "existing" syntax to reference either an on-chain entity or other entity that's part of the same batch.
-    // Here we reference language that we assume was added by initialization script (initialize:dev), as it is part of
-    // input/entityBatches/LanguageBatch.json
-    language: { existing: { code: 'EN' } },
-    coverPhotoUrl: '',
-    avatarPhotoUrl: '',
-    isPublic: true,
-  }
-  return new CreateChannelFixture(api, channelEntity)
-}
-
-function assertChannelMatchQueriedResult(queriedChannel: any, channel: ChannelEntity) {
-  assert.equal(queriedChannel.handle, channel.handle, 'Should be equal')
-  assert.equal(queriedChannel.description, channel.description, 'Should be equal')
-  assert.equal(queriedChannel.coverPhotoUrl, channel.coverPhotoUrl, 'Should be equal')
-  assert.equal(queriedChannel.avatarPhotoUrl, channel.avatarPhotoUrl, 'Should be equal')
-  assert.equal(queriedChannel.isPublic, channel.isPublic, 'Should be equal')
-}
-
-export default async function channelCreation({ api, query }: FlowProps): Promise<void> {
-  const debug = Debugger('flow:creatingChannel')
-  debug('Started')
-
-  const createChannelHappyCaseFixture = createSimpleChannelFixture(api)
-
-  await new FixtureRunner(createChannelHappyCaseFixture).run()
-
-  // Temporary solution (wait 2 minutes)
-  await Utils.wait(120000)
-
-  // Ensure newly created channel was parsed by query node
-  const result = await query.getChannelbyHandle(createChannelHappyCaseFixture.channelEntity.handle)
-
-  assertChannelMatchQueriedResult(result.data.channels[0], createChannelHappyCaseFixture.channelEntity)
-
-  debug('Done')
-}

+ 0 - 115
tests/network-tests/src/flows/contentDirectory/creatingVideo.ts

@@ -1,115 +0,0 @@
-import { Api } from '../../Api'
-import { FlowProps } from '../../Flow'
-import { CreateVideoFixture } from '../../fixtures/contentDirectoryModule'
-import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
-import { assert } from 'chai'
-import { Utils } from '../../utils'
-import { FixtureRunner } from '../../Fixture'
-import Debugger from 'debug'
-
-export function createVideoReferencingChannelFixture(api: Api, handle: string): CreateVideoFixture {
-  const videoEntity: VideoEntity = {
-    title: 'Example video',
-    description: 'This is an example video',
-    // We reference existing language and category by their unique properties with "existing" syntax
-    // (those referenced here are part of inputs/entityBatches)
-    language: { existing: { code: 'EN' } },
-    category: { existing: { name: 'Education' } },
-    // We use the same "existing" syntax to reference a channel by unique property (handle)
-    // In this case it's a channel that we created in createChannel example
-    channel: { existing: { handle } },
-    media: {
-      // We use "new" syntax to sygnalize we want to create a new VideoMedia entity that will be related to this Video entity
-      new: {
-        // We use "exisiting" enconding from inputs/entityBatches/VideoMediaEncodingBatch.json
-        encoding: { existing: { name: 'H.263_MP4' } },
-        pixelHeight: 600,
-        pixelWidth: 800,
-        // We create nested VideoMedia->MediaLocation->HttpMediaLocation relations using the "new" syntax
-        location: { new: { httpMediaLocation: { new: { url: 'https://testnet.joystream.org/' } } } },
-      },
-    },
-    // Here we use combined "new" and "existing" syntaxes to create Video->License->KnownLicense relations
-    license: {
-      new: {
-        knownLicense: {
-          // This license can be found in inputs/entityBatches/KnownLicenseBatch.json
-          existing: { code: 'CC_BY' },
-        },
-      },
-    },
-    duration: 3600,
-    thumbnailUrl: '',
-    isExplicit: false,
-    isPublic: true,
-  }
-  return new CreateVideoFixture(api, videoEntity)
-}
-
-function assertVideoMatchQueriedResult(queriedVideo: any, video: VideoEntity) {
-  assert.equal(queriedVideo.title, video.title, 'Should be equal')
-  assert.equal(queriedVideo.description, video.description, 'Should be equal')
-  assert.equal(queriedVideo.duration, video.duration, 'Should be equal')
-  assert.equal(queriedVideo.thumbnailUrl, video.thumbnailUrl, 'Should be equal')
-  assert.equal(queriedVideo.isExplicit, video.isExplicit, 'Should be equal')
-  assert.equal(queriedVideo.isPublic, video.isPublic, 'Should be equal')
-}
-
-export default async function createVideo({ api, query }: FlowProps): Promise<void> {
-  const debug = Debugger('flow:creatingVideo')
-  debug('Started')
-
-  const channelTitle = 'New channel example'
-  const createVideoHappyCaseFixture = createVideoReferencingChannelFixture(api, channelTitle)
-
-  await new FixtureRunner(createVideoHappyCaseFixture).run()
-
-  // 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 query.performFullTextSearchOnChannelTitle('video')
-
-  assert(channelFullTextSearchResult.data.search.length === 1, 'Should contain exactly one entry')
-
-  // Both channel and video title starts with `Example`
-  channelFullTextSearchResult = await query.performFullTextSearchOnChannelTitle('Example')
-
-  assert(channelFullTextSearchResult.data.search.length === 2, 'Should contain two entries')
-
-  // Perform number full text searches on Channel title, that absolutely should NOT return the video.
-  channelFullTextSearchResult = await query.performFullTextSearchOnChannelTitle('First')
-
-  assert(channelFullTextSearchResult.data.search.length === 0, 'Should be empty')
-
-  channelFullTextSearchResult = await query.performFullTextSearchOnChannelTitle('vid')
-
-  assert(channelFullTextSearchResult.data.search.length === 0, 'Should be empty')
-
-  // Ensure channel contains only one video with right data
-  const channelResult = await query.getChannelbyHandle(channelTitle)
-
-  assert(channelResult.data.channels[0].videos.length === 1, 'Given channel should contain exactly one video')
-
-  assertVideoMatchQueriedResult(channelResult.data.channels[0].videos[0], createVideoHappyCaseFixture.videoEntity)
-
-  // Perform number of full text searches on Video title, that is a slight variation on title that one expects would return the video.
-  let videoFullTextSearchResult = await query.performFullTextSearchOnVideoTitle('Example')
-
-  assert(videoFullTextSearchResult.data.search.length === 2, 'Should contain two entries')
-
-  videoFullTextSearchResult = await query.performFullTextSearchOnVideoTitle('Example 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 query.performFullTextSearchOnVideoTitle('unknown')
-
-  assert(videoFullTextSearchResult.data.search.length === 0, 'Should be empty')
-
-  videoFullTextSearchResult = await query.performFullTextSearchOnVideoTitle('MediaVideo')
-
-  assert(videoFullTextSearchResult.data.search.length === 0, 'Should be empty')
-
-  debug('Done')
-}

+ 0 - 49
tests/network-tests/src/flows/contentDirectory/updatingChannel.ts

@@ -1,49 +0,0 @@
-import { Api } from '../../Api'
-import { FlowProps } from '../../Flow'
-import { UpdateChannelFixture } from '../../fixtures/contentDirectoryModule'
-import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
-import { assert } from 'chai'
-import { Utils } from '../../utils'
-import { FixtureRunner } from '../../Fixture'
-import Debugger from 'debug'
-
-export function createUpdateChannelHandleFixture(api: Api, handle: string, description: string): UpdateChannelFixture {
-  // Create partial channel entity, only containing the fields we wish to update
-  const channelUpdateInput: Partial<ChannelEntity> = {
-    description,
-  }
-
-  const uniquePropVal: Record<string, any> = { handle }
-
-  return new UpdateChannelFixture(api, channelUpdateInput, uniquePropVal)
-}
-
-export default async function updateChannel({ api, query }: FlowProps): Promise<void> {
-  const debug = Debugger('flow:updateChannel')
-  debug('Started')
-
-  const handle = 'New channel example'
-  const channelResult = await query.getChannelbyHandle(handle)
-  const channel = channelResult.data.channels[0]
-
-  const description = 'Updated description'
-  const createUpdateChannelDescriptionHappyCaseFixture = createUpdateChannelHandleFixture(api, handle, description)
-
-  await new FixtureRunner(createUpdateChannelDescriptionHappyCaseFixture).run()
-
-  // Temporary solution (wait 2 minutes)
-  await Utils.wait(120000)
-
-  const channelAfterUpdateResult = await query.getChannelbyHandle(handle)
-  const channelAfterUpdate = channelAfterUpdateResult.data.channels[0]
-
-  // description field should be updated to provided one
-  assert.equal(channelAfterUpdate.description, description, 'Should be equal')
-
-  assert.equal(channelAfterUpdate.handle, channel.handle, 'Should be equal')
-  assert.equal(channelAfterUpdate.coverPhotoUrl, channel.coverPhotoUrl, 'Should be equal')
-  assert.equal(channelAfterUpdate.avatarPhotoUrl, channel.avatarPhotoUrl, 'Should be equal')
-  assert.equal(channelAfterUpdate.isPublic, channel.isPublic, 'Should be equal')
-
-  debug('Done')
-}

+ 0 - 6
tests/network-tests/src/scenarios/content-directory.ts

@@ -1,12 +1,6 @@
 import leaderSetup from '../flows/workingGroup/leaderSetup'
-import createChannel from '../flows/contentDirectory/creatingChannel'
-import createVideo from '../flows/contentDirectory/creatingVideo'
-import updateChannel from '../flows/contentDirectory/updatingChannel'
 import { scenario } from '../Scenario'
 
 scenario(async ({ job }) => {
   job('setup content lead', leaderSetup.content)
-    .then(job('create-channel', createChannel))
-    .then(job('create-video', createVideo))
-    .then(job('update-channel', updateChannel))
 })