X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fnotifications%2Fnotifications-api.ts;h=f194656c9f8b1eb684812e5f7b53489dd486b340;hb=aac7f4304dc7fa48869cb3f09c30383222add436;hp=647d783b54e055894844db116405a6c86c404ff0;hpb=89d241a79c262b9775c233b73cff080043ebb5e6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index 647d783b5..f194656c9 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -1,23 +1,18 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' +import { expect } from 'chai' import { CheckerBaseParams, checkNewVideoFromSubscription, - cleanupTests, getAllNotificationsSettings, MockSmtpServer, - prepareNotificationsTest, - ServerInfo, - waitJobs -} from '@shared/extra-utils' + prepareNotificationsTest +} from '@server/tests/shared' import { UserNotification, UserNotificationSettingValue } from '@shared/models' - -const expect = chai.expect +import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' describe('Test notifications API', function () { - let server: ServerInfo + let server: PeerTubeServer let userNotifications: UserNotification[] = [] let userToken: string let emails: object[] = [] @@ -40,6 +35,16 @@ describe('Test notifications API', function () { await waitJobs([ server ]) }) + describe('Notification list & count', function () { + + it('Should correctly list notifications', async function () { + const { data, total } = await server.notifications.list({ token: userToken, start: 0, count: 2 }) + + expect(data).to.have.lengthOf(2) + expect(total).to.equal(10) + }) + }) + describe('Mark as read', function () { it('Should mark as read some notifications', async function () { @@ -91,7 +96,7 @@ describe('Test notifications API', function () { before(() => { baseParams = { - server: server, + server, emails, socketNotifications: userNotifications, token: userToken @@ -111,10 +116,10 @@ describe('Test notifications API', function () { expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE) } - const { name, uuid } = await server.videos.randomUpload() + const { name, shortUUID } = await server.videos.randomUpload() const check = { web: true, mail: true } - await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') + await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'absence' }) }) it('Should only have web notifications', async function () { @@ -130,16 +135,16 @@ describe('Test notifications API', function () { expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB) } - const { name, uuid } = await server.videos.randomUpload() + const { name, shortUUID } = await server.videos.randomUpload() { const check = { mail: true, web: false } - await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') + await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'absence' }) } { const check = { mail: false, web: true } - await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence') + await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'presence' }) } }) @@ -156,16 +161,16 @@ describe('Test notifications API', function () { expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL) } - const { name, uuid } = await server.videos.randomUpload() + const { name, shortUUID } = await server.videos.randomUpload() { const check = { mail: false, web: true } - await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') + await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'absence' }) } { const check = { mail: true, web: false } - await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence') + await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'presence' }) } }) @@ -187,9 +192,9 @@ describe('Test notifications API', function () { ) } - const { name, uuid } = await server.videos.randomUpload() + const { name, shortUUID } = await server.videos.randomUpload() - await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') + await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) }) })