X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideos-overview.ts;h=c012d47c3fd6b1010bce894f1d1599b0c291b97d;hb=b1dbb9fefc870a90b25f5c0153589f45c9e75e3e;hp=969393842e86adedf8f955809c46c4832c3131a2;hpb=d23dd9fbfc4d26026352c10f81d2795ceaf2908a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index 969393842..c012d47c3 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts @@ -1,14 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' -import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, wait } from '@shared/extra-utils' +import { expect } from 'chai' +import { wait } from '@shared/core-utils' import { VideosOverview } from '@shared/models' - -const expect = chai.expect +import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' describe('Test a videos overview', function () { - let server: ServerInfo = null + let server: PeerTubeServer = null function testOverviewCount (overview: VideosOverview, expected: number) { expect(overview.tags).to.have.lengthOf(expected) @@ -19,13 +17,13 @@ describe('Test a videos overview', function () { before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) }) it('Should send empty overview', async function () { - const body = await server.overviewsCommand.getVideos({ page: 1 }) + const body = await server.overviews.getVideos({ page: 1 }) testOverviewCount(body, 0) }) @@ -35,7 +33,7 @@ describe('Test a videos overview', function () { await wait(3000) - await server.videosCommand.upload({ + await server.videos.upload({ attributes: { name: 'video 0', category: 3, @@ -43,7 +41,7 @@ describe('Test a videos overview', function () { } }) - const body = await server.overviewsCommand.getVideos({ page: 1 }) + const body = await server.overviews.getVideos({ page: 1 }) testOverviewCount(body, 0) }) @@ -53,7 +51,7 @@ describe('Test a videos overview', function () { { for (let i = 1; i < 6; i++) { - await server.videosCommand.upload({ + await server.videos.upload({ attributes: { name: 'video ' + i, category: 3, @@ -66,13 +64,13 @@ describe('Test a videos overview', function () { } { - const body = await server.overviewsCommand.getVideos({ page: 1 }) + const body = await server.overviews.getVideos({ page: 1 }) testOverviewCount(body, 1) } { - const overview = await server.overviewsCommand.getVideos({ page: 2 }) + const overview = await server.overviews.getVideos({ page: 2 }) expect(overview.tags).to.have.lengthOf(1) expect(overview.categories).to.have.lengthOf(0) @@ -81,8 +79,8 @@ describe('Test a videos overview', function () { }) it('Should have the correct overview', async function () { - const overview1 = await server.overviewsCommand.getVideos({ page: 1 }) - const overview2 = await server.overviewsCommand.getVideos({ page: 2 }) + const overview1 = await server.overviews.getVideos({ page: 1 }) + const overview2 = await server.overviews.getVideos({ page: 2 }) for (const arr of [ overview1.tags, overview1.categories, overview1.channels, overview2.tags ]) { expect(arr).to.have.lengthOf(1) @@ -108,18 +106,18 @@ describe('Test a videos overview', function () { }) it('Should hide muted accounts', async function () { - const token = await server.usersCommand.generateUserAndToken('choco') + const token = await server.users.generateUserAndToken('choco') - await server.blocklistCommand.addToMyBlocklist({ token, account: 'root@' + server.host }) + await server.blocklist.addToMyBlocklist({ token, account: 'root@' + server.host }) { - const body = await server.overviewsCommand.getVideos({ page: 1 }) + const body = await server.overviews.getVideos({ page: 1 }) testOverviewCount(body, 1) } { - const body = await server.overviewsCommand.getVideos({ page: 1, token }) + const body = await server.overviews.getVideos({ page: 1, token }) testOverviewCount(body, 0) }