]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/notifications/admin-notifications.ts
shared/ typescript types dir server-commands
[github/Chocobozzz/PeerTube.git] / server / tests / api / notifications / admin-notifications.ts
index 91681c9d6ad15b52d7f3ccc9c04731c8e89822c2..18962a71e77363f4ce4d155a20352907fcff4ab9 100644 (file)
@@ -2,21 +2,21 @@
 
 import 'mocha'
 import { expect } from 'chai'
-import { MockJoinPeerTubeVersions } from '@shared/extra-utils'
-import { PluginType } from '@shared/models'
-import { cleanupTests, installPlugin, setPluginLatestVersion, setPluginVersion, wait } from '../../../../shared/extra-utils'
-import { ServerInfo } from '../../../../shared/extra-utils/index'
-import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email'
 import {
   CheckerBaseParams,
   checkNewPeerTubeVersion,
   checkNewPluginVersion,
-  prepareNotificationsTest
-} from '../../../../shared/extra-utils/users/user-notifications'
-import { UserNotification, UserNotificationType } from '../../../../shared/models/users'
+  cleanupTests,
+  MockJoinPeerTubeVersions,
+  MockSmtpServer,
+  PeerTubeServer,
+  prepareNotificationsTest,
+  wait
+} from '@shared/server-commands'
+import { PluginType, UserNotification, UserNotificationType } from '@shared/models'
 
 describe('Test admin notifications', function () {
-  let server: ServerInfo
+  let server: PeerTubeServer
   let userNotifications: UserNotification[] = []
   let adminNotifications: UserNotification[] = []
   let emails: object[] = []
@@ -58,17 +58,8 @@ describe('Test admin notifications', function () {
       token: server.accessToken
     }
 
-    await installPlugin({
-      url: server.url,
-      accessToken: server.accessToken,
-      npmName: 'peertube-plugin-hello-world'
-    })
-
-    await installPlugin({
-      url: server.url,
-      accessToken: server.accessToken,
-      npmName: 'peertube-theme-background-red'
-    })
+    await server.plugins.install({ npmName: 'peertube-plugin-hello-world' })
+    await server.plugins.install({ npmName: 'peertube-theme-background-red' })
   })
 
   describe('Latest PeerTube version notification', function () {
@@ -79,7 +70,7 @@ describe('Test admin notifications', function () {
       joinPeerTubeServer.setLatestVersion('1.4.2')
 
       await wait(3000)
-      await checkNewPeerTubeVersion(baseParams, '1.4.2', 'absence')
+      await checkNewPeerTubeVersion({ ...baseParams, latestVersion: '1.4.2', checkType: 'absence' })
     })
 
     it('Should send a notification to admins on new plugin version', async function () {
@@ -88,7 +79,7 @@ describe('Test admin notifications', function () {
       joinPeerTubeServer.setLatestVersion('15.4.2')
 
       await wait(3000)
-      await checkNewPeerTubeVersion(baseParams, '15.4.2', 'presence')
+      await checkNewPeerTubeVersion({ ...baseParams, latestVersion: '15.4.2', checkType: 'presence' })
     })
 
     it('Should not send the same notification to admins', async function () {
@@ -110,7 +101,7 @@ describe('Test admin notifications', function () {
       joinPeerTubeServer.setLatestVersion('15.4.3')
 
       await wait(3000)
-      await checkNewPeerTubeVersion(baseParams, '15.4.3', 'presence')
+      await checkNewPeerTubeVersion({ ...baseParams, latestVersion: '15.4.3', checkType: 'presence' })
       expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2)
     })
   })
@@ -121,17 +112,17 @@ describe('Test admin notifications', function () {
       this.timeout(30000)
 
       await wait(6000)
-      await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'absence')
+      await checkNewPluginVersion({ ...baseParams, pluginType: PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'absence' })
     })
 
     it('Should send a notification to admins on new plugin version', async function () {
       this.timeout(30000)
 
-      await setPluginVersion(server.internalServerNumber, 'hello-world', '0.0.1')
-      await setPluginLatestVersion(server.internalServerNumber, 'hello-world', '0.0.1')
+      await server.sql.setPluginVersion('hello-world', '0.0.1')
+      await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
       await wait(6000)
 
-      await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'presence')
+      await checkNewPluginVersion({ ...baseParams, pluginType: PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'presence' })
     })
 
     it('Should not send the same notification to admins', async function () {
@@ -149,8 +140,8 @@ describe('Test admin notifications', function () {
     it('Should send a new notification after a new plugin release', async function () {
       this.timeout(30000)
 
-      await setPluginVersion(server.internalServerNumber, 'hello-world', '0.0.1')
-      await setPluginLatestVersion(server.internalServerNumber, 'hello-world', '0.0.1')
+      await server.sql.setPluginVersion('hello-world', '0.0.1')
+      await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
       await wait(6000)
 
       expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2)