creatingChannel.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { QueryNodeApi } from '../../Api'
  2. import { Utils } from '../../utils'
  3. import { CreateChannelFixture } from '../../fixtures/contentDirectoryModule'
  4. import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
  5. import { assert } from 'chai'
  6. import { KeyringPair } from '@polkadot/keyring/types'
  7. export function createSimpleChannelFixture(api: QueryNodeApi): CreateChannelFixture {
  8. const channelEntity: ChannelEntity = {
  9. handle: 'Example channel',
  10. description: 'This is an example channel',
  11. // We can use "existing" syntax to reference either an on-chain entity or other entity that's part of the same batch.
  12. // Here we reference language that we assume was added by initialization script (initialize:dev), as it is part of
  13. // input/entityBatches/LanguageBatch.json
  14. language: { existing: { code: 'EN' } },
  15. coverPhotoUrl: '',
  16. avatarPhotoUrl: '',
  17. isPublic: true,
  18. }
  19. return new CreateChannelFixture(api, channelEntity)
  20. }
  21. export default async function channelCreation(api: QueryNodeApi) {
  22. const createChannelHappyCaseFixture = createSimpleChannelFixture(api)
  23. await createChannelHappyCaseFixture.runner(false)
  24. // Temporary solution (wait 2 minutes)
  25. await Utils.wait(120000)
  26. // Ensure newly created channel was parsed by query node
  27. const result = await api.getChannelbyTitle(createChannelHappyCaseFixture.channelEntity.handle)
  28. const queriedChannel = result.data.channels[0]
  29. assert(queriedChannel.title === createChannelHappyCaseFixture.channelEntity.handle, 'Should be equal')
  30. assert(queriedChannel.description === createChannelHappyCaseFixture.channelEntity.description, 'Should be equal')
  31. assert(queriedChannel.coverPhotoUrl === createChannelHappyCaseFixture.channelEntity.coverPhotoUrl, 'Should be equal')
  32. assert(
  33. queriedChannel.avatarPhotoUrl === createChannelHappyCaseFixture.channelEntity.avatarPhotoUrl,
  34. 'Should be equal'
  35. )
  36. assert(queriedChannel.isPublic === createChannelHappyCaseFixture.channelEntity.isPublic, 'Should be equal')
  37. }