diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-06 15:22:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | af971e06c620bd46a5aa64c8833364e7022b5e3d (patch) | |
tree | 4288b66b79fe4dd1ab9496e85a3abf7d747ad03a /server/tests/api/search/search-playlists.ts | |
parent | 23a3a8827cb8b862f5cc7ee2819f39918303beca (diff) | |
download | PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.gz PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.zst PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.zip |
Introduce search command
Diffstat (limited to 'server/tests/api/search/search-playlists.ts')
-rw-r--r-- | server/tests/api/search/search-playlists.ts | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index ab17d55e9..1862ecd31 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts | |||
@@ -2,14 +2,13 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { VideoPlaylist, VideoPlaylistPrivacy } from '@shared/models' | 5 | import { VideoPlaylistPrivacy } from '@shared/models' |
6 | import { | 6 | import { |
7 | addVideoInPlaylist, | 7 | addVideoInPlaylist, |
8 | advancedVideoPlaylistSearch, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | createVideoPlaylist, | 9 | createVideoPlaylist, |
11 | flushAndRunServer, | 10 | flushAndRunServer, |
12 | searchVideoPlaylists, | 11 | SearchCommand, |
13 | ServerInfo, | 12 | ServerInfo, |
14 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
15 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
@@ -20,6 +19,7 @@ const expect = chai.expect | |||
20 | 19 | ||
21 | describe('Test playlists search', function () { | 20 | describe('Test playlists search', function () { |
22 | let server: ServerInfo = null | 21 | let server: ServerInfo = null |
22 | let command: SearchCommand | ||
23 | 23 | ||
24 | before(async function () { | 24 | before(async function () { |
25 | this.timeout(30000) | 25 | this.timeout(30000) |
@@ -71,13 +71,15 @@ describe('Test playlists search', function () { | |||
71 | } | 71 | } |
72 | await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) | 72 | await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) |
73 | } | 73 | } |
74 | |||
75 | command = server.searchCommand | ||
74 | }) | 76 | }) |
75 | 77 | ||
76 | it('Should make a simple search and not have results', async function () { | 78 | it('Should make a simple search and not have results', async function () { |
77 | const res = await searchVideoPlaylists(server.url, 'abc') | 79 | const body = await command.searchPlaylists({ search: 'abc' }) |
78 | 80 | ||
79 | expect(res.body.total).to.equal(0) | 81 | expect(body.total).to.equal(0) |
80 | expect(res.body.data).to.have.lengthOf(0) | 82 | expect(body.data).to.have.lengthOf(0) |
81 | }) | 83 | }) |
82 | 84 | ||
83 | it('Should make a search and have results', async function () { | 85 | it('Should make a search and have results', async function () { |
@@ -87,11 +89,11 @@ describe('Test playlists search', function () { | |||
87 | start: 0, | 89 | start: 0, |
88 | count: 1 | 90 | count: 1 |
89 | } | 91 | } |
90 | const res = await advancedVideoPlaylistSearch(server.url, search) | 92 | const body = await command.advancedPlaylistSearch({ search }) |
91 | expect(res.body.total).to.equal(1) | 93 | expect(body.total).to.equal(1) |
92 | expect(res.body.data).to.have.lengthOf(1) | 94 | expect(body.data).to.have.lengthOf(1) |
93 | 95 | ||
94 | const playlist: VideoPlaylist = res.body.data[0] | 96 | const playlist = body.data[0] |
95 | expect(playlist.displayName).to.equal('Dr. Kenzo Tenma hospital videos') | 97 | expect(playlist.displayName).to.equal('Dr. Kenzo Tenma hospital videos') |
96 | expect(playlist.url).to.equal(server.url + '/video-playlists/' + playlist.uuid) | 98 | expect(playlist.url).to.equal(server.url + '/video-playlists/' + playlist.uuid) |
97 | } | 99 | } |
@@ -102,11 +104,11 @@ describe('Test playlists search', function () { | |||
102 | start: 0, | 104 | start: 0, |
103 | count: 1 | 105 | count: 1 |
104 | } | 106 | } |
105 | const res = await advancedVideoPlaylistSearch(server.url, search) | 107 | const body = await command.advancedPlaylistSearch({ search }) |
106 | expect(res.body.total).to.equal(1) | 108 | expect(body.total).to.equal(1) |
107 | expect(res.body.data).to.have.lengthOf(1) | 109 | expect(body.data).to.have.lengthOf(1) |
108 | 110 | ||
109 | const playlist: VideoPlaylist = res.body.data[0] | 111 | const playlist = body.data[0] |
110 | expect(playlist.displayName).to.equal('Johan & Anna Libert musics') | 112 | expect(playlist.displayName).to.equal('Johan & Anna Libert musics') |
111 | } | 113 | } |
112 | }) | 114 | }) |
@@ -117,9 +119,9 @@ describe('Test playlists search', function () { | |||
117 | start: 0, | 119 | start: 0, |
118 | count: 1 | 120 | count: 1 |
119 | } | 121 | } |
120 | const res = await advancedVideoPlaylistSearch(server.url, search) | 122 | const body = await command.advancedPlaylistSearch({ search }) |
121 | expect(res.body.total).to.equal(0) | 123 | expect(body.total).to.equal(0) |
122 | expect(res.body.data).to.have.lengthOf(0) | 124 | expect(body.data).to.have.lengthOf(0) |
123 | }) | 125 | }) |
124 | 126 | ||
125 | after(async function () { | 127 | after(async function () { |