]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/peertube.ts
Add ability to enabled HLS in the admin panel
[github/Chocobozzz/PeerTube.git] / server / tests / cli / peertube.ts
index 0a8a98334dff8a7f816e8786dfdae693c7fbfa3b..b8c0b1f795e541cea386e2d0574793304e791faf 100644 (file)
@@ -43,132 +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
-    }
+        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 () {