diff options
Diffstat (limited to 'server/tests/api/videos/video-captions.ts')
-rw-r--r-- | server/tests/api/videos/video-captions.ts | 77 |
1 files changed, 32 insertions, 45 deletions
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts index 14ecedfa6..83ee809b8 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/server/tests/api/videos/video-captions.ts | |||
@@ -1,25 +1,20 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { | 5 | import { |
6 | checkVideoFilesWereRemoved, | 6 | checkVideoFilesWereRemoved, |
7 | cleanupTests, | 7 | cleanupTests, |
8 | doubleFollow, | 8 | doubleFollow, |
9 | flushAndRunMultipleServers, | 9 | flushAndRunMultipleServers, |
10 | removeVideo, | 10 | removeVideo, |
11 | ServerInfo, | ||
12 | setAccessTokensToServers, | ||
13 | testCaptionFile, | ||
11 | uploadVideo, | 14 | uploadVideo, |
12 | wait | 15 | wait, |
13 | } from '../../../../shared/extra-utils' | 16 | waitJobs |
14 | import { ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index' | 17 | } from '@shared/extra-utils' |
15 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
16 | import { | ||
17 | createVideoCaption, | ||
18 | deleteVideoCaption, | ||
19 | listVideoCaptions, | ||
20 | testCaptionFile | ||
21 | } from '../../../../shared/extra-utils/videos/video-captions' | ||
22 | import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' | ||
23 | 18 | ||
24 | const expect = chai.expect | 19 | const expect = chai.expect |
25 | 20 | ||
@@ -47,26 +42,22 @@ describe('Test video captions', function () { | |||
47 | 42 | ||
48 | it('Should list the captions and return an empty list', async function () { | 43 | it('Should list the captions and return an empty list', async function () { |
49 | for (const server of servers) { | 44 | for (const server of servers) { |
50 | const res = await listVideoCaptions(server.url, videoUUID) | 45 | const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) |
51 | expect(res.body.total).to.equal(0) | 46 | expect(body.total).to.equal(0) |
52 | expect(res.body.data).to.have.lengthOf(0) | 47 | expect(body.data).to.have.lengthOf(0) |
53 | } | 48 | } |
54 | }) | 49 | }) |
55 | 50 | ||
56 | it('Should create two new captions', async function () { | 51 | it('Should create two new captions', async function () { |
57 | this.timeout(30000) | 52 | this.timeout(30000) |
58 | 53 | ||
59 | await createVideoCaption({ | 54 | await servers[0].captionsCommand.createVideoCaption({ |
60 | url: servers[0].url, | ||
61 | accessToken: servers[0].accessToken, | ||
62 | language: 'ar', | 55 | language: 'ar', |
63 | videoId: videoUUID, | 56 | videoId: videoUUID, |
64 | fixture: 'subtitle-good1.vtt' | 57 | fixture: 'subtitle-good1.vtt' |
65 | }) | 58 | }) |
66 | 59 | ||
67 | await createVideoCaption({ | 60 | await servers[0].captionsCommand.createVideoCaption({ |
68 | url: servers[0].url, | ||
69 | accessToken: servers[0].accessToken, | ||
70 | language: 'zh', | 61 | language: 'zh', |
71 | videoId: videoUUID, | 62 | videoId: videoUUID, |
72 | fixture: 'subtitle-good2.vtt', | 63 | fixture: 'subtitle-good2.vtt', |
@@ -78,17 +69,17 @@ describe('Test video captions', function () { | |||
78 | 69 | ||
79 | it('Should list these uploaded captions', async function () { | 70 | it('Should list these uploaded captions', async function () { |
80 | for (const server of servers) { | 71 | for (const server of servers) { |
81 | const res = await listVideoCaptions(server.url, videoUUID) | 72 | const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) |
82 | expect(res.body.total).to.equal(2) | 73 | expect(body.total).to.equal(2) |
83 | expect(res.body.data).to.have.lengthOf(2) | 74 | expect(body.data).to.have.lengthOf(2) |
84 | 75 | ||
85 | const caption1: VideoCaption = res.body.data[0] | 76 | const caption1 = body.data[0] |
86 | expect(caption1.language.id).to.equal('ar') | 77 | expect(caption1.language.id).to.equal('ar') |
87 | expect(caption1.language.label).to.equal('Arabic') | 78 | expect(caption1.language.label).to.equal('Arabic') |
88 | expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$')) | 79 | expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$')) |
89 | await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 1.') | 80 | await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 1.') |
90 | 81 | ||
91 | const caption2: VideoCaption = res.body.data[1] | 82 | const caption2 = body.data[1] |
92 | expect(caption2.language.id).to.equal('zh') | 83 | expect(caption2.language.id).to.equal('zh') |
93 | expect(caption2.language.label).to.equal('Chinese') | 84 | expect(caption2.language.label).to.equal('Chinese') |
94 | expect(caption2.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$')) | 85 | expect(caption2.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$')) |
@@ -99,9 +90,7 @@ describe('Test video captions', function () { | |||
99 | it('Should replace an existing caption', async function () { | 90 | it('Should replace an existing caption', async function () { |
100 | this.timeout(30000) | 91 | this.timeout(30000) |
101 | 92 | ||
102 | await createVideoCaption({ | 93 | await servers[0].captionsCommand.createVideoCaption({ |
103 | url: servers[0].url, | ||
104 | accessToken: servers[0].accessToken, | ||
105 | language: 'ar', | 94 | language: 'ar', |
106 | videoId: videoUUID, | 95 | videoId: videoUUID, |
107 | fixture: 'subtitle-good2.vtt' | 96 | fixture: 'subtitle-good2.vtt' |
@@ -112,11 +101,11 @@ describe('Test video captions', function () { | |||
112 | 101 | ||
113 | it('Should have this caption updated', async function () { | 102 | it('Should have this caption updated', async function () { |
114 | for (const server of servers) { | 103 | for (const server of servers) { |
115 | const res = await listVideoCaptions(server.url, videoUUID) | 104 | const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) |
116 | expect(res.body.total).to.equal(2) | 105 | expect(body.total).to.equal(2) |
117 | expect(res.body.data).to.have.lengthOf(2) | 106 | expect(body.data).to.have.lengthOf(2) |
118 | 107 | ||
119 | const caption1: VideoCaption = res.body.data[0] | 108 | const caption1 = body.data[0] |
120 | expect(caption1.language.id).to.equal('ar') | 109 | expect(caption1.language.id).to.equal('ar') |
121 | expect(caption1.language.label).to.equal('Arabic') | 110 | expect(caption1.language.label).to.equal('Arabic') |
122 | expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$')) | 111 | expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$')) |
@@ -127,9 +116,7 @@ describe('Test video captions', function () { | |||
127 | it('Should replace an existing caption with a srt file and convert it', async function () { | 116 | it('Should replace an existing caption with a srt file and convert it', async function () { |
128 | this.timeout(30000) | 117 | this.timeout(30000) |
129 | 118 | ||
130 | await createVideoCaption({ | 119 | await servers[0].captionsCommand.createVideoCaption({ |
131 | url: servers[0].url, | ||
132 | accessToken: servers[0].accessToken, | ||
133 | language: 'ar', | 120 | language: 'ar', |
134 | videoId: videoUUID, | 121 | videoId: videoUUID, |
135 | fixture: 'subtitle-good.srt' | 122 | fixture: 'subtitle-good.srt' |
@@ -143,11 +130,11 @@ describe('Test video captions', function () { | |||
143 | 130 | ||
144 | it('Should have this caption updated and converted', async function () { | 131 | it('Should have this caption updated and converted', async function () { |
145 | for (const server of servers) { | 132 | for (const server of servers) { |
146 | const res = await listVideoCaptions(server.url, videoUUID) | 133 | const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) |
147 | expect(res.body.total).to.equal(2) | 134 | expect(body.total).to.equal(2) |
148 | expect(res.body.data).to.have.lengthOf(2) | 135 | expect(body.data).to.have.lengthOf(2) |
149 | 136 | ||
150 | const caption1: VideoCaption = res.body.data[0] | 137 | const caption1 = body.data[0] |
151 | expect(caption1.language.id).to.equal('ar') | 138 | expect(caption1.language.id).to.equal('ar') |
152 | expect(caption1.language.label).to.equal('Arabic') | 139 | expect(caption1.language.label).to.equal('Arabic') |
153 | expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$')) | 140 | expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$')) |
@@ -172,18 +159,18 @@ describe('Test video captions', function () { | |||
172 | it('Should remove one caption', async function () { | 159 | it('Should remove one caption', async function () { |
173 | this.timeout(30000) | 160 | this.timeout(30000) |
174 | 161 | ||
175 | await deleteVideoCaption(servers[0].url, servers[0].accessToken, videoUUID, 'ar') | 162 | await servers[0].captionsCommand.deleteVideoCaption({ videoId: videoUUID, language: 'ar' }) |
176 | 163 | ||
177 | await waitJobs(servers) | 164 | await waitJobs(servers) |
178 | }) | 165 | }) |
179 | 166 | ||
180 | it('Should only list the caption that was not deleted', async function () { | 167 | it('Should only list the caption that was not deleted', async function () { |
181 | for (const server of servers) { | 168 | for (const server of servers) { |
182 | const res = await listVideoCaptions(server.url, videoUUID) | 169 | const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) |
183 | expect(res.body.total).to.equal(1) | 170 | expect(body.total).to.equal(1) |
184 | expect(res.body.data).to.have.lengthOf(1) | 171 | expect(body.data).to.have.lengthOf(1) |
185 | 172 | ||
186 | const caption: VideoCaption = res.body.data[0] | 173 | const caption = body.data[0] |
187 | 174 | ||
188 | expect(caption.language.id).to.equal('zh') | 175 | expect(caption.language.id).to.equal('zh') |
189 | expect(caption.language.label).to.equal('Chinese') | 176 | expect(caption.language.label).to.equal('Chinese') |