X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Factivitypub%2Frefresher.ts;h=f295dfab76a4e879d52e90fa5e8d93740e679971;hb=e6346d59e63135cf012ed18c102d3b0179ef565f;hp=232c5d82341a75d3754aaea140c3319a3af4edf1;hpb=4c1def5fd8e9f483238eb38e221f555e2e6bbf07;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts index 232c5d823..f295dfab7 100644 --- a/server/tests/api/activitypub/refresher.ts +++ b/server/tests/api/activitypub/refresher.ts @@ -1,14 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' +import { HttpStatusCode } from '@shared/core-utils' import { - cleanupTests, closeAllSequelize, - createVideoPlaylist, + cleanupTests, + closeAllSequelize, doubleFollow, flushAndRunMultipleServers, generateUserAccessToken, getVideo, - getVideoPlaylist, killallServers, reRunServer, ServerInfo, @@ -21,9 +21,8 @@ import { uploadVideoAndGetId, wait, waitJobs -} from '../../../../shared/extra-utils' -import { getAccount } from '../../../../shared/extra-utils/users/accounts' -import { VideoPlaylistPrivacy } from '../../../../shared/models/videos' +} from '@shared/extra-utils' +import { VideoPlaylistPrivacy } from '@shared/models' describe('Test AP refresher', function () { let servers: ServerInfo[] = [] @@ -57,15 +56,15 @@ describe('Test AP refresher', function () { } { - const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } - const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs }) - playlistUUID1 = res.body.videoPlaylist.uuid + const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } + const created = await servers[1].playlistsCommand.create({ attributes }) + playlistUUID1 = created.uuid } { - const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } - const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs }) - playlistUUID2 = res.body.videoPlaylist.uuid + const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } + const created = await servers[1].playlistsCommand.create({ attributes }) + playlistUUID2 = created.uuid } await doubleFollow(servers[0], servers[1]) @@ -86,8 +85,8 @@ describe('Test AP refresher', function () { await waitJobs(servers) - await getVideo(servers[0].url, videoUUID1, 404) - await getVideo(servers[0].url, videoUUID2, 200) + await getVideo(servers[0].url, videoUUID1, HttpStatusCode.NOT_FOUND_404) + await getVideo(servers[0].url, videoUUID2, HttpStatusCode.OK_200) }) it('Should not update a remote video if the remote instance is down', async function () { @@ -106,7 +105,7 @@ describe('Test AP refresher', function () { await reRunServer(servers[1]) - await getVideo(servers[0].url, videoUUID3, 200) + await getVideo(servers[0].url, videoUUID3, HttpStatusCode.OK_200) }) }) @@ -115,19 +114,21 @@ describe('Test AP refresher', function () { it('Should remove a deleted actor', async function () { this.timeout(60000) + const command = servers[0].accountsCommand + await wait(10000) // Change actor name so the remote server returns a 404 const to = 'http://localhost:' + servers[1].port + '/accounts/user2' await setActorField(servers[1].internalServerNumber, to, 'preferredUsername', 'toto') - await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port) - await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port) + await command.get({ accountName: 'user1@localhost:' + servers[1].port }) + await command.get({ accountName: 'user2@localhost:' + servers[1].port }) await waitJobs(servers) - await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port, 200) - await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port, 404) + await command.get({ accountName: 'user1@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.OK_200 }) + await command.get({ accountName: 'user2@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) }) @@ -141,13 +142,13 @@ describe('Test AP refresher', function () { // Change UUID so the remote server returns a 404 await setPlaylistField(servers[1].internalServerNumber, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e') - await getVideoPlaylist(servers[0].url, playlistUUID1) - await getVideoPlaylist(servers[0].url, playlistUUID2) + await servers[0].playlistsCommand.get({ playlistId: playlistUUID1 }) + await servers[0].playlistsCommand.get({ playlistId: playlistUUID2 }) await waitJobs(servers) - await getVideoPlaylist(servers[0].url, playlistUUID1, 200) - await getVideoPlaylist(servers[0].url, playlistUUID2, 404) + await servers[0].playlistsCommand.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 }) + await servers[0].playlistsCommand.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) })