diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-28 13:59:22 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-28 13:59:22 +0100 |
commit | c5d31dba56d669c0df0209761c43c5a6ac7cec4a (patch) | |
tree | fe72b56a1c0e7beb6e092c393a00ddfe93a5d71f /server/tests/api/videos/video-description.ts | |
parent | db799da3d2b2ea465165df78ff71effa653b6309 (diff) | |
download | PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.tar.gz PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.tar.zst PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.zip |
Tests directories refractor
Diffstat (limited to 'server/tests/api/videos/video-description.ts')
-rw-r--r-- | server/tests/api/videos/video-description.ts | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts new file mode 100644 index 000000000..c2985194c --- /dev/null +++ b/server/tests/api/videos/video-description.ts | |||
@@ -0,0 +1,111 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | ||
5 | import { | ||
6 | flushAndRunMultipleServers, | ||
7 | flushTests, | ||
8 | getVideo, | ||
9 | getVideoDescription, | ||
10 | getVideosList, | ||
11 | killallServers, | ||
12 | ServerInfo, | ||
13 | setAccessTokensToServers, | ||
14 | updateVideo, | ||
15 | uploadVideo, | ||
16 | wait | ||
17 | } from '../../utils/index' | ||
18 | import { doubleFollow } from '../../utils/server/follows' | ||
19 | |||
20 | const expect = chai.expect | ||
21 | |||
22 | describe('Test video description', function () { | ||
23 | let servers: ServerInfo[] = [] | ||
24 | let videoUUID = '' | ||
25 | let videoId: number | ||
26 | let longDescription = 'my super description for server 1'.repeat(50) | ||
27 | |||
28 | before(async function () { | ||
29 | this.timeout(40000) | ||
30 | |||
31 | // Run servers | ||
32 | servers = await flushAndRunMultipleServers(2) | ||
33 | |||
34 | // Get the access tokens | ||
35 | await setAccessTokensToServers(servers) | ||
36 | |||
37 | // Server 1 and server 2 follow each other | ||
38 | await doubleFollow(servers[0], servers[1]) | ||
39 | }) | ||
40 | |||
41 | it('Should upload video with long description', async function () { | ||
42 | this.timeout(10000) | ||
43 | |||
44 | const attributes = { | ||
45 | description: longDescription | ||
46 | } | ||
47 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
48 | |||
49 | await wait(5000) | ||
50 | |||
51 | const res = await getVideosList(servers[0].url) | ||
52 | |||
53 | videoId = res.body.data[0].id | ||
54 | videoUUID = res.body.data[0].uuid | ||
55 | }) | ||
56 | |||
57 | it('Should have a truncated description on each server', async function () { | ||
58 | for (const server of servers) { | ||
59 | const res = await getVideo(server.url, videoUUID) | ||
60 | const video = res.body | ||
61 | |||
62 | // 30 characters * 6 -> 240 characters | ||
63 | const truncatedDescription = 'my super description for server 1'.repeat(7) + | ||
64 | 'my super descrip...' | ||
65 | |||
66 | expect(video.description).to.equal(truncatedDescription) | ||
67 | } | ||
68 | }) | ||
69 | |||
70 | it('Should fetch long description on each server', async function () { | ||
71 | for (const server of servers) { | ||
72 | const res = await getVideo(server.url, videoUUID) | ||
73 | const video = res.body | ||
74 | |||
75 | const res2 = await getVideoDescription(server.url, video.descriptionPath) | ||
76 | expect(res2.body.description).to.equal(longDescription) | ||
77 | } | ||
78 | }) | ||
79 | |||
80 | it('Should update with a short description', async function () { | ||
81 | this.timeout(10000) | ||
82 | |||
83 | const attributes = { | ||
84 | description: 'short description' | ||
85 | } | ||
86 | await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes) | ||
87 | |||
88 | await wait(5000) | ||
89 | }) | ||
90 | |||
91 | it('Should have a small description on each server', async function () { | ||
92 | for (const server of servers) { | ||
93 | const res = await getVideo(server.url, videoUUID) | ||
94 | const video = res.body | ||
95 | |||
96 | expect(video.description).to.equal('short description') | ||
97 | |||
98 | const res2 = await getVideoDescription(server.url, video.descriptionPath) | ||
99 | expect(res2.body.description).to.equal('short description') | ||
100 | } | ||
101 | }) | ||
102 | |||
103 | after(async function () { | ||
104 | killallServers(servers) | ||
105 | |||
106 | // Keep the logs if the test failed | ||
107 | if (this['ok']) { | ||
108 | await flushTests() | ||
109 | } | ||
110 | }) | ||
111 | }) | ||