X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fuser-notifications.ts;h=6a588e4460a585ea056b67feded539289d1a40c3;hb=458685e0d039a0ad3fa4f26d99746f7d6d0b40e9;hp=913eca36691eab115608bdf87ddbd3ee8079b3d8;hpb=6c5065a011b099618681a37bd77eaa7bd3db752e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 913eca366..6a588e446 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts @@ -1,32 +1,28 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' import { io } from 'socket.io-client' -import { HttpStatusCode } from '@shared/core-utils' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' +import { wait } from '@shared/core-utils' +import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models' import { - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination, cleanupTests, - flushAndRunServer, + createSingleServer, makeGetRequest, makePostBodyRequest, makePutBodyRequest, - ServerInfo, - setAccessTokensToServers, - wait -} from '@shared/extra-utils' -import { UserNotificationSetting, UserNotificationSettingValue } from '@shared/models' + PeerTubeServer, + setAccessTokensToServers +} from '@shared/server-commands' describe('Test user notifications API validators', function () { - let server: ServerInfo + let server: PeerTubeServer // --------------------------------------------------------------- before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) }) @@ -54,7 +50,7 @@ describe('Test user notifications API validators', function () { unread: 'toto' }, token: server.accessToken, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) }) @@ -62,7 +58,7 @@ describe('Test user notifications API validators', function () { await makeGetRequest({ url: server.url, path, - statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 + expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -71,7 +67,7 @@ describe('Test user notifications API validators', function () { url: server.url, path, token: server.accessToken, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) }) }) @@ -87,7 +83,7 @@ describe('Test user notifications API validators', function () { ids: [ 'hello' ] }, token: server.accessToken, - statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 + expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) await makePostBodyRequest({ @@ -97,7 +93,7 @@ describe('Test user notifications API validators', function () { ids: [ ] }, token: server.accessToken, - statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 + expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) await makePostBodyRequest({ @@ -107,7 +103,7 @@ describe('Test user notifications API validators', function () { ids: 5 }, token: server.accessToken, - statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 + expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) @@ -118,7 +114,7 @@ describe('Test user notifications API validators', function () { fields: { ids: [ 5 ] }, - statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 + expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -130,7 +126,7 @@ describe('Test user notifications API validators', function () { ids: [ 5 ] }, token: server.accessToken, - statusCodeExpected: HttpStatusCode.NO_CONTENT_204 + expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) }) @@ -142,7 +138,7 @@ describe('Test user notifications API validators', function () { await makePostBodyRequest({ url: server.url, path, - statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 + expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -151,7 +147,7 @@ describe('Test user notifications API validators', function () { url: server.url, path, token: server.accessToken, - statusCodeExpected: HttpStatusCode.NO_CONTENT_204 + expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) }) @@ -174,6 +170,7 @@ describe('Test user notifications API validators', function () { abuseNewMessage: UserNotificationSettingValue.WEB, abuseStateChange: UserNotificationSettingValue.WEB, newPeerTubeVersion: UserNotificationSettingValue.WEB, + myVideoStudioEditionFinished: UserNotificationSettingValue.WEB, newPluginVersion: UserNotificationSettingValue.WEB } @@ -183,7 +180,7 @@ describe('Test user notifications API validators', function () { path, token: server.accessToken, fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB }, - statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 + expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) @@ -196,7 +193,7 @@ describe('Test user notifications API validators', function () { path, token: server.accessToken, fields, - statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 + expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) } @@ -208,7 +205,7 @@ describe('Test user notifications API validators', function () { path, fields, token: server.accessToken, - statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 + expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) } }) @@ -218,7 +215,7 @@ describe('Test user notifications API validators', function () { url: server.url, path, fields: correctFields, - statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 + expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -228,7 +225,7 @@ describe('Test user notifications API validators', function () { path, token: server.accessToken, fields: correctFields, - statusCodeExpected: HttpStatusCode.NO_CONTENT_204 + expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) }) @@ -236,7 +233,7 @@ describe('Test user notifications API validators', function () { describe('When connecting to my notification socket', function () { it('Should fail with no token', function (next) { - const socket = io(`http://localhost:${server.port}/user-notifications`, { reconnection: false }) + const socket = io(`${server.url}/user-notifications`, { reconnection: false }) socket.once('connect_error', function () { socket.disconnect() @@ -250,7 +247,7 @@ describe('Test user notifications API validators', function () { }) it('Should fail with an invalid token', function (next) { - const socket = io(`http://localhost:${server.port}/user-notifications`, { + const socket = io(`${server.url}/user-notifications`, { query: { accessToken: 'bad_access_token' }, reconnection: false }) @@ -267,7 +264,7 @@ describe('Test user notifications API validators', function () { }) it('Should success with the correct token', function (next) { - const socket = io(`http://localhost:${server.port}/user-notifications`, { + const socket = io(`${server.url}/user-notifications`, { query: { accessToken: server.accessToken }, reconnection: false })