diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-10 10:58:44 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-10 14:02:41 +0200 |
commit | 3521ab8fc01da85fa804439ca6e297e6fb364c58 (patch) | |
tree | 70db4fc628c85d145d59efafbefec9093e9eebac /server/tests/api/search/search-channels.ts | |
parent | 3b0bd70aa05ab82fa30fe67ed4899d44652c703a (diff) | |
download | PeerTube-3521ab8fc01da85fa804439ca6e297e6fb364c58.tar.gz PeerTube-3521ab8fc01da85fa804439ca6e297e6fb364c58.tar.zst PeerTube-3521ab8fc01da85fa804439ca6e297e6fb364c58.zip |
Add search index tests
Diffstat (limited to 'server/tests/api/search/search-channels.ts')
-rw-r--r-- | server/tests/api/search/search-channels.ts | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts new file mode 100644 index 000000000..daca2aebe --- /dev/null +++ b/server/tests/api/search/search-channels.ts | |||
@@ -0,0 +1,79 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | ||
5 | import { searchVideoChannel, advancedVideoChannelSearch } from '@shared/extra-utils/search/video-channels' | ||
6 | import { | ||
7 | addVideoChannel, | ||
8 | cleanupTests, | ||
9 | createUser, | ||
10 | flushAndRunServer, | ||
11 | ServerInfo, | ||
12 | setAccessTokensToServers | ||
13 | } from '../../../../shared/extra-utils' | ||
14 | import { VideoChannel } from '@shared/models' | ||
15 | |||
16 | const expect = chai.expect | ||
17 | |||
18 | describe('Test channels search', function () { | ||
19 | let server: ServerInfo = null | ||
20 | |||
21 | before(async function () { | ||
22 | this.timeout(30000) | ||
23 | |||
24 | server = await flushAndRunServer(1) | ||
25 | |||
26 | await setAccessTokensToServers([ server ]) | ||
27 | |||
28 | { | ||
29 | await createUser({ url: server.url, accessToken: server.accessToken, username: 'user1', password: 'password' }) | ||
30 | const channel = { | ||
31 | name: 'squall_channel', | ||
32 | displayName: 'Squall channel' | ||
33 | } | ||
34 | await addVideoChannel(server.url, server.accessToken, channel) | ||
35 | } | ||
36 | }) | ||
37 | |||
38 | it('Should make a simple search and not have results', async function () { | ||
39 | const res = await searchVideoChannel(server.url, 'abc') | ||
40 | |||
41 | expect(res.body.total).to.equal(0) | ||
42 | expect(res.body.data).to.have.lengthOf(0) | ||
43 | }) | ||
44 | |||
45 | it('Should make a search and have results', async function () { | ||
46 | { | ||
47 | const search = { | ||
48 | search: 'Squall', | ||
49 | start: 0, | ||
50 | count: 1 | ||
51 | } | ||
52 | const res = await advancedVideoChannelSearch(server.url, search) | ||
53 | expect(res.body.total).to.equal(1) | ||
54 | expect(res.body.data).to.have.lengthOf(1) | ||
55 | |||
56 | const channel: VideoChannel = res.body.data[0] | ||
57 | expect(channel.name).to.equal('squall_channel') | ||
58 | expect(channel.displayName).to.equal('Squall channel') | ||
59 | } | ||
60 | |||
61 | { | ||
62 | const search = { | ||
63 | search: 'Squall', | ||
64 | start: 1, | ||
65 | count: 1 | ||
66 | } | ||
67 | |||
68 | const res = await advancedVideoChannelSearch(server.url, search) | ||
69 | |||
70 | expect(res.body.total).to.equal(1) | ||
71 | |||
72 | expect(res.body.data).to.have.lengthOf(0) | ||
73 | } | ||
74 | }) | ||
75 | |||
76 | after(async function () { | ||
77 | await cleanupTests([ server ]) | ||
78 | }) | ||
79 | }) | ||