diff options
Diffstat (limited to 'server/tests/api/activitypub/cleaner.ts')
-rw-r--r-- | server/tests/api/activitypub/cleaner.ts | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/server/tests/api/activitypub/cleaner.ts b/server/tests/api/activitypub/cleaner.ts index dcf758711..1421824da 100644 --- a/server/tests/api/activitypub/cleaner.ts +++ b/server/tests/api/activitypub/cleaner.ts | |||
@@ -46,9 +46,9 @@ describe('Test AP cleaner', function () { | |||
46 | // Create 1 comment per video | 46 | // Create 1 comment per video |
47 | // Update 1 remote URL and 1 local URL on | 47 | // Update 1 remote URL and 1 local URL on |
48 | 48 | ||
49 | videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'server 1' })).uuid | 49 | videoUUID1 = (await servers[0].videos.quickUpload({ name: 'server 1' })).uuid |
50 | videoUUID2 = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid | 50 | videoUUID2 = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid |
51 | videoUUID3 = (await servers[2].videosCommand.quickUpload({ name: 'server 3' })).uuid | 51 | videoUUID3 = (await servers[2].videos.quickUpload({ name: 'server 3' })).uuid |
52 | 52 | ||
53 | videoUUIDs = [ videoUUID1, videoUUID2, videoUUID3 ] | 53 | videoUUIDs = [ videoUUID1, videoUUID2, videoUUID3 ] |
54 | 54 | ||
@@ -56,8 +56,8 @@ describe('Test AP cleaner', function () { | |||
56 | 56 | ||
57 | for (const server of servers) { | 57 | for (const server of servers) { |
58 | for (const uuid of videoUUIDs) { | 58 | for (const uuid of videoUUIDs) { |
59 | await server.videosCommand.rate({ id: uuid, rating: 'like' }) | 59 | await server.videos.rate({ id: uuid, rating: 'like' }) |
60 | await server.commentsCommand.createThread({ videoId: uuid, text: 'comment' }) | 60 | await server.comments.createThread({ videoId: uuid, text: 'comment' }) |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
@@ -67,7 +67,7 @@ describe('Test AP cleaner', function () { | |||
67 | it('Should have the correct likes', async function () { | 67 | it('Should have the correct likes', async function () { |
68 | for (const server of servers) { | 68 | for (const server of servers) { |
69 | for (const uuid of videoUUIDs) { | 69 | for (const uuid of videoUUIDs) { |
70 | const video = await server.videosCommand.get({ id: uuid }) | 70 | const video = await server.videos.get({ id: uuid }) |
71 | 71 | ||
72 | expect(video.likes).to.equal(3) | 72 | expect(video.likes).to.equal(3) |
73 | expect(video.dislikes).to.equal(0) | 73 | expect(video.dislikes).to.equal(0) |
@@ -78,9 +78,9 @@ describe('Test AP cleaner', function () { | |||
78 | it('Should destroy server 3 internal likes and correctly clean them', async function () { | 78 | it('Should destroy server 3 internal likes and correctly clean them', async function () { |
79 | this.timeout(20000) | 79 | this.timeout(20000) |
80 | 80 | ||
81 | await servers[2].sqlCommand.deleteAll('accountVideoRate') | 81 | await servers[2].sql.deleteAll('accountVideoRate') |
82 | for (const uuid of videoUUIDs) { | 82 | for (const uuid of videoUUIDs) { |
83 | await servers[2].sqlCommand.setVideoField(uuid, 'likes', '0') | 83 | await servers[2].sql.setVideoField(uuid, 'likes', '0') |
84 | } | 84 | } |
85 | 85 | ||
86 | await wait(5000) | 86 | await wait(5000) |
@@ -88,14 +88,14 @@ describe('Test AP cleaner', function () { | |||
88 | 88 | ||
89 | // Updated rates of my video | 89 | // Updated rates of my video |
90 | { | 90 | { |
91 | const video = await servers[0].videosCommand.get({ id: videoUUID1 }) | 91 | const video = await servers[0].videos.get({ id: videoUUID1 }) |
92 | expect(video.likes).to.equal(2) | 92 | expect(video.likes).to.equal(2) |
93 | expect(video.dislikes).to.equal(0) | 93 | expect(video.dislikes).to.equal(0) |
94 | } | 94 | } |
95 | 95 | ||
96 | // Did not update rates of a remote video | 96 | // Did not update rates of a remote video |
97 | { | 97 | { |
98 | const video = await servers[0].videosCommand.get({ id: videoUUID2 }) | 98 | const video = await servers[0].videos.get({ id: videoUUID2 }) |
99 | expect(video.likes).to.equal(3) | 99 | expect(video.likes).to.equal(3) |
100 | expect(video.dislikes).to.equal(0) | 100 | expect(video.dislikes).to.equal(0) |
101 | } | 101 | } |
@@ -106,7 +106,7 @@ describe('Test AP cleaner', function () { | |||
106 | 106 | ||
107 | for (const server of servers) { | 107 | for (const server of servers) { |
108 | for (const uuid of videoUUIDs) { | 108 | for (const uuid of videoUUIDs) { |
109 | await server.videosCommand.rate({ id: uuid, rating: 'dislike' }) | 109 | await server.videos.rate({ id: uuid, rating: 'dislike' }) |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
@@ -114,7 +114,7 @@ describe('Test AP cleaner', function () { | |||
114 | 114 | ||
115 | for (const server of servers) { | 115 | for (const server of servers) { |
116 | for (const uuid of videoUUIDs) { | 116 | for (const uuid of videoUUIDs) { |
117 | const video = await server.videosCommand.get({ id: uuid }) | 117 | const video = await server.videos.get({ id: uuid }) |
118 | expect(video.likes).to.equal(0) | 118 | expect(video.likes).to.equal(0) |
119 | expect(video.dislikes).to.equal(3) | 119 | expect(video.dislikes).to.equal(3) |
120 | } | 120 | } |
@@ -124,10 +124,10 @@ describe('Test AP cleaner', function () { | |||
124 | it('Should destroy server 3 internal dislikes and correctly clean them', async function () { | 124 | it('Should destroy server 3 internal dislikes and correctly clean them', async function () { |
125 | this.timeout(20000) | 125 | this.timeout(20000) |
126 | 126 | ||
127 | await servers[2].sqlCommand.deleteAll('accountVideoRate') | 127 | await servers[2].sql.deleteAll('accountVideoRate') |
128 | 128 | ||
129 | for (const uuid of videoUUIDs) { | 129 | for (const uuid of videoUUIDs) { |
130 | await servers[2].sqlCommand.setVideoField(uuid, 'dislikes', '0') | 130 | await servers[2].sql.setVideoField(uuid, 'dislikes', '0') |
131 | } | 131 | } |
132 | 132 | ||
133 | await wait(5000) | 133 | await wait(5000) |
@@ -135,14 +135,14 @@ describe('Test AP cleaner', function () { | |||
135 | 135 | ||
136 | // Updated rates of my video | 136 | // Updated rates of my video |
137 | { | 137 | { |
138 | const video = await servers[0].videosCommand.get({ id: videoUUID1 }) | 138 | const video = await servers[0].videos.get({ id: videoUUID1 }) |
139 | expect(video.likes).to.equal(0) | 139 | expect(video.likes).to.equal(0) |
140 | expect(video.dislikes).to.equal(2) | 140 | expect(video.dislikes).to.equal(2) |
141 | } | 141 | } |
142 | 142 | ||
143 | // Did not update rates of a remote video | 143 | // Did not update rates of a remote video |
144 | { | 144 | { |
145 | const video = await servers[0].videosCommand.get({ id: videoUUID2 }) | 145 | const video = await servers[0].videos.get({ id: videoUUID2 }) |
146 | expect(video.likes).to.equal(0) | 146 | expect(video.likes).to.equal(0) |
147 | expect(video.dislikes).to.equal(3) | 147 | expect(video.dislikes).to.equal(3) |
148 | } | 148 | } |
@@ -151,15 +151,15 @@ describe('Test AP cleaner', function () { | |||
151 | it('Should destroy server 3 internal shares and correctly clean them', async function () { | 151 | it('Should destroy server 3 internal shares and correctly clean them', async function () { |
152 | this.timeout(20000) | 152 | this.timeout(20000) |
153 | 153 | ||
154 | const preCount = await servers[0].sqlCommand.getCount('videoShare') | 154 | const preCount = await servers[0].sql.getCount('videoShare') |
155 | expect(preCount).to.equal(6) | 155 | expect(preCount).to.equal(6) |
156 | 156 | ||
157 | await servers[2].sqlCommand.deleteAll('videoShare') | 157 | await servers[2].sql.deleteAll('videoShare') |
158 | await wait(5000) | 158 | await wait(5000) |
159 | await waitJobs(servers) | 159 | await waitJobs(servers) |
160 | 160 | ||
161 | // Still 6 because we don't have remote shares on local videos | 161 | // Still 6 because we don't have remote shares on local videos |
162 | const postCount = await servers[0].sqlCommand.getCount('videoShare') | 162 | const postCount = await servers[0].sql.getCount('videoShare') |
163 | expect(postCount).to.equal(6) | 163 | expect(postCount).to.equal(6) |
164 | }) | 164 | }) |
165 | 165 | ||
@@ -167,17 +167,17 @@ describe('Test AP cleaner', function () { | |||
167 | this.timeout(20000) | 167 | this.timeout(20000) |
168 | 168 | ||
169 | { | 169 | { |
170 | const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 }) | 170 | const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 }) |
171 | expect(total).to.equal(3) | 171 | expect(total).to.equal(3) |
172 | } | 172 | } |
173 | 173 | ||
174 | await servers[2].sqlCommand.deleteAll('videoComment') | 174 | await servers[2].sql.deleteAll('videoComment') |
175 | 175 | ||
176 | await wait(5000) | 176 | await wait(5000) |
177 | await waitJobs(servers) | 177 | await waitJobs(servers) |
178 | 178 | ||
179 | { | 179 | { |
180 | const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 }) | 180 | const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 }) |
181 | expect(total).to.equal(2) | 181 | expect(total).to.equal(2) |
182 | } | 182 | } |
183 | }) | 183 | }) |
@@ -188,7 +188,7 @@ describe('Test AP cleaner', function () { | |||
188 | async function check (like: string, ofServerUrl: string, urlSuffix: string, remote: 'true' | 'false') { | 188 | async function check (like: string, ofServerUrl: string, urlSuffix: string, remote: 'true' | 'false') { |
189 | const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` + | 189 | const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` + |
190 | `INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'` | 190 | `INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'` |
191 | const res = await servers[0].sqlCommand.selectQuery(query) | 191 | const res = await servers[0].sql.selectQuery(query) |
192 | 192 | ||
193 | for (const rate of res) { | 193 | for (const rate of res) { |
194 | const matcher = new RegExp(`^${ofServerUrl}/accounts/root/dislikes/\\d+${urlSuffix}$`) | 194 | const matcher = new RegExp(`^${ofServerUrl}/accounts/root/dislikes/\\d+${urlSuffix}$`) |
@@ -217,7 +217,7 @@ describe('Test AP cleaner', function () { | |||
217 | 217 | ||
218 | { | 218 | { |
219 | const query = `UPDATE "accountVideoRate" SET url = url || 'stan'` | 219 | const query = `UPDATE "accountVideoRate" SET url = url || 'stan'` |
220 | await servers[1].sqlCommand.updateQuery(query) | 220 | await servers[1].sql.updateQuery(query) |
221 | 221 | ||
222 | await wait(5000) | 222 | await wait(5000) |
223 | await waitJobs(servers) | 223 | await waitJobs(servers) |
@@ -234,7 +234,7 @@ describe('Test AP cleaner', function () { | |||
234 | const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` + | 234 | const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` + |
235 | `INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'` | 235 | `INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'` |
236 | 236 | ||
237 | const res = await servers[0].sqlCommand.selectQuery(query) | 237 | const res = await servers[0].sql.selectQuery(query) |
238 | 238 | ||
239 | for (const comment of res) { | 239 | for (const comment of res) { |
240 | const matcher = new RegExp(`${ofServerUrl}/videos/watch/${comment.videoUUID}/comments/\\d+${urlSuffix}`) | 240 | const matcher = new RegExp(`${ofServerUrl}/videos/watch/${comment.videoUUID}/comments/\\d+${urlSuffix}`) |
@@ -260,7 +260,7 @@ describe('Test AP cleaner', function () { | |||
260 | 260 | ||
261 | { | 261 | { |
262 | const query = `UPDATE "videoComment" SET url = url || 'kyle'` | 262 | const query = `UPDATE "videoComment" SET url = url || 'kyle'` |
263 | await servers[1].sqlCommand.updateQuery(query) | 263 | await servers[1].sql.updateQuery(query) |
264 | 264 | ||
265 | await wait(5000) | 265 | await wait(5000) |
266 | await waitJobs(servers) | 266 | await waitJobs(servers) |