/* 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,
- PeerTubeServer,
- prepareNotificationsTest,
- 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: PeerTubeServer
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 () {
before(() => {
baseParams = {
- server: server,
+ server,
emails,
socketNotifications: userNotifications,
token: userToken
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 () {
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' })
}
})
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' })
}
})
)
}
- 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' })
})
})