diff options
Diffstat (limited to 'server/tests/api/notifications/admin-notifications.ts')
-rw-r--r-- | server/tests/api/notifications/admin-notifications.ts | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index cfe0bd2bb..c00d4e257 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts | |||
@@ -2,21 +2,21 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { MockJoinPeerTubeVersions } from '@shared/extra-utils/mock-servers/joinpeertube-versions' | ||
6 | import { PluginType } from '@shared/models' | ||
7 | import { cleanupTests, installPlugin, setPluginLatestVersion, setPluginVersion, wait } from '../../../../shared/extra-utils' | ||
8 | import { ServerInfo } from '../../../../shared/extra-utils/index' | ||
9 | import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' | ||
10 | import { | 5 | import { |
11 | CheckerBaseParams, | 6 | CheckerBaseParams, |
12 | checkNewPeerTubeVersion, | 7 | checkNewPeerTubeVersion, |
13 | checkNewPluginVersion, | 8 | checkNewPluginVersion, |
14 | prepareNotificationsTest | 9 | cleanupTests, |
15 | } from '../../../../shared/extra-utils/users/user-notifications' | 10 | MockJoinPeerTubeVersions, |
16 | import { UserNotification, UserNotificationType } from '../../../../shared/models/users' | 11 | MockSmtpServer, |
12 | PeerTubeServer, | ||
13 | prepareNotificationsTest, | ||
14 | wait | ||
15 | } from '@shared/extra-utils' | ||
16 | import { PluginType, UserNotification, UserNotificationType } from '@shared/models' | ||
17 | 17 | ||
18 | describe('Test admin notifications', function () { | 18 | describe('Test admin notifications', function () { |
19 | let server: ServerInfo | 19 | let server: PeerTubeServer |
20 | let userNotifications: UserNotification[] = [] | 20 | let userNotifications: UserNotification[] = [] |
21 | let adminNotifications: UserNotification[] = [] | 21 | let adminNotifications: UserNotification[] = [] |
22 | let emails: object[] = [] | 22 | let emails: object[] = [] |
@@ -58,17 +58,8 @@ describe('Test admin notifications', function () { | |||
58 | token: server.accessToken | 58 | token: server.accessToken |
59 | } | 59 | } |
60 | 60 | ||
61 | await installPlugin({ | 61 | await server.plugins.install({ npmName: 'peertube-plugin-hello-world' }) |
62 | url: server.url, | 62 | await server.plugins.install({ npmName: 'peertube-theme-background-red' }) |
63 | accessToken: server.accessToken, | ||
64 | npmName: 'peertube-plugin-hello-world' | ||
65 | }) | ||
66 | |||
67 | await installPlugin({ | ||
68 | url: server.url, | ||
69 | accessToken: server.accessToken, | ||
70 | npmName: 'peertube-theme-background-red' | ||
71 | }) | ||
72 | }) | 63 | }) |
73 | 64 | ||
74 | describe('Latest PeerTube version notification', function () { | 65 | describe('Latest PeerTube version notification', function () { |
@@ -79,7 +70,7 @@ describe('Test admin notifications', function () { | |||
79 | joinPeerTubeServer.setLatestVersion('1.4.2') | 70 | joinPeerTubeServer.setLatestVersion('1.4.2') |
80 | 71 | ||
81 | await wait(3000) | 72 | await wait(3000) |
82 | await checkNewPeerTubeVersion(baseParams, '1.4.2', 'absence') | 73 | await checkNewPeerTubeVersion({ ...baseParams, latestVersion: '1.4.2', checkType: 'absence' }) |
83 | }) | 74 | }) |
84 | 75 | ||
85 | it('Should send a notification to admins on new plugin version', async function () { | 76 | it('Should send a notification to admins on new plugin version', async function () { |
@@ -88,7 +79,7 @@ describe('Test admin notifications', function () { | |||
88 | joinPeerTubeServer.setLatestVersion('15.4.2') | 79 | joinPeerTubeServer.setLatestVersion('15.4.2') |
89 | 80 | ||
90 | await wait(3000) | 81 | await wait(3000) |
91 | await checkNewPeerTubeVersion(baseParams, '15.4.2', 'presence') | 82 | await checkNewPeerTubeVersion({ ...baseParams, latestVersion: '15.4.2', checkType: 'presence' }) |
92 | }) | 83 | }) |
93 | 84 | ||
94 | it('Should not send the same notification to admins', async function () { | 85 | it('Should not send the same notification to admins', async function () { |
@@ -110,7 +101,7 @@ describe('Test admin notifications', function () { | |||
110 | joinPeerTubeServer.setLatestVersion('15.4.3') | 101 | joinPeerTubeServer.setLatestVersion('15.4.3') |
111 | 102 | ||
112 | await wait(3000) | 103 | await wait(3000) |
113 | await checkNewPeerTubeVersion(baseParams, '15.4.3', 'presence') | 104 | await checkNewPeerTubeVersion({ ...baseParams, latestVersion: '15.4.3', checkType: 'presence' }) |
114 | expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2) | 105 | expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2) |
115 | }) | 106 | }) |
116 | }) | 107 | }) |
@@ -121,17 +112,17 @@ describe('Test admin notifications', function () { | |||
121 | this.timeout(30000) | 112 | this.timeout(30000) |
122 | 113 | ||
123 | await wait(6000) | 114 | await wait(6000) |
124 | await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'absence') | 115 | await checkNewPluginVersion({ ...baseParams, pluginType: PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'absence' }) |
125 | }) | 116 | }) |
126 | 117 | ||
127 | it('Should send a notification to admins on new plugin version', async function () { | 118 | it('Should send a notification to admins on new plugin version', async function () { |
128 | this.timeout(30000) | 119 | this.timeout(30000) |
129 | 120 | ||
130 | await setPluginVersion(server.internalServerNumber, 'hello-world', '0.0.1') | 121 | await server.sql.setPluginVersion('hello-world', '0.0.1') |
131 | await setPluginLatestVersion(server.internalServerNumber, 'hello-world', '0.0.1') | 122 | await server.sql.setPluginLatestVersion('hello-world', '0.0.1') |
132 | await wait(6000) | 123 | await wait(6000) |
133 | 124 | ||
134 | await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'presence') | 125 | await checkNewPluginVersion({ ...baseParams, pluginType: PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'presence' }) |
135 | }) | 126 | }) |
136 | 127 | ||
137 | it('Should not send the same notification to admins', async function () { | 128 | it('Should not send the same notification to admins', async function () { |
@@ -149,8 +140,8 @@ describe('Test admin notifications', function () { | |||
149 | it('Should send a new notification after a new plugin release', async function () { | 140 | it('Should send a new notification after a new plugin release', async function () { |
150 | this.timeout(30000) | 141 | this.timeout(30000) |
151 | 142 | ||
152 | await setPluginVersion(server.internalServerNumber, 'hello-world', '0.0.1') | 143 | await server.sql.setPluginVersion('hello-world', '0.0.1') |
153 | await setPluginLatestVersion(server.internalServerNumber, 'hello-world', '0.0.1') | 144 | await server.sql.setPluginLatestVersion('hello-world', '0.0.1') |
154 | await wait(6000) | 145 | await wait(6000) |
155 | 146 | ||
156 | expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2) | 147 | expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2) |