import 'mocha' ; import * as chai from 'chai' ; import { cleanupTests , createMultipleServers , doubleFollow , PeerTubeServer , setAccessTokensToServers , waitJobs } from '@shared/server-commands' ; const expect = chai . expect ; describe ( 'Test video description' , function ( ) { let servers = [ ] ; let videoUUID = '' ; let videoId ; const longDescription = 'my super description for server 1' . repeat ( 50 ) ; before ( async function ( ) { this . timeout ( 40000 ) ; servers = await createMultipleServers ( 2 ) ; await setAccessTokensToServers ( servers ) ; await doubleFollow ( servers [ 0 ] , servers [ 1 ] ) ; } ) ; it ( 'Should upload video with long description' , async function ( ) { this . timeout ( 10000 ) ; const attributes = { description : longDescription } ; await servers [ 0 ] . videos . upload ( { attributes } ) ; await waitJobs ( servers ) ; const { data } = await servers [ 0 ] . videos . list ( ) ; videoId = data [ 0 ] . id ; videoUUID = data [ 0 ] . uuid ; } ) ; it ( 'Should have a truncated description on each server' , async function ( ) { for ( const server of servers ) { const video = await server . videos . get ( { id : videoUUID } ) ; const truncatedDescription = 'my super description for server 1' . repeat ( 7 ) + 'my super descrip...' ; expect ( video . description ) . to . equal ( truncatedDescription ) ; } } ) ; it ( 'Should fetch long description on each server' , async function ( ) { for ( const server of servers ) { const video = await server . videos . get ( { id : videoUUID } ) ; const { description } = await server . videos . getDescription ( { descriptionPath : video . descriptionPath } ) ; expect ( description ) . to . equal ( longDescription ) ; } } ) ; it ( 'Should update with a short description' , async function ( ) { this . timeout ( 10000 ) ; const attributes = { description : 'short description' } ; await servers [ 0 ] . videos . update ( { id : videoId , attributes } ) ; await waitJobs ( servers ) ; } ) ; it ( 'Should have a small description on each server' , async function ( ) { for ( const server of servers ) { const video = await server . videos . get ( { id : videoUUID } ) ; expect ( video . description ) . to . equal ( 'short description' ) ; const { description } = await server . videos . getDescription ( { descriptionPath : video . descriptionPath } ) ; expect ( description ) . to . equal ( 'short description' ) ; } } ) ; after ( async function ( ) { await cleanupTests ( servers ) ; } ) ; } ) ;