diff options
Diffstat (limited to 'server/tests/api/search')
-rw-r--r-- | server/tests/api/search/search-activitypub-video-playlists.ts | 45 | ||||
-rw-r--r-- | server/tests/api/search/search-playlists.ts | 26 |
2 files changed, 20 insertions, 51 deletions
diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts index 1df18173a..cb7582d29 100644 --- a/server/tests/api/search/search-activitypub-video-playlists.ts +++ b/server/tests/api/search/search-activitypub-video-playlists.ts | |||
@@ -3,12 +3,8 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | addVideoInPlaylist, | ||
7 | cleanupTests, | 6 | cleanupTests, |
8 | createVideoPlaylist, | ||
9 | deleteVideoPlaylist, | ||
10 | flushAndRunMultipleServers, | 7 | flushAndRunMultipleServers, |
11 | getVideoPlaylistsList, | ||
12 | SearchCommand, | 8 | SearchCommand, |
13 | ServerInfo, | 9 | ServerInfo, |
14 | setAccessTokensToServers, | 10 | setAccessTokensToServers, |
@@ -46,16 +42,11 @@ describe('Test ActivityPub playlists search', function () { | |||
46 | privacy: VideoPlaylistPrivacy.PUBLIC, | 42 | privacy: VideoPlaylistPrivacy.PUBLIC, |
47 | videoChannelId: servers[0].videoChannel.id | 43 | videoChannelId: servers[0].videoChannel.id |
48 | } | 44 | } |
49 | const res = await createVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistAttrs: attributes }) | 45 | const created = await servers[0].playlistsCommand.create({ attributes }) |
50 | playlistServer1UUID = res.body.videoPlaylist.uuid | 46 | playlistServer1UUID = created.uuid |
51 | 47 | ||
52 | for (const videoId of [ video1, video2 ]) { | 48 | for (const videoId of [ video1, video2 ]) { |
53 | await addVideoInPlaylist({ | 49 | await servers[0].playlistsCommand.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } }) |
54 | url: servers[0].url, | ||
55 | token: servers[0].accessToken, | ||
56 | playlistId: playlistServer1UUID, | ||
57 | elementAttrs: { videoId } | ||
58 | }) | ||
59 | } | 50 | } |
60 | } | 51 | } |
61 | 52 | ||
@@ -68,15 +59,10 @@ describe('Test ActivityPub playlists search', function () { | |||
68 | privacy: VideoPlaylistPrivacy.PUBLIC, | 59 | privacy: VideoPlaylistPrivacy.PUBLIC, |
69 | videoChannelId: servers[1].videoChannel.id | 60 | videoChannelId: servers[1].videoChannel.id |
70 | } | 61 | } |
71 | const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs: attributes }) | 62 | const created = await servers[1].playlistsCommand.create({ attributes }) |
72 | playlistServer2UUID = res.body.videoPlaylist.uuid | 63 | playlistServer2UUID = created.uuid |
73 | 64 | ||
74 | await addVideoInPlaylist({ | 65 | await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } }) |
75 | url: servers[1].url, | ||
76 | token: servers[1].accessToken, | ||
77 | playlistId: playlistServer2UUID, | ||
78 | elementAttrs: { videoId } | ||
79 | }) | ||
80 | } | 66 | } |
81 | 67 | ||
82 | await waitJobs(servers) | 68 | await waitJobs(servers) |
@@ -154,21 +140,16 @@ describe('Test ActivityPub playlists search', function () { | |||
154 | }) | 140 | }) |
155 | 141 | ||
156 | it('Should not list this remote playlist', async function () { | 142 | it('Should not list this remote playlist', async function () { |
157 | const res = await getVideoPlaylistsList(servers[0].url, 0, 10) | 143 | const body = await servers[0].playlistsCommand.list({ start: 0, count: 10 }) |
158 | expect(res.body.total).to.equal(1) | 144 | expect(body.total).to.equal(1) |
159 | expect(res.body.data).to.have.lengthOf(1) | 145 | expect(body.data).to.have.lengthOf(1) |
160 | expect(res.body.data[0].displayName).to.equal('playlist 1 on server 1') | 146 | expect(body.data[0].displayName).to.equal('playlist 1 on server 1') |
161 | }) | 147 | }) |
162 | 148 | ||
163 | it('Should update the playlist of server 2, and refresh it on server 1', async function () { | 149 | it('Should update the playlist of server 2, and refresh it on server 1', async function () { |
164 | this.timeout(60000) | 150 | this.timeout(60000) |
165 | 151 | ||
166 | await addVideoInPlaylist({ | 152 | await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } }) |
167 | url: servers[1].url, | ||
168 | token: servers[1].accessToken, | ||
169 | playlistId: playlistServer2UUID, | ||
170 | elementAttrs: { videoId: video2Server2 } | ||
171 | }) | ||
172 | 153 | ||
173 | await waitJobs(servers) | 154 | await waitJobs(servers) |
174 | // Expire playlist | 155 | // Expire playlist |
@@ -192,7 +173,7 @@ describe('Test ActivityPub playlists search', function () { | |||
192 | it('Should delete playlist of server 2, and delete it on server 1', async function () { | 173 | it('Should delete playlist of server 2, and delete it on server 1', async function () { |
193 | this.timeout(60000) | 174 | this.timeout(60000) |
194 | 175 | ||
195 | await deleteVideoPlaylist(servers[1].url, servers[1].accessToken, playlistServer2UUID) | 176 | await servers[1].playlistsCommand.delete({ playlistId: playlistServer2UUID }) |
196 | 177 | ||
197 | await waitJobs(servers) | 178 | await waitJobs(servers) |
198 | // Expiration | 179 | // Expiration |
diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index 1862ecd31..517884503 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts | |||
@@ -4,9 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { VideoPlaylistPrivacy } from '@shared/models' | 5 | import { VideoPlaylistPrivacy } from '@shared/models' |
6 | import { | 6 | import { |
7 | addVideoInPlaylist, | ||
8 | cleanupTests, | 7 | cleanupTests, |
9 | createVideoPlaylist, | ||
10 | flushAndRunServer, | 8 | flushAndRunServer, |
11 | SearchCommand, | 9 | SearchCommand, |
12 | ServerInfo, | 10 | ServerInfo, |
@@ -37,14 +35,9 @@ describe('Test playlists search', function () { | |||
37 | privacy: VideoPlaylistPrivacy.PUBLIC, | 35 | privacy: VideoPlaylistPrivacy.PUBLIC, |
38 | videoChannelId: server.videoChannel.id | 36 | videoChannelId: server.videoChannel.id |
39 | } | 37 | } |
40 | const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) | 38 | const created = await server.playlistsCommand.create({ attributes }) |
41 | 39 | ||
42 | await addVideoInPlaylist({ | 40 | await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) |
43 | url: server.url, | ||
44 | token: server.accessToken, | ||
45 | playlistId: res.body.videoPlaylist.id, | ||
46 | elementAttrs: { videoId } | ||
47 | }) | ||
48 | } | 41 | } |
49 | 42 | ||
50 | { | 43 | { |
@@ -53,14 +46,9 @@ describe('Test playlists search', function () { | |||
53 | privacy: VideoPlaylistPrivacy.PUBLIC, | 46 | privacy: VideoPlaylistPrivacy.PUBLIC, |
54 | videoChannelId: server.videoChannel.id | 47 | videoChannelId: server.videoChannel.id |
55 | } | 48 | } |
56 | const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) | 49 | const created = await server.playlistsCommand.create({ attributes }) |
57 | 50 | ||
58 | await addVideoInPlaylist({ | 51 | await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) |
59 | url: server.url, | ||
60 | token: server.accessToken, | ||
61 | playlistId: res.body.videoPlaylist.id, | ||
62 | elementAttrs: { videoId } | ||
63 | }) | ||
64 | } | 52 | } |
65 | 53 | ||
66 | { | 54 | { |
@@ -69,7 +57,7 @@ describe('Test playlists search', function () { | |||
69 | privacy: VideoPlaylistPrivacy.PUBLIC, | 57 | privacy: VideoPlaylistPrivacy.PUBLIC, |
70 | videoChannelId: server.videoChannel.id | 58 | videoChannelId: server.videoChannel.id |
71 | } | 59 | } |
72 | await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) | 60 | await server.playlistsCommand.create({ attributes }) |
73 | } | 61 | } |
74 | 62 | ||
75 | command = server.searchCommand | 63 | command = server.searchCommand |