From 9b474844e85cce916370693cc24f53339a695570 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Jul 2019 10:37:35 +0200 Subject: Add CLI plugins tests --- server/tests/cli/peertube.ts | 202 +++++++++++++++++++++++++------------------ 1 file changed, 120 insertions(+), 82 deletions(-) (limited to 'server/tests/cli/peertube.ts') diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index d73e27564..b8c0b1f79 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -43,133 +43,171 @@ describe('Test CLI wrapper', function () { } }) - it('Should display no selected instance', async function () { - this.timeout(60000) + describe('Authentication and instance selection', function () { - const env = getEnvCli(server) - const stdout = await execCLI(`${env} ${cmd} --help`) + it('Should display no selected instance', async function () { + this.timeout(60000) - expect(stdout).to.contain('no instance selected') - }) + const env = getEnvCli(server) + const stdout = await execCLI(`${env} ${cmd} --help`) - it('Should add a user', async function () { - this.timeout(60000) + expect(stdout).to.contain('no instance selected') + }) - const env = getEnvCli(server) - await execCLI(`${env} ${cmd} auth add -u ${server.url} -U user_1 -p super_password`) - }) + it('Should add a user', async function () { + this.timeout(60000) - it('Should default to this user', async function () { - this.timeout(60000) + const env = getEnvCli(server) + await execCLI(`${env} ${cmd} auth add -u ${server.url} -U user_1 -p super_password`) + }) - const env = getEnvCli(server) - const stdout = await execCLI(`${env} ${cmd} --help`) + it('Should default to this user', async function () { + this.timeout(60000) - expect(stdout).to.contain(`instance ${server.url} selected`) - }) + const env = getEnvCli(server) + const stdout = await execCLI(`${env} ${cmd} --help`) - it('Should remember the user', async function () { - this.timeout(60000) + expect(stdout).to.contain(`instance ${server.url} selected`) + }) - const env = getEnvCli(server) - const stdout = await execCLI(`${env} ${cmd} auth list`) + it('Should remember the user', async function () { + this.timeout(60000) - expect(stdout).to.contain(server.url) + const env = getEnvCli(server) + const stdout = await execCLI(`${env} ${cmd} auth list`) + + expect(stdout).to.contain(server.url) + }) }) - it('Should upload a video', async function () { - this.timeout(60000) + describe('Video upload/import', function () { - const env = getEnvCli(server) + it('Should upload a video', async function () { + this.timeout(60000) - const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4') + const env = getEnvCli(server) - const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'` + const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4') - await execCLI(`${env} ${cmd} upload ${params}`) - }) + const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'` - it('Should have the video uploaded', async function () { - const res = await getVideosList(server.url) + await execCLI(`${env} ${cmd} upload ${params}`) + }) - expect(res.body.total).to.equal(1) + it('Should have the video uploaded', async function () { + const res = await getVideosList(server.url) - const videos: Video[] = res.body.data + expect(res.body.total).to.equal(1) - const video: VideoDetails = (await getVideo(server.url, videos[0].uuid)).body + const videos: Video[] = res.body.data - expect(video.name).to.equal('test upload') - expect(video.support).to.equal('support_text') - expect(video.channel.name).to.equal('user_channel') - }) + const video: VideoDetails = (await getVideo(server.url, videos[ 0 ].uuid)).body - it('Should import a video', async function () { - this.timeout(60000) + expect(video.name).to.equal('test upload') + expect(video.support).to.equal('support_text') + expect(video.channel.name).to.equal('user_channel') + }) - const env = getEnvCli(server) + it('Should import a video', async function () { + this.timeout(60000) - const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel` + const env = getEnvCli(server) - await execCLI(`${env} ${cmd} import ${params}`) - }) + const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel` - it('Should have imported the video', async function () { - this.timeout(60000) + await execCLI(`${env} ${cmd} import ${params}`) + }) - await waitJobs([ server ]) + it('Should have imported the video', async function () { + this.timeout(60000) - const res = await getVideosList(server.url) + await waitJobs([ server ]) - expect(res.body.total).to.equal(2) + const res = await getVideosList(server.url) - const videos: Video[] = res.body.data - const video = videos.find(v => v.name === 'small video - youtube') - expect(video).to.not.be.undefined + expect(res.body.total).to.equal(2) - const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body - expect(videoDetails.channel.name).to.equal('user_channel') - expect(videoDetails.support).to.equal('super support text') - expect(videoDetails.nsfw).to.be.false + const videos: Video[] = res.body.data + const video = videos.find(v => v.name === 'small video - youtube') + expect(video).to.not.be.undefined - // So we can reimport it - await removeVideo(server.url, userAccessToken, video.id) - }) + const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body + expect(videoDetails.channel.name).to.equal('user_channel') + expect(videoDetails.support).to.equal('super support text') + expect(videoDetails.nsfw).to.be.false - it('Should import and override some imported attributes', async function () { - this.timeout(60000) + // So we can reimport it + await removeVideo(server.url, userAccessToken, video.id) + }) - const env = getEnvCli(server) + it('Should import and override some imported attributes', async function () { + this.timeout(60000) - const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support` + const env = getEnvCli(server) - await execCLI(`${env} ${cmd} import ${params}`) + const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support` - await waitJobs([ server ]) + await execCLI(`${env} ${cmd} import ${params}`) - { - const res = await getVideosList(server.url) - expect(res.body.total).to.equal(2) + await waitJobs([ server ]) - const videos: Video[] = res.body.data - const video = videos.find(v => v.name === 'toto') - expect(video).to.not.be.undefined + { + const res = await getVideosList(server.url) + expect(res.body.total).to.equal(2) - const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body - expect(videoDetails.channel.name).to.equal('user_channel') - expect(videoDetails.support).to.equal('support') - expect(videoDetails.nsfw).to.be.true - expect(videoDetails.commentsEnabled).to.be.true - } + const videos: Video[] = res.body.data + const video = videos.find(v => v.name === 'toto') + expect(video).to.not.be.undefined + + const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body + expect(videoDetails.channel.name).to.equal('user_channel') + expect(videoDetails.support).to.equal('support') + expect(videoDetails.nsfw).to.be.true + expect(videoDetails.commentsEnabled).to.be.true + } + }) }) - it('Should remove the auth user', async function () { - const env = getEnvCli(server) + describe('Admin auth', function () { + + it('Should remove the auth user', async function () { + const env = getEnvCli(server) + + await execCLI(`${env} ${cmd} auth del ${server.url}`) + + const stdout = await execCLI(`${env} ${cmd} --help`) + + expect(stdout).to.contain('no instance selected') + }) + + it('Should add the admin user', async function () { + const env = getEnvCli(server) + await execCLI(`${env} ${cmd} auth add -u ${server.url} -U root -p test${server.internalServerNumber}`) + }) + }) + + describe('Manage plugins', function () { + + it('Should install a plugin', async function () { + this.timeout(60000) + + const env = getEnvCli(server) + await execCLI(`${env} ${cmd} plugins install --npm-name peertube-plugin-hello-world`) + }) + + it('Should list installed plugins', async function () { + const env = getEnvCli(server) + const res = await execCLI(`${env} ${cmd} plugins list`) - await execCLI(`${env} ${cmd} auth del ${server.url}`) + expect(res).to.contain('peertube-plugin-hello-world') + }) - const stdout = await execCLI(`${env} ${cmd} --help`) + it('Should uninstall the plugin', async function () { + const env = getEnvCli(server) + const res = await execCLI(`${env} ${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`) - expect(stdout).to.contain('no instance selected') + expect(res).to.not.contain('peertube-plugin-hello-world') + }) }) after(async function () { -- cgit v1.2.3