From 59bbcced37005dd511daca9bd58ae2998cb931b1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:19:16 +0200 Subject: Centralize test URLs --- server/tests/api/check-params/upload-quota.ts | 6 +++--- server/tests/api/check-params/video-imports.ts | 6 +++--- server/tests/api/moderation/video-blacklist.ts | 8 ++++---- server/tests/api/notifications/user-notifications.ts | 16 ++++++++-------- server/tests/api/videos/video-imports.ts | 18 +++++++++--------- server/tests/cli/peertube.ts | 8 ++++---- server/tests/helpers/request.ts | 10 +++++----- server/tests/plugins/filter-hooks.ts | 12 ++++++------ 8 files changed, 42 insertions(+), 42 deletions(-) (limited to 'server') diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts index 2c73e6a19..bd8dce975 100644 --- a/server/tests/api/check-params/upload-quota.ts +++ b/server/tests/api/check-params/upload-quota.ts @@ -6,7 +6,7 @@ import { HttpStatusCode, randomInt } from '@shared/core-utils' import { cleanupTests, createSingleServer, - ImportsCommand, + FIXTURE_URLS, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, @@ -76,8 +76,8 @@ describe('Test upload quota', function () { channelId: server.store.channel.id, privacy: VideoPrivacy.PUBLIC } - await server.imports.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } }) - await server.imports.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } }) + await server.imports.importVideo({ attributes: { ...baseAttributes, targetUrl: FIXTURE_URLS.goodVideo } }) + await server.imports.importVideo({ attributes: { ...baseAttributes, magnetUri: FIXTURE_URLS.magnet } }) await server.imports.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } }) await waitJobs([ server ]) diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 627f0c7ad..0209275ac 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts @@ -10,7 +10,7 @@ import { checkBadStartPagination, cleanupTests, createSingleServer, - ImportsCommand, + FIXTURE_URLS, makeGetRequest, makePostBodyRequest, makeUploadRequest, @@ -70,7 +70,7 @@ describe('Test video imports API validator', function () { before(function () { baseCorrectParams = { - targetUrl: ImportsCommand.getGoodVideoUrl(), + targetUrl: FIXTURE_URLS.goodVideo, name: 'my super name', category: 5, licence: 1, @@ -297,7 +297,7 @@ describe('Test video imports API validator', function () { }) let fields = omit(baseCorrectParams, 'targetUrl') - fields = { ...fields, magnetUri: ImportsCommand.getMagnetURI() } + fields = { ...fields, magnetUri: FIXTURE_URLS.magnet } await makePostBodyRequest({ url: server.url, diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts index 62cbf2e07..d5838191a 100644 --- a/server/tests/api/moderation/video-blacklist.ts +++ b/server/tests/api/moderation/video-blacklist.ts @@ -6,9 +6,9 @@ import { orderBy } from 'lodash' import { BlacklistCommand, cleanupTests, - doubleFollow, createMultipleServers, - ImportsCommand, + doubleFollow, + FIXTURE_URLS, killallServers, PeerTubeServer, setAccessTokensToServers, @@ -387,7 +387,7 @@ describe('Test video blacklist', function () { this.timeout(15000) const attributes = { - targetUrl: ImportsCommand.getGoodVideoUrl(), + targetUrl: FIXTURE_URLS.goodVideo, name: 'URL import', channelId: channelOfUserWithoutFlag } @@ -400,7 +400,7 @@ describe('Test video blacklist', function () { it('Should auto blacklist a video on torrent import', async function () { const attributes = { - magnetUri: ImportsCommand.getMagnetURI(), + magnetUri: FIXTURE_URLS.magnet, name: 'Torrent import', channelId: channelOfUserWithoutFlag } diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index b7c22d118..ca592d466 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -10,10 +10,10 @@ import { checkNewVideoFromSubscription, checkVideoIsPublished, cleanupTests, - ImportsCommand, + FIXTURE_URLS, MockSmtpServer, - prepareNotificationsTest, PeerTubeServer, + prepareNotificationsTest, uploadRandomVideoOnServers, wait, waitJobs @@ -205,7 +205,7 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PUBLIC, - targetUrl: ImportsCommand.getGoodVideoUrl() + targetUrl: FIXTURE_URLS.goodVideo } const { video } = await servers[0].imports.importVideo({ attributes }) @@ -275,7 +275,7 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PUBLIC, - targetUrl: ImportsCommand.getGoodVideoUrl(), + targetUrl: FIXTURE_URLS.goodVideo, waitTranscoding: true } const { video } = await servers[1].imports.importVideo({ attributes }) @@ -343,12 +343,12 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PRIVATE, - targetUrl: ImportsCommand.getBadVideoUrl() + targetUrl: FIXTURE_URLS.badVideo } const { video } = await servers[0].imports.importVideo({ attributes }) await waitJobs(servers) - await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence') + await checkMyVideoImportIsFinished(baseParams, name, video.uuid, FIXTURE_URLS.badVideo, false, 'presence') }) it('Should send a notification when the video import succeeded', async function () { @@ -360,12 +360,12 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PRIVATE, - targetUrl: ImportsCommand.getGoodVideoUrl() + targetUrl: FIXTURE_URLS.goodVideo } const { video } = await servers[0].imports.importVideo({ attributes }) await waitJobs(servers) - await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence') + await checkMyVideoImportIsFinished(baseParams, name, video.uuid, FIXTURE_URLS.goodVideo, true, 'presence') }) }) diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index 4ef55c3af..192f5232e 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts @@ -5,9 +5,9 @@ import * as chai from 'chai' import { areHttpImportTestsDisabled, cleanupTests, - doubleFollow, createMultipleServers, - ImportsCommand, + doubleFollow, + FIXTURE_URLS, PeerTubeServer, setAccessTokensToServers, testCaptionFile, @@ -110,7 +110,7 @@ describe('Test video imports', function () { } { - const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() } + const attributes = { ...baseAttributes, targetUrl: FIXTURE_URLS.youtube } const { video } = await servers[0].imports.importVideo({ attributes }) expect(video.name).to.equal('small video - youtube') @@ -162,7 +162,7 @@ Ajouter un sous-titre est vraiment facile`) { const attributes = { ...baseAttributes, - magnetUri: ImportsCommand.getMagnetURI(), + magnetUri: FIXTURE_URLS.magnet, description: 'this is a super torrent description', tags: [ 'tag_torrent1', 'tag_torrent2' ] } @@ -199,13 +199,13 @@ Ajouter un sous-titre est vraiment facile`) expect(videoImports).to.have.lengthOf(3) - expect(videoImports[2].targetUrl).to.equal(ImportsCommand.getYoutubeVideoUrl()) + expect(videoImports[2].targetUrl).to.equal(FIXTURE_URLS.youtube) expect(videoImports[2].magnetUri).to.be.null expect(videoImports[2].torrentName).to.be.null expect(videoImports[2].video.name).to.equal('small video - youtube') expect(videoImports[1].targetUrl).to.be.null - expect(videoImports[1].magnetUri).to.equal(ImportsCommand.getMagnetURI()) + expect(videoImports[1].magnetUri).to.equal(FIXTURE_URLS.magnet) expect(videoImports[1].torrentName).to.be.null expect(videoImports[1].video.name).to.equal('super peertube2 video') @@ -234,7 +234,7 @@ Ajouter un sous-titre est vraiment facile`) this.timeout(60_000) const attributes = { - targetUrl: ImportsCommand.getYoutubeVideoUrl(), + targetUrl: FIXTURE_URLS.youtube, channelId: channelIdServer2, privacy: VideoPrivacy.PUBLIC, category: 10, @@ -270,7 +270,7 @@ Ajouter un sous-titre est vraiment facile`) const attributes = { name: 'transcoded video', - magnetUri: ImportsCommand.getMagnetURI(), + magnetUri: FIXTURE_URLS.magnet, channelId: channelIdServer2, privacy: VideoPrivacy.PUBLIC } @@ -320,7 +320,7 @@ Ajouter un sous-titre est vraiment facile`) const attributes = { name: 'hdr video', - targetUrl: ImportsCommand.getYoutubeHDRVideoUrl(), + targetUrl: FIXTURE_URLS.youtubeHDR, channelId: channelIdServer1, privacy: VideoPrivacy.PUBLIC } diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index f19b6ae22..f2a984962 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -7,9 +7,9 @@ import { buildAbsoluteFixturePath, cleanupTests, CLICommand, - doubleFollow, createSingleServer, - ImportsCommand, + doubleFollow, + FIXTURE_URLS, PeerTubeServer, setAccessTokensToServers, testHelloWorldRegisteredSettings, @@ -117,7 +117,7 @@ describe('Test CLI wrapper', function () { this.timeout(60000) - const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} --channel-name user_channel` + const params = `--target-url ${FIXTURE_URLS.youtube} --channel-name user_channel` await cliCommand.execWithEnv(`${cmd} import ${params}`) }) @@ -148,7 +148,7 @@ describe('Test CLI wrapper', function () { this.timeout(60000) - const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} ` + + const params = `--target-url ${FIXTURE_URLS.youtube} ` + `--channel-name user_channel --video-name toto --nsfw --support support` await cliCommand.execWithEnv(`${cmd} import ${params}`) diff --git a/server/tests/helpers/request.ts b/server/tests/helpers/request.ts index 5e77f129e..7f7873df3 100644 --- a/server/tests/helpers/request.ts +++ b/server/tests/helpers/request.ts @@ -4,7 +4,7 @@ import 'mocha' import { expect } from 'chai' import { pathExists, remove } from 'fs-extra' import { join } from 'path' -import { get4KFileUrl, root, wait } from '../../../shared/extra-utils' +import { FIXTURE_URLS, root, wait } from '../../../shared/extra-utils' import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' describe('Request helpers', function () { @@ -13,7 +13,7 @@ describe('Request helpers', function () { it('Should throw an error when the bytes limit is exceeded for request', async function () { try { - await doRequest(get4KFileUrl(), { bodyKBLimit: 3 }) + await doRequest(FIXTURE_URLS.video4K, { bodyKBLimit: 3 }) } catch { return } @@ -23,7 +23,7 @@ describe('Request helpers', function () { it('Should throw an error when the bytes limit is exceeded for request and save file', async function () { try { - await doRequestAndSaveToFile(get4KFileUrl(), destPath1, { bodyKBLimit: 3 }) + await doRequestAndSaveToFile(FIXTURE_URLS.video4K, destPath1, { bodyKBLimit: 3 }) } catch { await wait(500) @@ -35,8 +35,8 @@ describe('Request helpers', function () { }) it('Should succeed if the file is below the limit', async function () { - await doRequest(get4KFileUrl(), { bodyKBLimit: 5 }) - await doRequestAndSaveToFile(get4KFileUrl(), destPath2, { bodyKBLimit: 5 }) + await doRequest(FIXTURE_URLS.video4K, { bodyKBLimit: 5 }) + await doRequestAndSaveToFile(FIXTURE_URLS.video4K, destPath2, { bodyKBLimit: 5 }) expect(await pathExists(destPath2)).to.be.true }) diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 5d94303a9..df52bb3b5 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -5,12 +5,12 @@ import * as chai from 'chai' import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, - doubleFollow, createMultipleServers, - ImportsCommand, + doubleFollow, + FIXTURE_URLS, makeRawRequest, - PluginsCommand, PeerTubeServer, + PluginsCommand, setAccessTokensToServers, setDefaultVideoChannel, waitJobs @@ -136,7 +136,7 @@ describe('Test plugin filter hooks', function () { name: 'normal title', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].store.channel.id, - targetUrl: ImportsCommand.getGoodVideoUrl() + 'bad' + targetUrl: FIXTURE_URLS.goodVideo + 'bad' } await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) @@ -161,7 +161,7 @@ describe('Test plugin filter hooks', function () { name: 'title with bad word', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].store.channel.id, - targetUrl: ImportsCommand.getGoodVideoUrl() + targetUrl: FIXTURE_URLS.goodVideo } const body = await servers[0].imports.importVideo({ attributes }) videoImportId = body.id @@ -273,7 +273,7 @@ describe('Test plugin filter hooks', function () { const attributes = { name: 'video please blacklist me', - targetUrl: ImportsCommand.getGoodVideoUrl(), + targetUrl: FIXTURE_URLS.goodVideo, channelId: servers[0].store.channel.id } const body = await servers[0].imports.importVideo({ attributes }) -- cgit v1.2.3