]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/notifications/admin-notifications.ts
Added "total views" in the my channels list (#5007)
[github/Chocobozzz/PeerTube.git] / server / tests / api / notifications / admin-notifications.ts
index da9767b7401098a955ae949fc6c85170abe88e0d..f037e7aaec29ceb2487b6b7da7e0862328e5ed77 100644 (file)
@@ -6,19 +6,16 @@ import {
   CheckerBaseParams,
   checkNewPeerTubeVersion,
   checkNewPluginVersion,
-  cleanupTests,
   MockJoinPeerTubeVersions,
   MockSmtpServer,
-  prepareNotificationsTest,
-  ServerInfo,
-  setPluginLatestVersion,
-  setPluginVersion,
-  wait
-} from '@shared/extra-utils'
+  prepareNotificationsTest
+} from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
 import { PluginType, UserNotification, UserNotificationType } from '@shared/models'
+import { cleanupTests, PeerTubeServer } from '@shared/server-commands'
 
 describe('Test admin notifications', function () {
-  let server: ServerInfo
+  let server: PeerTubeServer
   let userNotifications: UserNotification[] = []
   let adminNotifications: UserNotification[] = []
   let emails: object[] = []
@@ -60,8 +57,8 @@ describe('Test admin notifications', function () {
       token: server.accessToken
     }
 
-    await server.pluginsCommand.install({ npmName: 'peertube-plugin-hello-world' })
-    await server.pluginsCommand.install({ 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 () {
@@ -72,7 +69,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 () {
@@ -81,7 +78,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 () {
@@ -103,7 +100,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)
     })
   })
@@ -114,17 +111,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 () {
@@ -142,8 +139,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)