1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers'
6 checkVideoFilesWereRemoved,
10 setAccessTokensToServers,
13 } from '../../../shared/extra-utils'
15 describe('Test plugin helpers', function () {
16 let server: ServerInfo
18 before(async function () {
21 server = await flushAndRunServer(1)
22 await setAccessTokensToServers([ server ])
26 accessToken: server.accessToken,
27 path: getPluginTestPath('-four')
31 it('Should have logged things', async function () {
32 await waitUntilLog(server, 'localhost:' + server.port + ' peertube-plugin-test-four', 1, false)
33 await waitUntilLog(server, 'Hello world from plugin four', 1)
36 it('Should have made a query', async function () {
37 await waitUntilLog(server, `root email is admin${server.internalServerNumber}@example.com`, 1)
40 it('Should remove a video after a view', async function () {
43 const videoUUID = (await uploadVideoAndGetId({ server: server, videoName: 'video1' })).uuid
45 // Should not throw -> video exists
46 await getVideo(server.url, videoUUID)
47 // Should delete the video
48 await viewVideo(server.url, videoUUID)
50 await waitUntilLog(server, 'Video deleted by plugin four.', 1)
53 // Should throw because the video should have been deleted
54 await getVideo(server.url, videoUUID)
55 throw new Error('Video exists')
57 if (err.message.includes('exists')) throw err
60 await checkVideoFilesWereRemoved(videoUUID, server.internalServerNumber)
63 after(async function () {
64 await cleanupTests([ server ])