aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/peertube.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/cli/peertube.ts')
-rw-r--r--server/tests/cli/peertube.ts202
1 files changed, 120 insertions, 82 deletions
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 () {
43 } 43 }
44 }) 44 })
45 45
46 it('Should display no selected instance', async function () { 46 describe('Authentication and instance selection', function () {
47 this.timeout(60000)
48 47
49 const env = getEnvCli(server) 48 it('Should display no selected instance', async function () {
50 const stdout = await execCLI(`${env} ${cmd} --help`) 49 this.timeout(60000)
51 50
52 expect(stdout).to.contain('no instance selected') 51 const env = getEnvCli(server)
53 }) 52 const stdout = await execCLI(`${env} ${cmd} --help`)
54 53
55 it('Should add a user', async function () { 54 expect(stdout).to.contain('no instance selected')
56 this.timeout(60000) 55 })
57 56
58 const env = getEnvCli(server) 57 it('Should add a user', async function () {
59 await execCLI(`${env} ${cmd} auth add -u ${server.url} -U user_1 -p super_password`) 58 this.timeout(60000)
60 })
61 59
62 it('Should default to this user', async function () { 60 const env = getEnvCli(server)
63 this.timeout(60000) 61 await execCLI(`${env} ${cmd} auth add -u ${server.url} -U user_1 -p super_password`)
62 })
64 63
65 const env = getEnvCli(server) 64 it('Should default to this user', async function () {
66 const stdout = await execCLI(`${env} ${cmd} --help`) 65 this.timeout(60000)
67 66
68 expect(stdout).to.contain(`instance ${server.url} selected`) 67 const env = getEnvCli(server)
69 }) 68 const stdout = await execCLI(`${env} ${cmd} --help`)
70 69
71 it('Should remember the user', async function () { 70 expect(stdout).to.contain(`instance ${server.url} selected`)
72 this.timeout(60000) 71 })
73 72
74 const env = getEnvCli(server) 73 it('Should remember the user', async function () {
75 const stdout = await execCLI(`${env} ${cmd} auth list`) 74 this.timeout(60000)
76 75
77 expect(stdout).to.contain(server.url) 76 const env = getEnvCli(server)
77 const stdout = await execCLI(`${env} ${cmd} auth list`)
78
79 expect(stdout).to.contain(server.url)
80 })
78 }) 81 })
79 82
80 it('Should upload a video', async function () { 83 describe('Video upload/import', function () {
81 this.timeout(60000)
82 84
83 const env = getEnvCli(server) 85 it('Should upload a video', async function () {
86 this.timeout(60000)
84 87
85 const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4') 88 const env = getEnvCli(server)
86 89
87 const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'` 90 const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4')
88 91
89 await execCLI(`${env} ${cmd} upload ${params}`) 92 const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'`
90 })
91 93
92 it('Should have the video uploaded', async function () { 94 await execCLI(`${env} ${cmd} upload ${params}`)
93 const res = await getVideosList(server.url) 95 })
94 96
95 expect(res.body.total).to.equal(1) 97 it('Should have the video uploaded', async function () {
98 const res = await getVideosList(server.url)
96 99
97 const videos: Video[] = res.body.data 100 expect(res.body.total).to.equal(1)
98 101
99 const video: VideoDetails = (await getVideo(server.url, videos[0].uuid)).body 102 const videos: Video[] = res.body.data
100 103
101 expect(video.name).to.equal('test upload') 104 const video: VideoDetails = (await getVideo(server.url, videos[ 0 ].uuid)).body
102 expect(video.support).to.equal('support_text')
103 expect(video.channel.name).to.equal('user_channel')
104 })
105 105
106 it('Should import a video', async function () { 106 expect(video.name).to.equal('test upload')
107 this.timeout(60000) 107 expect(video.support).to.equal('support_text')
108 expect(video.channel.name).to.equal('user_channel')
109 })
108 110
109 const env = getEnvCli(server) 111 it('Should import a video', async function () {
112 this.timeout(60000)
110 113
111 const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel` 114 const env = getEnvCli(server)
112 115
113 await execCLI(`${env} ${cmd} import ${params}`) 116 const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel`
114 })
115 117
116 it('Should have imported the video', async function () { 118 await execCLI(`${env} ${cmd} import ${params}`)
117 this.timeout(60000) 119 })
118 120
119 await waitJobs([ server ]) 121 it('Should have imported the video', async function () {
122 this.timeout(60000)
120 123
121 const res = await getVideosList(server.url) 124 await waitJobs([ server ])
122 125
123 expect(res.body.total).to.equal(2) 126 const res = await getVideosList(server.url)
124 127
125 const videos: Video[] = res.body.data 128 expect(res.body.total).to.equal(2)
126 const video = videos.find(v => v.name === 'small video - youtube')
127 expect(video).to.not.be.undefined
128 129
129 const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body 130 const videos: Video[] = res.body.data
130 expect(videoDetails.channel.name).to.equal('user_channel') 131 const video = videos.find(v => v.name === 'small video - youtube')
131 expect(videoDetails.support).to.equal('super support text') 132 expect(video).to.not.be.undefined
132 expect(videoDetails.nsfw).to.be.false
133 133
134 // So we can reimport it 134 const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body
135 await removeVideo(server.url, userAccessToken, video.id) 135 expect(videoDetails.channel.name).to.equal('user_channel')
136 }) 136 expect(videoDetails.support).to.equal('super support text')
137 expect(videoDetails.nsfw).to.be.false
137 138
138 it('Should import and override some imported attributes', async function () { 139 // So we can reimport it
139 this.timeout(60000) 140 await removeVideo(server.url, userAccessToken, video.id)
141 })
140 142
141 const env = getEnvCli(server) 143 it('Should import and override some imported attributes', async function () {
144 this.timeout(60000)
142 145
143 const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support` 146 const env = getEnvCli(server)
144 147
145 await execCLI(`${env} ${cmd} import ${params}`) 148 const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support`
146 149
147 await waitJobs([ server ]) 150 await execCLI(`${env} ${cmd} import ${params}`)
148 151
149 { 152 await waitJobs([ server ])
150 const res = await getVideosList(server.url)
151 expect(res.body.total).to.equal(2)
152 153
153 const videos: Video[] = res.body.data 154 {
154 const video = videos.find(v => v.name === 'toto') 155 const res = await getVideosList(server.url)
155 expect(video).to.not.be.undefined 156 expect(res.body.total).to.equal(2)
156 157
157 const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body 158 const videos: Video[] = res.body.data
158 expect(videoDetails.channel.name).to.equal('user_channel') 159 const video = videos.find(v => v.name === 'toto')
159 expect(videoDetails.support).to.equal('support') 160 expect(video).to.not.be.undefined
160 expect(videoDetails.nsfw).to.be.true 161
161 expect(videoDetails.commentsEnabled).to.be.true 162 const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body
162 } 163 expect(videoDetails.channel.name).to.equal('user_channel')
164 expect(videoDetails.support).to.equal('support')
165 expect(videoDetails.nsfw).to.be.true
166 expect(videoDetails.commentsEnabled).to.be.true
167 }
168 })
163 }) 169 })
164 170
165 it('Should remove the auth user', async function () { 171 describe('Admin auth', function () {
166 const env = getEnvCli(server) 172
173 it('Should remove the auth user', async function () {
174 const env = getEnvCli(server)
175
176 await execCLI(`${env} ${cmd} auth del ${server.url}`)
177
178 const stdout = await execCLI(`${env} ${cmd} --help`)
179
180 expect(stdout).to.contain('no instance selected')
181 })
182
183 it('Should add the admin user', async function () {
184 const env = getEnvCli(server)
185 await execCLI(`${env} ${cmd} auth add -u ${server.url} -U root -p test${server.internalServerNumber}`)
186 })
187 })
188
189 describe('Manage plugins', function () {
190
191 it('Should install a plugin', async function () {
192 this.timeout(60000)
193
194 const env = getEnvCli(server)
195 await execCLI(`${env} ${cmd} plugins install --npm-name peertube-plugin-hello-world`)
196 })
197
198 it('Should list installed plugins', async function () {
199 const env = getEnvCli(server)
200 const res = await execCLI(`${env} ${cmd} plugins list`)
167 201
168 await execCLI(`${env} ${cmd} auth del ${server.url}`) 202 expect(res).to.contain('peertube-plugin-hello-world')
203 })
169 204
170 const stdout = await execCLI(`${env} ${cmd} --help`) 205 it('Should uninstall the plugin', async function () {
206 const env = getEnvCli(server)
207 const res = await execCLI(`${env} ${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`)
171 208
172 expect(stdout).to.contain('no instance selected') 209 expect(res).to.not.contain('peertube-plugin-hello-world')
210 })
173 }) 211 })
174 212
175 after(async function () { 213 after(async function () {