|
@@ -1,9 +1,10 @@
|
|
|
-import { QueryNodeApi, WorkingGroups } from '../../Api'
|
|
|
+import { QueryNodeApi } from '../../Api'
|
|
|
import { CreateVideoFixture } from '../../fixtures/contentDirectoryModule'
|
|
|
import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
|
|
|
import { assert } from 'chai'
|
|
|
+import { Utils } from '../../utils'
|
|
|
|
|
|
-export function createVideoReferencingChannelFixture(api: QueryNodeApi): CreateVideoFixture {
|
|
|
+export function createVideoReferencingChannelFixture(api: QueryNodeApi, handle: string): CreateVideoFixture {
|
|
|
const videoEntity: VideoEntity = {
|
|
|
title: 'Example video',
|
|
|
description: 'This is an example video',
|
|
@@ -13,7 +14,7 @@ export function createVideoReferencingChannelFixture(api: QueryNodeApi): CreateV
|
|
|
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: 'Example channel' } },
|
|
|
+ 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: {
|
|
@@ -42,8 +43,65 @@ export function createVideoReferencingChannelFixture(api: QueryNodeApi): CreateV
|
|
|
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: QueryNodeApi) {
|
|
|
- const createVideoHappyCaseFixture = createVideoReferencingChannelFixture(api)
|
|
|
+ const channelTitle = 'New channel example'
|
|
|
+ const createVideoHappyCaseFixture = createVideoReferencingChannelFixture(api, channelTitle)
|
|
|
|
|
|
await createVideoHappyCaseFixture.runner(false)
|
|
|
+
|
|
|
+ // 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')
|
|
|
+
|
|
|
+ assert(channelFullTextSearchResult.data.search.length === 1, 'Should contain exactly one entry')
|
|
|
+
|
|
|
+ // Both channel and video title starts with `Example`
|
|
|
+ channelFullTextSearchResult = await api.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 api.performFullTextSearchOnChannelTitle('First')
|
|
|
+
|
|
|
+ assert(channelFullTextSearchResult.data.search.length === 0, 'Should be empty')
|
|
|
+
|
|
|
+ channelFullTextSearchResult = await api.performFullTextSearchOnChannelTitle('vid')
|
|
|
+
|
|
|
+ assert(channelFullTextSearchResult.data.search.length === 0, 'Should be empty')
|
|
|
+
|
|
|
+ // Ensure channel contains only one video with right data
|
|
|
+ const channelResult = await api.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 api.performFullTextSearchOnVideoTitle('Example')
|
|
|
+
|
|
|
+ assert(videoFullTextSearchResult.data.search.length === 2, 'Should contain two entries')
|
|
|
+
|
|
|
+ videoFullTextSearchResult = await api.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 api.performFullTextSearchOnVideoTitle('unknown')
|
|
|
+
|
|
|
+ assert(videoFullTextSearchResult.data.search.length === 0, 'Should be empty')
|
|
|
+
|
|
|
+ videoFullTextSearchResult = await api.performFullTextSearchOnVideoTitle('MediaVideo')
|
|
|
+
|
|
|
+ assert(videoFullTextSearchResult.data.search.length === 0, 'Should be empty')
|
|
|
}
|