From d23dd9fbfc4d26026352c10f81d2795ceaf2908a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Jul 2021 10:02:54 +0200 Subject: Introduce videos command --- server/tests/api/check-params/videos-history.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'server/tests/api/check-params/videos-history.ts') diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index 0e91fe0a8..1da922a17 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' +import { HttpStatusCode } from '@shared/core-utils' import { checkBadCountPagination, checkBadStartPagination, @@ -10,10 +11,8 @@ import { makePostBodyRequest, makePutBodyRequest, ServerInfo, - setAccessTokensToServers, - uploadVideo -} from '../../../../shared/extra-utils' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' + setAccessTokensToServers +} from '@shared/extra-utils' describe('Test videos history API validator', function () { const myHistoryPath = '/api/v1/users/me/history/videos' @@ -30,10 +29,8 @@ describe('Test videos history API validator', function () { await setAccessTokensToServers([ server ]) - const res = await uploadVideo(server.url, server.accessToken, {}) - const videoUUID = res.body.video.uuid - - watchingPath = '/api/v1/videos/' + videoUUID + '/watching' + const { uuid } = await server.videosCommand.upload() + watchingPath = '/api/v1/videos/' + uuid + '/watching' }) describe('When notifying a user is watching a video', function () { -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/api/check-params/videos-history.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/api/check-params/videos-history.ts') diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index 1da922a17..549c9fa1f 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts @@ -29,7 +29,7 @@ describe('Test videos history API validator', function () { await setAccessTokensToServers([ server ]) - const { uuid } = await server.videosCommand.upload() + const { uuid } = await server.videos.upload() watchingPath = '/api/v1/videos/' + uuid + '/watching' }) -- cgit v1.2.3 From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/api/check-params/videos-history.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/api/check-params/videos-history.ts') diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index 549c9fa1f..3c1f479e4 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts @@ -6,11 +6,11 @@ import { checkBadCountPagination, checkBadStartPagination, cleanupTests, - flushAndRunServer, + createSingleServer, makeGetRequest, makePostBodyRequest, makePutBodyRequest, - ServerInfo, + PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' @@ -18,14 +18,14 @@ describe('Test videos history API validator', function () { const myHistoryPath = '/api/v1/users/me/history/videos' const myHistoryRemove = myHistoryPath + '/remove' let watchingPath: string - let server: ServerInfo + let server: PeerTubeServer // --------------------------------------------------------------- before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) -- cgit v1.2.3 From c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/tests/api/check-params/videos-history.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'server/tests/api/check-params/videos-history.ts') diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index 3c1f479e4..7283a4d28 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { checkBadCountPagination, checkBadStartPagination, @@ -37,7 +37,7 @@ describe('Test videos history API validator', function () { it('Should fail with an unauthenticated user', async function () { const fields = { currentTime: 5 } - await makePutBodyRequest({ url: server.url, path: watchingPath, fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) + await makePutBodyRequest({ url: server.url, path: watchingPath, fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) it('Should fail with an incorrect video id', async function () { @@ -48,7 +48,7 @@ describe('Test videos history API validator', function () { path, fields, token: server.accessToken, - statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 + expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) @@ -61,7 +61,7 @@ describe('Test videos history API validator', function () { path, fields, token: server.accessToken, - statusCodeExpected: HttpStatusCode.NOT_FOUND_404 + expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) @@ -72,7 +72,7 @@ describe('Test videos history API validator', function () { path: watchingPath, fields, token: server.accessToken, - statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 + expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) @@ -84,7 +84,7 @@ describe('Test videos history API validator', function () { path: watchingPath, fields, token: server.accessToken, - statusCodeExpected: HttpStatusCode.NO_CONTENT_204 + expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) }) @@ -99,17 +99,17 @@ describe('Test videos history API validator', function () { }) it('Should fail with an unauthenticated user', async function () { - await makeGetRequest({ url: server.url, path: myHistoryPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) + await makeGetRequest({ url: server.url, path: myHistoryPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) it('Should succeed with the correct params', async function () { - await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, statusCodeExpected: HttpStatusCode.OK_200 }) + await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, expectedStatus: HttpStatusCode.OK_200 }) }) }) describe('When removing user videos history', function () { it('Should fail with an unauthenticated user', async function () { - await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) + await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) it('Should fail with a bad beforeDate parameter', async function () { @@ -119,7 +119,7 @@ describe('Test videos history API validator', function () { token: server.accessToken, path: myHistoryRemove, fields: body, - statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 + expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) @@ -130,7 +130,7 @@ describe('Test videos history API validator', function () { token: server.accessToken, path: myHistoryRemove, fields: body, - statusCodeExpected: HttpStatusCode.NO_CONTENT_204 + expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) @@ -139,7 +139,7 @@ describe('Test videos history API validator', function () { url: server.url, token: server.accessToken, path: myHistoryRemove, - statusCodeExpected: HttpStatusCode.NO_CONTENT_204 + expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) }) -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/tests/api/check-params/videos-history.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/api/check-params/videos-history.ts') diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index 7283a4d28..c3c309ed2 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import { HttpStatusCode } from '@shared/models' import { checkBadCountPagination, checkBadStartPagination, @@ -13,6 +12,7 @@ import { PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' +import { HttpStatusCode } from '@shared/models' describe('Test videos history API validator', function () { const myHistoryPath = '/api/v1/users/me/history/videos' -- cgit v1.2.3