|
@@ -2,8 +2,9 @@ import { QueryNodeApi, WorkingGroups } from '../../Api'
|
|
|
import { CreateVideoFixture } from '../../fixtures/contentDirectoryModule'
|
|
|
import { VideoEntity } from 'cd-schemas/types/entities/VideoEntity'
|
|
|
import { assert } from 'chai'
|
|
|
+import { Utils } from '../../utils'
|
|
|
|
|
|
-export function createVideoReferencingChannelFixture(api: QueryNodeApi): CreateVideoFixture {
|
|
|
+export function createVideoReferencingChannelFixture(api: QueryNodeApi, title: 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 (title)
|
|
|
// In this case it's a channel that we created in createChannel example
|
|
|
- channel: { existing: { title: 'Example channel' } },
|
|
|
+ channel: { existing: { title } },
|
|
|
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,11 +43,63 @@ export function createVideoReferencingChannelFixture(api: QueryNodeApi): CreateV
|
|
|
return new CreateVideoFixture(api, videoEntity)
|
|
|
}
|
|
|
|
|
|
+function assertVideoMatchQueriedResult(queriedVideo: any, video: VideoEntity) {
|
|
|
+ assert(queriedVideo.title === video.title, 'Should be equal')
|
|
|
+ assert(queriedVideo.description === video.description, 'Should be equal')
|
|
|
+ assert(queriedVideo.duration === video.duration, 'Should be equal')
|
|
|
+ assert(queriedVideo.thumbnailUrl === video.thumbnailURL, 'Should be equal')
|
|
|
+ assert(queriedVideo.avatarPhotoUrl === video.isExplicit, 'Should be equal')
|
|
|
+ assert(queriedVideo.isPublic === video.isPublic, 'Should be equal')
|
|
|
+}
|
|
|
+
|
|
|
export default async function createVideo(api: QueryNodeApi) {
|
|
|
- const createVideoHappyCaseFixture = createVideoReferencingChannelFixture(api)
|
|
|
+ const channelTitle = 'Example channel'
|
|
|
+ const createVideoHappyCaseFixture = createVideoReferencingChannelFixture(api, channelTitle)
|
|
|
+
|
|
|
+ await createVideoHappyCaseFixture.runner(false)
|
|
|
|
|
|
// Temporary solution (wait 2 minutes)
|
|
|
- // await Utils.wait(120000)
|
|
|
+ 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('Examp')
|
|
|
+
|
|
|
+ assert(channelFullTextSearchResult.data.titles[0].item.videos.length === 1, 'Should contain exactly one video')
|
|
|
+
|
|
|
+ channelFullTextSearchResult = await api.performFullTextSearchOnChannelTitle(' channel')
|
|
|
+
|
|
|
+ assert(channelFullTextSearchResult.data.titles[0].item.videos.length === 1, 'Should contain exactly one video')
|
|
|
+
|
|
|
+ // Perform number full text searches on Channel title, that absolutely should NOT return the video.
|
|
|
+ channelFullTextSearchResult = await api.performFullTextSearchOnChannelTitle('First')
|
|
|
+
|
|
|
+ assert(channelFullTextSearchResult.data.titles.length === 0, 'Should be empty')
|
|
|
+
|
|
|
+ channelFullTextSearchResult = await api.performFullTextSearchOnChannelTitle('Chanel')
|
|
|
+
|
|
|
+ assert(channelFullTextSearchResult.data.titles.length === 0, 'Should be empty')
|
|
|
+
|
|
|
+ // Ensure channel contains only one video with right data
|
|
|
+ const channelResult = await api.getChannelbyTitle(channelTitle)
|
|
|
+
|
|
|
+ assertVideoMatchQueriedResult(channelResult.data.channels[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.titles.length === 1, 'Should contain exactly one video')
|
|
|
+
|
|
|
+ videoFullTextSearchResult = await api.performFullTextSearchOnVideoTitle('video')
|
|
|
+
|
|
|
+ assert(videoFullTextSearchResult.data.titles.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.titles.length === 0, 'Should be empty')
|
|
|
+
|
|
|
+ videoFullTextSearchResult = await api.performFullTextSearchOnVideoTitle('MediaVideo')
|
|
|
+
|
|
|
+ assert(videoFullTextSearchResult.data.titles.length === 0, 'Should be empty')
|
|
|
|
|
|
- await createVideoHappyCaseFixture.runner(false)
|
|
|
}
|