diff options
Diffstat (limited to 'server/tests/plugins/filter-hooks.ts')
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 88 |
1 files changed, 83 insertions, 5 deletions
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 6c1fd40ba..41242318e 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -1,8 +1,8 @@ | |||
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' |
5 | import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers' | 4 | import * as chai from 'chai' |
5 | import { ServerConfig } from '@shared/models' | ||
6 | import { | 6 | import { |
7 | addVideoCommentReply, | 7 | addVideoCommentReply, |
8 | addVideoCommentThread, | 8 | addVideoCommentThread, |
@@ -23,10 +23,10 @@ import { | |||
23 | uploadVideo, | 23 | uploadVideo, |
24 | waitJobs | 24 | waitJobs |
25 | } from '../../../shared/extra-utils' | 25 | } from '../../../shared/extra-utils' |
26 | import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers' | ||
27 | import { getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports' | ||
28 | import { VideoDetails, VideoImport, VideoImportState, VideoPrivacy } from '../../../shared/models/videos' | ||
26 | import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' | 29 | import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' |
27 | import { VideoDetails } from '../../../shared/models/videos' | ||
28 | import { getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports' | ||
29 | import { ServerConfig } from '@shared/models' | ||
30 | 30 | ||
31 | const expect = chai.expect | 31 | const expect = chai.expect |
32 | 32 | ||
@@ -87,6 +87,84 @@ describe('Test plugin filter hooks', function () { | |||
87 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video with bad word' }, 403) | 87 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video with bad word' }, 403) |
88 | }) | 88 | }) |
89 | 89 | ||
90 | it('Should run filter:api.video.pre-import-url.accept.result', async function () { | ||
91 | const baseAttributes = { | ||
92 | name: 'normal title', | ||
93 | privacy: VideoPrivacy.PUBLIC, | ||
94 | channelId: servers[0].videoChannel.id, | ||
95 | targetUrl: getYoutubeVideoUrl() + 'bad' | ||
96 | } | ||
97 | await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, 403) | ||
98 | }) | ||
99 | |||
100 | it('Should run filter:api.video.pre-import-torrent.accept.result', async function () { | ||
101 | const baseAttributes = { | ||
102 | name: 'bad torrent', | ||
103 | privacy: VideoPrivacy.PUBLIC, | ||
104 | channelId: servers[0].videoChannel.id, | ||
105 | torrentfile: 'video-720p.torrent' as any | ||
106 | } | ||
107 | await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, 403) | ||
108 | }) | ||
109 | |||
110 | it('Should run filter:api.video.post-import-url.accept.result', async function () { | ||
111 | this.timeout(60000) | ||
112 | |||
113 | let videoImportId: number | ||
114 | |||
115 | { | ||
116 | const baseAttributes = { | ||
117 | name: 'title with bad word', | ||
118 | privacy: VideoPrivacy.PUBLIC, | ||
119 | channelId: servers[0].videoChannel.id, | ||
120 | targetUrl: getYoutubeVideoUrl() | ||
121 | } | ||
122 | const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes) | ||
123 | videoImportId = res.body.id | ||
124 | } | ||
125 | |||
126 | await waitJobs(servers) | ||
127 | |||
128 | { | ||
129 | const res = await getMyVideoImports(servers[0].url, servers[0].accessToken) | ||
130 | const videoImports = res.body.data as VideoImport[] | ||
131 | |||
132 | const videoImport = videoImports.find(i => i.id === videoImportId) | ||
133 | |||
134 | expect(videoImport.state.id).to.equal(VideoImportState.REJECTED) | ||
135 | expect(videoImport.state.label).to.equal('Rejected') | ||
136 | } | ||
137 | }) | ||
138 | |||
139 | it('Should run filter:api.video.post-import-torrent.accept.result', async function () { | ||
140 | this.timeout(60000) | ||
141 | |||
142 | let videoImportId: number | ||
143 | |||
144 | { | ||
145 | const baseAttributes = { | ||
146 | name: 'title with bad word', | ||
147 | privacy: VideoPrivacy.PUBLIC, | ||
148 | channelId: servers[0].videoChannel.id, | ||
149 | torrentfile: 'video-720p.torrent' as any | ||
150 | } | ||
151 | const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes) | ||
152 | videoImportId = res.body.id | ||
153 | } | ||
154 | |||
155 | await waitJobs(servers) | ||
156 | |||
157 | { | ||
158 | const res = await getMyVideoImports(servers[0].url, servers[0].accessToken) | ||
159 | const videoImports = res.body.data as VideoImport[] | ||
160 | |||
161 | const videoImport = videoImports.find(i => i.id === videoImportId) | ||
162 | |||
163 | expect(videoImport.state.id).to.equal(VideoImportState.REJECTED) | ||
164 | expect(videoImport.state.label).to.equal('Rejected') | ||
165 | } | ||
166 | }) | ||
167 | |||
90 | it('Should run filter:api.video-thread.create.accept.result', async function () { | 168 | it('Should run filter:api.video-thread.create.accept.result', async function () { |
91 | await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'comment with bad word', 403) | 169 | await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'comment with bad word', 403) |
92 | }) | 170 | }) |