aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/notifications/notifications-api.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-13 14:23:01 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (patch)
tree7a166515e4d57a06eb3c08be569f106ed049988b /server/tests/api/notifications/notifications-api.ts
parentd0a0fa429d4651710ed951a3c11af0219e408964 (diff)
downloadPeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.tar.gz
PeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.tar.zst
PeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.zip
Introduce user command
Diffstat (limited to 'server/tests/api/notifications/notifications-api.ts')
-rw-r--r--server/tests/api/notifications/notifications-api.ts25
1 files changed, 10 insertions, 15 deletions
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts
index e5864f1c2..f33d8e64d 100644
--- a/server/tests/api/notifications/notifications-api.ts
+++ b/server/tests/api/notifications/notifications-api.ts
@@ -7,14 +7,13 @@ import {
7 checkNewVideoFromSubscription, 7 checkNewVideoFromSubscription,
8 cleanupTests, 8 cleanupTests,
9 getAllNotificationsSettings, 9 getAllNotificationsSettings,
10 getMyUserInformation,
11 MockSmtpServer, 10 MockSmtpServer,
12 prepareNotificationsTest, 11 prepareNotificationsTest,
13 ServerInfo, 12 ServerInfo,
14 uploadRandomVideo, 13 uploadRandomVideo,
15 waitJobs 14 waitJobs
16} from '@shared/extra-utils' 15} from '@shared/extra-utils'
17import { User, UserNotification, UserNotificationSettingValue } from '@shared/models' 16import { UserNotification, UserNotificationSettingValue } from '@shared/models'
18 17
19const expect = chai.expect 18const expect = chai.expect
20 19
@@ -109,15 +108,14 @@ describe('Test notifications API', function () {
109 }) 108 })
110 109
111 { 110 {
112 const res = await getMyUserInformation(server.url, userToken) 111 const info = await server.usersCommand.getMyInfo({ token: userToken })
113 const info = res.body as User
114 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE) 112 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE)
115 } 113 }
116 114
117 const { name, uuid } = await uploadRandomVideo(server) 115 const { name, uuid } = await uploadRandomVideo(server)
118 116
119 const check = { web: true, mail: true } 117 const check = { web: true, mail: true }
120 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence') 118 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
121 }) 119 })
122 120
123 it('Should only have web notifications', async function () { 121 it('Should only have web notifications', async function () {
@@ -129,8 +127,7 @@ describe('Test notifications API', function () {
129 }) 127 })
130 128
131 { 129 {
132 const res = await getMyUserInformation(server.url, userToken) 130 const info = await server.usersCommand.getMyInfo({ token: userToken })
133 const info = res.body as User
134 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB) 131 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
135 } 132 }
136 133
@@ -138,12 +135,12 @@ describe('Test notifications API', function () {
138 135
139 { 136 {
140 const check = { mail: true, web: false } 137 const check = { mail: true, web: false }
141 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence') 138 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
142 } 139 }
143 140
144 { 141 {
145 const check = { mail: false, web: true } 142 const check = { mail: false, web: true }
146 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence') 143 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence')
147 } 144 }
148 }) 145 })
149 146
@@ -156,8 +153,7 @@ describe('Test notifications API', function () {
156 }) 153 })
157 154
158 { 155 {
159 const res = await getMyUserInformation(server.url, userToken) 156 const info = await server.usersCommand.getMyInfo({ token: userToken })
160 const info = res.body as User
161 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL) 157 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL)
162 } 158 }
163 159
@@ -165,12 +161,12 @@ describe('Test notifications API', function () {
165 161
166 { 162 {
167 const check = { mail: false, web: true } 163 const check = { mail: false, web: true }
168 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence') 164 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
169 } 165 }
170 166
171 { 167 {
172 const check = { mail: true, web: false } 168 const check = { mail: true, web: false }
173 await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence') 169 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence')
174 } 170 }
175 }) 171 })
176 172
@@ -186,8 +182,7 @@ describe('Test notifications API', function () {
186 }) 182 })
187 183
188 { 184 {
189 const res = await getMyUserInformation(server.url, userToken) 185 const info = await server.usersCommand.getMyInfo({ token: userToken })
190 const info = res.body as User
191 expect(info.notificationSettings.newVideoFromSubscription).to.equal( 186 expect(info.notificationSettings.newVideoFromSubscription).to.equal(
192 UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL 187 UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
193 ) 188 )